Skip to content

Commit d79f0bd

Browse files
authored
Standardize pyproject and relax dependencies (#54)
* Use standardized pyproject instead of poetry * Relax dependency pins for upstream libraries * Bump poetry version * Add dynamic version and remove generated version * Add __version__.py to gitignore * Replace poetry sections with uv (supporting setuptools-scm) * fix: set activate-environment * Use uv for running docs
1 parent 5c5212f commit d79f0bd

File tree

6 files changed

+75
-169
lines changed

6 files changed

+75
-169
lines changed

.github/workflows/pull-docs.yml

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,55 +8,28 @@ jobs:
88
strategy:
99
matrix:
1010
python-version: [ "3.11" ]
11-
poetry-version: [ "1.8.3" ]
1211
steps:
1312
# ======
14-
# Checkout, set up python
13+
# Checkout, set up python and uv
1514
# ======
1615
- name: Check out
17-
uses: actions/checkout@v4
18-
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v4
16+
uses: actions/checkout@v5
17+
- name: Install the latest version of uv
18+
uses: astral-sh/setup-uv@v7
2019
with:
2120
python-version: ${{ matrix.python-version }}
22-
# ======
23-
# Install and configure poetry from cache
24-
# ======
25-
- name: Load cached Poetry installation
26-
id: cached-poetry
27-
uses: actions/cache@v4
28-
with:
29-
path: ~/.local # the path depends on the OS
30-
key: poetry-${{ matrix.poetry-version }}
31-
- name: Install poetry
32-
if: steps.cached-poetry.outputs.cache-hit != 'true'
33-
uses: snok/install-poetry@v1
34-
with:
35-
version: ${{ matrix.poetry-version }}
36-
virtualenvs-create: true
37-
virtualenvs-in-project: true
38-
# ======
39-
# Load cached venv if cache exists
40-
# Install dependencies if cache does not exist
41-
# ======
42-
- name: Load cached venv
43-
id: cached-poetry-dependencies-docs
44-
uses: actions/cache@v4
45-
with:
46-
path: .venv
47-
key: docs-${{ matrix.python-version }}-${{ matrix.poetry-version }}-${{ hashFiles('**/poetry.lock') }}
21+
activate-environment: true
4822
- name: Install dependencies
49-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
50-
run: poetry install --no-interaction -E docs
23+
run: uv pip install .[docs]
5124
# ======
5225
# Install Pandoc
5326
# ======
5427
- name: Use pandoc (external to Poetry)
5528
uses: nikeee/setup-pandoc@v1
5629
# uses: docker://pandoc/latex:2.9
57-
- run: pip install pandoc
30+
- run: uv pip install pandoc
5831
# ======
5932
# Run test suite
6033
# ======
6134
- name: Make docs
62-
run: poetry run sphinx-build docs docs/_build
35+
run: uv run sphinx-build docs docs/_build

.github/workflows/push-test.yml

Lines changed: 14 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -9,112 +9,53 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
python-version: ["3.9"]
13-
poetry-version: ["1.2.1"]
14-
12+
python-version: ["3.9", "3.10", "3.11", "3.12"]
1513
steps:
1614
# ======
17-
# Checkout, set up python
15+
# Checkout, set up python and uv
1816
# ======
1917
- name: Check out
20-
uses: actions/checkout@v4
21-
- name: Set up Python ${{ matrix.python-version }}
22-
uses: actions/setup-python@v4
18+
uses: actions/checkout@v5
19+
- name: Install the latest version of uv
20+
uses: astral-sh/setup-uv@v7
2321
with:
2422
python-version: ${{ matrix.python-version }}
25-
# ======
26-
# Install and configure poetry
27-
# ======
28-
- name: Load cached Poetry installation
29-
id: cached-poetry
30-
uses: actions/cache@v4
31-
with:
32-
path: ~/.local # the path depends on the OS
33-
key: poetry-${{ matrix.poetry-version }}
34-
- name: Install Poetry
35-
if: steps.cached-poetry.outputs.cache-hit != 'true'
36-
uses: snok/install-poetry@v1
37-
with:
38-
version: ${{ matrix.poetry-version }}
39-
virtualenvs-create: true
40-
virtualenvs-in-project: true
41-
# ======
42-
# Load cached venv if cache exists
43-
# Install dependencies if cache does not exist
44-
# ======
45-
- name: Load cached venv
46-
id: cached-poetry-dependencies-dev
47-
uses: actions/cache@v4
48-
with:
49-
path: .venv
50-
key: dev-${{ matrix.python-version }}-${{ matrix.poetry-version }}-${{ hashFiles('**/poetry.lock') }}
23+
activate-environment: true
5124
- name: Install dependencies
52-
if: steps.cached-poetry-dependencies-dev.outputs.cache-hit != 'true'
53-
run: poetry install --no-interaction -E dev
25+
run: uv pip install .[dev]
5426
# ======
5527
# Run test suite
5628
# TODO: output code coverage, --cov=<project-dir> --cov-report=xml
5729
# https://github.com/marketplace/actions/install-poetry-action#codecov-upload
5830
# ======
5931
- name: Run tests
60-
run: poetry run pytest
32+
run: pytest
6133

6234
benchmarks:
6335
name: ASV Benchmarks
6436
needs: test
6537
runs-on: ubuntu-22.04
6638
strategy:
6739
matrix:
68-
python-version: ["3.9"]
69-
poetry-version: ["1.2.1"]
40+
python-version: ["3.9", "3.10", "3.11", "3.12"]
7041
steps:
7142
# ======
7243
# Checkout, set up python
7344
# ======
7445
- name: Check out
75-
uses: actions/checkout@v4
76-
with:
77-
fetch-depth: 0
78-
- name: Set up Python ${{ matrix.python-version }}
79-
uses: actions/setup-python@v4
46+
uses: actions/checkout@v5
47+
- name: Install the latest version of uv
48+
uses: astral-sh/setup-uv@v7
8049
with:
8150
python-version: ${{ matrix.python-version }}
82-
# ======
83-
# Install and configure poetry
84-
# ======
85-
- name: Load cached Poetry installation
86-
id: cached-poetry
87-
uses: actions/cache@v4
88-
with:
89-
path: ~/.local # the path depends on the OS
90-
key: poetry-${{ matrix.poetry-version }}
91-
- name: Install Poetry
92-
if: steps.cached-poetry.outputs.cache-hit != 'true'
93-
uses: snok/install-poetry@v1
94-
with:
95-
version: ${{ matrix.poetry-version }}
96-
virtualenvs-create: true
97-
virtualenvs-in-project: true
98-
# ======
99-
# Load cached venv if cache exists
100-
# Install dependencies if cache does not exist
101-
# ======
102-
- name: Load cached venv
103-
id: cached-poetry-dependencies-dev
104-
uses: actions/cache@v4
105-
with:
106-
path: .venv
107-
key: dev-${{ matrix.python-version }}-${{ matrix.poetry-version }}-${{ hashFiles('**/poetry.lock') }}
51+
activate-environment: true
10852
- name: Install dependencies
109-
if: steps.cached-poetry-dependencies-dev.outputs.cache-hit != 'true'
110-
run: poetry install --no-interaction -E dev
53+
run: uv pip install .[dev]
11154
# ======
11255
# Compare benchmarks between master and PR, and fail if any get worse
11356
# ======
114-
11557
- name: Setup ASV
11658
run: |
117-
pip install asv
11859
cd asv_bench
11960
asv machine --yes
12061
- name: Check regression

.github/workflows/release.yml

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,24 @@ jobs:
1515
strategy:
1616
matrix:
1717
python-version: ["3.9"]
18-
poetry-version: ["1.2.1"]
1918
steps:
2019
# ======
21-
# Checkout, set up python
20+
# Checkout, set up python and uv
2221
# ======
23-
- name: Checkout source
24-
uses: actions/checkout@v4
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v4
22+
- name: Check out
23+
uses: actions/checkout@v5
24+
- name: Install the latest version of uv
25+
uses: astral-sh/setup-uv@v7
2726
with:
2827
python-version: ${{ matrix.python-version }}
29-
# ======
30-
# Install poetry
31-
# ======
32-
- name: Install Poetry
33-
uses: snok/install-poetry@v1
34-
with:
35-
version: ${{ matrix.poetry-version }}
36-
virtualenvs-create: true
37-
virtualenvs-in-project: true
38-
# ======
39-
# Install dependencies
40-
# ======
41-
- name: Install dependencies
42-
run: poetry install --no-interaction --no-root
28+
activate-environment: true
4329
# ======
4430
# Build and upload package to Test-PyPI
45-
# Null API token? "There is no pypi-token.testpypi setting."
46-
# Test?
47-
# poetry config repositories.testpypi https://test.pypi.org/legacy/
48-
# poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_TOKEN }}
49-
# poetry publish --no-interaction --build -r testpypi
31+
# uv build
32+
# uv publish --repository testpypi --token ${{ secrets.TEST_PYPI_TOKEN }}
5033
# =====
5134
- name: Upload package
5235
run: |
53-
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
54-
poetry publish --no-interaction --build
36+
uv build
37+
uv publish --token ${{ secrets.PYPI_TOKEN }}
38+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ wheels/
2727
.installed.cfg
2828
*.egg
2929
MANIFEST
30+
# generated by setuptools-scm
31+
__version__.py
3032

3133
# PyInstaller
3234
# Usually these files are written by a python script from a template

derivative/__version__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

pyproject.toml

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,51 @@
11
[build-system]
2-
requires = ["poetry-core>=1.1.0"]
3-
build-backend = "poetry.core.masonry.api"
2+
requires = ["setuptools", "setuptools-scm"]
3+
build-backend = "setuptools.build_meta"
44

5-
[tool.poetry]
5+
[tool.setuptools.packages.find]
6+
where = ["."]
7+
include = ["derivative*"]
8+
9+
[project]
610
name = "derivative"
7-
version = "0.6.3"
11+
dynamic = ["version"]
812
description = "Numerical differentiation in python."
9-
repository = "https://github.com/andgoldschmidt/derivative"
10-
documentation = "https://derivative.readthedocs.io/"
11-
keywords = ["differentiation", "derivative", "gradient", "prime"]
13+
readme = "README.rst"
14+
requires-python = ">=3.9"
15+
license-files = ["LICENSE.rst"]
1216
authors = [
13-
"Andy Goldschmidt <andygold@uchicago.edu>",
14-
"Markus Quade <info@markusqua.de>",
15-
"Jacob Stevens-Haas <jmsh@uw.edu>"
17+
{ name = "Andy Goldschmidt", email = "andygold@uchicago.edu" },
18+
{ name = "Markus Quade", email = "info@markusqua.de" },
19+
{ name = "Jacob Stevens-Haas", email = "jmsh@uw.edu" },
20+
]
21+
keywords = ["differentiation", "derivative", "gradient", "prime"]
22+
dependencies = [
23+
"numpy>=1.18.3",
24+
"scipy>=1.4.1",
25+
"scikit-learn>=1.0.0",
26+
"importlib-metadata>=7.1.0",
27+
"spectral-derivatives>=0.8",
1628
]
17-
license = "MIT"
18-
readme = "README.rst"
19-
20-
[tool.poetry.dependencies]
21-
python = "^3.9"
22-
numpy = ">=1.18.3"
23-
scipy = "^1.4.1"
24-
scikit-learn = "^1"
25-
importlib-metadata = ">=7.1.0"
26-
spectral-derivatives = ">=0.8"
2729

28-
# docs
29-
sphinx = {version = "7.2.6", optional = true}
30-
nbsphinx = {version = "^0.9.5", optional = true}
31-
matplotlib = {version = "^3.2.1", optional = true}
32-
ipython = {version = "^8.0.0, !=8.7.0, !=8.18.1", optional = true}
33-
ipykernel = {version = "^6.0.0", optional = true}
30+
[project.optional-dependencies]
31+
docs = [
32+
"sphinx==7.2.6",
33+
"nbsphinx==0.9.5",
34+
"matplotlib",
35+
"ipython",
36+
"ipykernel",
37+
]
38+
dev = [
39+
"asv",
40+
"pytest>=7",
41+
]
3442

35-
# dev
36-
asv = {version = "^0.6", optional = true}
37-
pytest = {version = ">=7", optional = true}
43+
[project.urls]
44+
Repository = "https://github.com/andgoldschmidt/derivative"
45+
Documentation = "https://derivative.readthedocs.io/"
3846

39-
[tool.poetry.extras]
40-
docs = ["sphinx", "nbsphinx", "matplotlib", "ipython", "ipykernel"]
41-
dev = ["asv", "pytest"]
47+
[tool.setuptools_scm]
48+
write_to = "derivative/__version__.py"
4249

43-
[tool.poetry.plugins.'derivative.hyperparam_opt']
50+
[project.entry-points."derivative.hyperparam_opt"]
4451
"kalman.default" = "derivative.utils:_default_kalman"

0 commit comments

Comments
 (0)