Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 46 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ on:
branches: [ master ]

jobs:
test:
test-uv-pip-install:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
continue-on-error: true

steps:
Expand All @@ -22,14 +22,43 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
- name: Install uv
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install -e . --no-deps
pip install uv

- name: Create virtual environment
run: |
uv venv

- name: Install dependencies with uv
run: |
uv pip install ."[tests]"

- name: Run tests
run: pytest
run: |
uv run pytest

test-pip-install:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.14']

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies with pip
run: |
pip install ."[tests]"

- name: Run tests
run: |
pytest

build-docs:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
Expand All @@ -52,12 +81,17 @@ jobs:
with:
python-version: '3.9'

- name: Install dependencies
- name: Install uv
run: |
pip install uv

- name: Create virtual environment
run: |
uv venv

- name: Install dependencies with uv
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install sphinx sphinx_rtd_theme sphinx-argparse
pip install -e . --no-deps
uv pip install ."[docs]"

- name: Build docs
working-directory: docs
Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
- name: Install uv
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build package (setup.py)
pip install uv

- name : Create virtual environment
run: |
python setup.py sdist bdist_wheel
uv venv

- name: Install project with uv
run: |
uv pip install -e .
- name: Build package with uv
run: |
uv build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
45 changes: 44 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,57 @@ model.compare(dataset) # See how the simulated and measured patterns compare
plt.show()
```

Further documentation is found [here](https://cdtools-developers.github.io/cdtools/).

# Installation

CDTools can be installed in several ways depending on your needs. For most users, installation from pypi is recommended. For developers or those who want the latest features, installation from source is available.

## Installation from pypi

CDTools can be installed via pip as the [cdtools-py](https://pypi.org/project/cdtools-py/) package on [PyPI](https://pypi.org/):

```bash
$ pip install cdtools-py
```

Further documentation is found [here](https://cdtools-developers.github.io/cdtools/).
or using [uv](https://github.com/astral-sh/uv):

```bash
$ uv pip install cdtools-py
```

## Installation from Source

For development or to access the latest features, CDTools can be installed directly from source:


```bash
$ git clone https://github.com/cdtools-developers/cdtools.git
$ cd cdtools
$ pip install -e .
```


or using [uv](https://github.com/astral-sh/uv):

```bash
$ git clone https://github.com/cdtools-developers/cdtools.git
$ cd cdtools
$ uv pip install -e .
```

## Installing for Contributors (with tests and docs dependencies)

If you want to run the test suite or build the documentation, install with the extra dependencies:

```bash
$ pip install -e ."[tests,docs]"
```
or with uv:
```bash
$ uv pip install -e ."[tests,docs]"
```

CDTools was developed in the [photon scattering lab](https://scattering.mit.edu/) at MIT, and further development took place within the [computational x-ray imaging group](https://www.psi.ch/en/cxi) at PSI. The code is distributed under an MIT (a.k.a. Expat) license. If you would like to publish any work that uses CDTools, please contact [Abe Levitan](mailto:abraham.levitan@psi.ch).

Expand Down
80 changes: 52 additions & 28 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Installation
============

CDTools supports python >=3.8 and can be installed via pip as the the `cdtools-py`_ package on `PyPI`_. If you plan to contribute to the code or need a custom environment, installation from source is also possible.
CDTools supports python >=3.9 and can be installed via pip as the the `cdtools-py`_ package on `PyPI`_. If you plan to contribute to the code or need a custom environment, installation from source is also possible.

.. _`cdtools-py`: https://pypi.org/project/cdtools-py/
.. _`PyPI`: https://pypi.org/
Expand All @@ -15,6 +15,14 @@ To install from `PyPI`_, run:

$ pip install cdtools-py

or you can use `uv`_ for a faster installation:

.. _`uv`: https://github.com/astral-sh/uv

.. code:: bash

$ uv pip install cdtools-py

Pytorch, a major dependence of CDTools, often needs to be installed with a specific CUDA version for machine compatability. If you run into issues with pytorch, consider first installing pytorch into your environment using the instructions on `the pytorch site`_.

.. _`the pytorch site`: https://pytorch.org/get-started/locally/
Expand All @@ -31,18 +39,51 @@ The source code for CDTools is hosted on `Github`_.
.. _`Github`: https://github.com/cdtools-developers/cdtools


Step 2: Install Dependencies
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To download the source code, you can either clone the repository using git:

.. code:: bash

$ git clone https://github.com/cdtools-developers/cdtools.git

or you can download a zip file of the repository from the `releases page`_.

.. _`releases page`: https://github.com/cdtools-developers/cdtools/releases

The major dependency for CDTools is pytorch version 2.3.0 or greater. Because the details of the pytorch installation can vary depending on platform and GPU availability, it is recommended that you first install pytorch using the instructions on `the pytorch site`_. The remaining dependencies can be installed by running the following command from the top level directory of the git repository:

Step 2: Install
^^^^^^^^^^^^^^^

Move to the directory where you downloaded the source code. It is recommended that you create a new python virtual environment to install CDTools into.

Installation using pip and uv. Editable mode is recommended for development purposes and is added with the `-e` flag.

.. code:: bash

$ pip install -r requirements.txt

Note that several optional dependencies used for testing and documentation will also be installed. The full set of dependencies and minimum requirements are listed below. CDTools is reguarly tested with the latest versions of these packages and with python 3.8 through 3.12.
$ pip install -e .

or using uv:

.. code:: bash

$ uv pip install -e .


Required dependencies:
To install the required test and documentation dependencies as well, use:

.. code:: bash

$ pip install -e ."[tests,docs]"

or using uv:

.. code:: bash

$ uv pip install -e ."[tests,docs]"

CDTools is reguarly tested with the latest versions of these packages and with python 3.9 through 3.14.


Required dependencies (see pyproject.toml for all details):

* `numpy <http://www.numpy.org>`_ >= 1.0
* `scipy <http://www.scipy.org>`_ >= 1.0
Expand All @@ -63,30 +104,13 @@ Optional dependencies for building docs:
* `sphinx_rtd_theme <https://sphinx-rtd-theme.readthedocs.io/en/stable/>`_ >= 0.5.1


Step 3: Install
^^^^^^^^^^^^^^^

To install CDTools, run the following command from the top level directory of the git repository:

.. code:: bash

$ pip install -e . --no-deps


This will install CDTools in developer mode, so that changes to the code will propagate to the installed version immediately. This is best if you plan to actively develop CDTools. If you simply need a custom environment, you can also install CDTools in standard mode using:

.. code:: bash

$ pip install . --no-deps


Step 4: Run The Tests
^^^^^^^^^^^^^^^^^^^^^
Optional step 4: Run The Tests
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

To ensure that the installation has worked correctly, it is recommended that you run the unit tests. Execute the following command from the top level directory of the git repository:

.. code:: bash

$ pytest
$ python -m pytest

If any tests fail, make sure that you have all the noted dependencies properly installed. If you do, and things still aren't working, `open an issue on the github page <https://github.com/cdtools-developers/cdtools/issues>`_ and we'll get to the bottom of it.
52 changes: 51 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,53 @@
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "cdtools-py"
description = "Tools for coherent diffractive imaging and ptychography"
readme = "README.md"
requires-python = ">=3.9"
license = { file = "LICENSE.txt" }
authors = [
{ name = "Abe Levitan", email = "abraham.levitan@psi.ch" },
{ name = "Dayne Y. Sasaki" },
{ name = "Damian Guenzing" },
{ name = "Madelyn Cain" },
{ name = "Anastasiia Kutakh" }
]
maintainers = [
{ name = "Abe Levitan", email = "abraham.levitan@psi.ch" }
]
keywords = ["ptychography", "CDI", "imaging", "torch", "differentiable"]
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
"License :: OSI Approved :: MIT License"
]
urls = { "Homepage" = "https://github.com/cdtools-developers/cdtools", "Documentation" = "https://cdtools-developers.github.io/cdtools/" }
dependencies = [
"numpy>=1.0",
"scipy>=1.0",
"matplotlib>=2.0",
"torch>=2.3.0",
"h5py>=2.1",
"python-dateutil",
]
dynamic = ["version"]

[tool.setuptools.dynamic]
version = {attr = "cdtools._version.__version__"}

[project.optional-dependencies]
tests = [
"pytest",
"pooch"
]
docs = [
"sphinx>=4.3.0",
"sphinx-argparse",
"sphinx_rtd_theme>=0.5.1"
]

[tool.ruff]
# Decrease the maximum line length to 79 characters.
line-length = 79
11 changes: 0 additions & 11 deletions requirements.txt

This file was deleted.

Loading