refactor: CI installation process to use 'uv' for faster dependency management

This commit is contained in:
gnzng
2025-11-10 12:23:09 -08:00
parent 5d43b05822
commit be28903be7
5 changed files with 67 additions and 78 deletions
+11 -10
View File
@@ -22,14 +22,15 @@ 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: Install dependencies with uv
run: |
uv pip install ."[tests]"
- name: Run tests
run: pytest
run: python -m pytest
build-docs:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
@@ -52,12 +53,12 @@ jobs:
with:
python-version: '3.9'
- name: Install dependencies
- name: Install uv
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install sphinx sphinx_rtd_theme sphinx-argparse
pip install -e . --no-deps
pip install uv
- name: Install dependencies with uv
run: |
uv pip install ."[docs]""
- name: Build docs
working-directory: docs
+7 -5
View File
@@ -19,12 +19,14 @@ 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: Install project with uv
run: |
python setup.py sdist bdist_wheel
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
+49 -1
View File
@@ -1,3 +1,51 @@
[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.8"
license = { file = "LICENSE.txt" }
authors = [
{ name = "Abe Levitan", email = "abraham.levitan@psi.ch" },
{ 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
View File
@@ -1,11 +0,0 @@
numpy>=1.0
scipy>=1.0
matplotlib>=2.0 # 2.0 introduces better colormaps which are used by default
torch>=1.9.0 #1.9.0 implements support for autograd on indexed complex tensors
h5py>=2.1
python-dateutil
pytest
pooch
sphinx>=4.3.0 # Fixes a bug with bulleted lists
sphinx-argparse
sphinx_rtd_theme>=0.5.1 # Fixes a bug with bulleted lists
-51
View File
@@ -1,51 +0,0 @@
import setuptools
import os
import re
with open("README.md", "r") as fh:
long_description = fh.read()
# read version from src/cdtools/_version.py
version_file = os.path.join("src/cdtools", "_version.py")
with open(version_file) as f:
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", f.read(), re.M)
if not version_match:
raise RuntimeError("Unable to find version string.")
version = version_match.group(1)
setuptools.setup(
name="cdtools-py",
version=version,
python_requires='>3.8', # recommended minimum version for pytorch 2.3.0
author="Abe Levitan",
author_email="abraham.levitan@psi.ch",
description="Tools for coherent diffractive imaging and ptychography",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/cdtools-developers/cdtools",
install_requires=[
"numpy>=1.0",
"scipy>=1.0",
"matplotlib>=2.0", # 2.0 has better colormaps which are used by default
"python-dateutil",
"torch>=2.3.0", #2.3.0 is the earliest release for which L-BFGS works directly on complex-valued leaf tensors
"h5py>=2.1"],
extras_require={
'tests': [
"pytest",
"pooch",
],
'docs': [
"sphinx>=4.3.0",
"sphinx-argparse",
"sphinx_rtd_theme>=0.5.1"
]
},
package_dir={"": "src"},
packages=setuptools.find_packages("src"),
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
)