Skip to content

Commit d30fb27

Browse files
committed
Reqs in pyproject
1 parent 5f3bc2f commit d30fb27

File tree

14 files changed

+132
-215
lines changed

14 files changed

+132
-215
lines changed

.circleci/config.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ commands:
1313
# Install meson to the system packages so we can run it as root
1414
pip install --upgrade pip wheel
1515
sudo pip install meson
16-
# Needed for some build steps in requirements.txt, no blas as expensive to
16+
# Install uv for dependency management
17+
pip install --user uv
18+
# Install dependencies from pyproject.toml, no blas as expensive to
1719
# build on 32 bit
1820
pip install --user numpy --config-settings=setup-args="-Dallow-noblas=true"
19-
pip install --user -r python/requirements/CI-complete/requirements.txt --config-settings=setup-args="-Dallow-noblas=true"
21+
cd python && uv pip install --system -r pyproject.toml --extra test --config-settings=setup-args="-Dallow-noblas=true"
2022
# Remove tskit installed by msprime
2123
pip uninstall tskit -y
2224
echo 'export PATH=/home/circleci/.local/bin:$PATH' >> $BASH_ENV

.github/workflows/docs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ on:
88
- '*'
99
jobs:
1010
Docs:
11-
uses: tskit-dev/.github/.github/workflows/docs-build-template.yml@main
11+
uses: tskit-dev/.github/.github/workflows/docs-build-template.yml@v1
1212
with:
13-
requirements-path: python/requirements/CI-docs/requirements.txt
1413
additional-setup: sudo apt-get install -y doxygen
1514
make-command: make -C python

.github/workflows/tests.yml

Lines changed: 28 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,6 @@ jobs:
5353
run: |
5454
brew install libxml2 libxslt
5555
56-
- name: Cache conda and dependencies
57-
id: cache
58-
uses: actions/[email protected]
59-
with:
60-
path: ${{ env.CONDA }}/envs
61-
key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.python}}-conda-v1-${{ hashFiles('python/requirements/CI-tests-conda/requirements.txt') }}-${{ hashFiles('python/requirements/CI-tests-pip/requirements.txt') }}
62-
63-
- name: Install Conda
64-
uses: conda-incubator/[email protected]
65-
if: steps.cache.outputs.cache-hit != 'true'
66-
with:
67-
activate-environment: anaconda-client-env
68-
python-version: ${{ matrix.python }}
69-
channels: conda-forge
70-
channel-priority: strict
71-
auto-update-conda: true
72-
7356
- name: Fix windows symlinks
7457
working-directory: python
7558
if: matrix.os == 'windows-latest'
@@ -80,47 +63,36 @@ jobs:
8063
cp -r --dereference ../c/tskit lib/.
8164
cp ../c/tskit.h lib/.
8265
83-
- name: Fix windows .profile
84-
if: steps.cache.outputs.cache-hit != 'true' && matrix.os == 'windows-latest'
85-
run: |
86-
cp ~/.bash_profile ~/.profile
87-
88-
- name: Install conda deps
89-
if: steps.cache.outputs.cache-hit != 'true'
90-
shell: bash -l {0} #We need a login shell to get conda
91-
run: |
92-
conda install --yes --file=python/requirements/CI-tests-conda/requirements.txt
93-
94-
- name: Install pip deps
95-
if: steps.cache.outputs.cache-hit != 'true'
96-
shell: bash -l {0}
66+
- name: Install uv and set the python version
67+
uses: astral-sh/setup-uv@v6
68+
with:
69+
python-version: ${{ matrix.python }}
70+
version: "0.8.15"
71+
72+
- name: Install dependencies
73+
working-directory: python
9774
run: |
98-
pip install -r python/requirements/CI-tests-pip/requirements.txt
99-
# Remove tskit installed by conda
100-
pip uninstall -y tskit
75+
uv venv
76+
uv pip install -r pyproject.toml --extra test
77+
# Remove tskit installed as a dep of msprime
78+
uv pip uninstall tskit
10179
10280
- name: Build module
10381
working-directory: python
10482
run: |
105-
source ~/.profile
106-
conda activate anaconda-client-env
107-
python setup.py build_ext --inplace
83+
uv run --no-sync python setup.py build_ext --inplace
10884
10985
- name: Minidom test
11086
working-directory: python
11187
# Importing either IPython or pytest causes import of xml.dom.minidom
11288
# So to actually test that tskit imports it, we need a minimal test
11389
run: |
114-
source ~/.profile
115-
conda activate anaconda-client-env
116-
python -c "import tskit;tskit.Tree.generate_star(5).tree_sequence.draw_svg(path='test.svg')"
90+
uv run --no-sync python -c "import tskit;tskit.Tree.generate_star(5).tree_sequence.draw_svg(path='test.svg')"
11791
11892
- name: Run JIT code coverage
11993
working-directory: python
12094
run: |
121-
source ~/.profile
122-
conda activate anaconda-client-env
123-
NUMBA_DISABLE_JIT=1 python -m pytest -x --cov=tskit --cov-report=xml --cov-branch -n2 tests/test_jit.py
95+
NUMBA_DISABLE_JIT=1 uv run --no-sync python -m pytest -x --cov=tskit --cov-report=xml --cov-branch -n2 tests/test_jit.py
12496
12597
- name: Upload coverage to Codecov
12698
uses: codecov/[email protected]
@@ -134,12 +106,10 @@ jobs:
134106
- name: Run tests
135107
working-directory: python
136108
run: |
137-
source ~/.profile
138-
conda activate anaconda-client-env
139109
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
140-
python -m pytest -x --skip-slow --cov=tskit --cov-report=xml --cov-branch -n2 --durations=20 tests
110+
uv run --no-sync python -m pytest -x --skip-slow --cov=tskit --cov-report=xml --cov-branch -n2 --durations=20 tests
141111
else
142-
python -m pytest -x --cov=tskit --cov-report=xml --cov-branch -n2 --durations=20 tests
112+
uv run --no-sync python -m pytest -x --cov=tskit --cov-report=xml --cov-branch -n2 --durations=20 tests
143113
fi
144114
145115
- name: Upload coverage to Codecov
@@ -173,21 +143,28 @@ jobs:
173143
with:
174144
python-version: '3.12'
175145

146+
- name: Install uv
147+
uses: astral-sh/setup-uv@v6
148+
with:
149+
version: "0.8.15"
150+
176151
- name: Install dependencies
177152
working-directory: python
178153
run: |
179-
pip install -r requirements/CI-complete/requirements.txt
180-
pip install "numpy<2"
154+
uv venv
155+
uv pip install -r pyproject.toml --extra test
156+
uv pip uninstall tskit
157+
uv pip install "numpy<2"
181158
182159
- name: Build module
183160
working-directory: python
184161
run: |
185-
python setup.py build_ext --inplace
162+
uv run --no-sync python setup.py build_ext --inplace
186163
187164
- name: Run tests with numpy 1.x
188165
working-directory: python
189166
run: |
190-
python -m pytest -x --cov=tskit --cov-report=xml --cov-branch -n2 tests/test_lowlevel.py tests/test_highlevel.py
167+
uv run --no-sync python -m pytest -x --cov=tskit --cov-report=xml --cov-branch -n2 tests/test_lowlevel.py tests/test_highlevel.py
191168
192169
- name: Upload coverage to Codecov
193170
uses: codecov/[email protected]

.pyup.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/development.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,32 +78,29 @@ with:
7878
$ sudo apt install python3-dev python-is-python3 build-essential doxygen
7979
```
8080

81-
Python packages required for development are listed in `python/requirements/development.txt`.
82-
These can be installed using `pip`. We recommend using an isolated environment as below:
81+
The packages needed for development are specified as optional dependencies
82+
in the ``python/pyproject.toml`` file. Install these using:
8383

8484
```bash
8585
$ python3 -m venv env
8686
$ source env/bin/activate
87-
$ python3 -m pip install -r python/requirements/development.txt
87+
$ cd python
88+
$ python3 -m pip install -e ".[dev]"
8889
```
8990

9091
A few extra dependencies are required if you wish to work on the
9192
{ref}`C library <sec_development_c_requirements>`.
9293

93-
For OSX and Windows users we recommending using
94+
For OSX and Windows users we recommend using
9495
[conda](https://docs.conda.io/projects/conda/en/latest/),
9596
and isolating development in a dedicated environment as follows:
9697

9798
```bash
98-
$ conda env create -f python/requirements/development.yml
99+
$ conda env create -f python/development.yml
99100
$ conda activate tskit-dev
100101
```
101102

102-
On macOS, conda builds are generally done using `clang` packages that are kept up to date:
103-
104-
```bash
105-
$ conda install clang_osx-64 clangxx_osx-64
106-
```
103+
The environment includes macOS-specific clang packages when needed.
107104

108105
In order to make sure that these compilers work correctly (*e.g.*, so that they can find
109106
other dependencies installed via `conda`), you need to compile `tskit` with this command
@@ -442,9 +439,8 @@ Test code is contained in the `tests` directory. Tests are also roughly split
442439
by function, so that tests for the `drawing` module are in the
443440
`tests/test_drawing.py` file. This is not a one-to-one mapping, though.
444441

445-
The `requirements` directory contains descriptions of the requirements
446-
needed for development and on various
447-
{ref}`sec_development_continuous_integration` providers.
442+
Development dependencies are specified in the `pyproject.toml` file
443+
and can be installed using pip or conda (via `development.yml`).
448444

449445
(sec_development_python_style)=
450446

@@ -651,7 +647,7 @@ $ sudo apt install libcunit1-dev ninja-build meson clang-format-6.0
651647
if so, you can install it instead with `pip` by running
652648
`pip3 install clang-format==6.0.1 && ln -s clang-format $(which clang-format)-6.0`.
653649

654-
Conda users can install the basic requirements from `python/requirements/development.txt`.
650+
Conda users can install the development environment using `python/development.yml`.
655651

656652
Unfortunately clang-format is not available on conda, but it is not essential.
657653

python/development.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: tskit-dev
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- python>=3.9
6+
- pip
7+
- doxygen
8+
- numpy
9+
- pandas
10+
- scipy
11+
- pytest
12+
- pytest-cov
13+
- pytest-xdist
14+
- coverage
15+
- flake8
16+
- mypy
17+
- pre-commit
18+
- sphinx>=4.4
19+
- jupyter-book
20+
- networkx
21+
- matplotlib
22+
- jsonschema

python/pyproject.toml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,73 @@ packages = ["tskit"]
6262
[tool.setuptools.dynamic]
6363
version = {attr = "tskit._version.tskit_version"}
6464

65+
[project.optional-dependencies]
66+
test = [
67+
"biopython==1.85",
68+
"coverage==7.7.0",
69+
"dendropy==5.0.1",
70+
"kastore==0.3.3",
71+
"lshmm==0.0.8",
72+
"msgpack==1.1.0",
73+
"msprime==1.3.4",
74+
"networkx==3.2.1",
75+
"numba==0.61.2; python_version>='3.10'",
76+
"numba==0.60.0; python_version=='3.9'",
77+
"portion==2.6.0",
78+
"pytest==8.3.5",
79+
"pytest-cov==6.0.0",
80+
"pytest-xdist==3.6.1",
81+
"tszip==0.2.5",
82+
"xmlunittest==1.0.1",
83+
"svgwrite==1.4.3",
84+
"newick==1.10.0",
85+
"zarr<3",
86+
]
87+
88+
docs = [
89+
"jupyter-book==1.0.4.post1",
90+
"breathe==4.35.0",
91+
"sphinx-autodoc-typehints==2.3.0",
92+
"sphinx-issues==5.0.0",
93+
"sphinx-argparse==0.5.2",
94+
"msprime==1.3.3",
95+
"numba==0.61.2",
96+
"sphinx-book-theme",
97+
"pandas==2.2.3",
98+
]
99+
100+
dev = [
101+
"biopython>=1.70",
102+
"coverage",
103+
"dendropy",
104+
"flake8",
105+
"kastore",
106+
"lshmm",
107+
"msgpack",
108+
"msprime",
109+
"mypy",
110+
"networkx",
111+
"numba",
112+
"portion",
113+
"pre-commit",
114+
"pytest",
115+
"pytest-cov",
116+
"pytest-xdist",
117+
"setuptools_scm",
118+
"svgwrite",
119+
"tszip",
120+
"xmlunittest",
121+
"newick",
122+
"zarr<3",
123+
"jupyter-book",
124+
"breathe",
125+
"sphinx-autodoc-typehints",
126+
"sphinx-issues",
127+
"sphinx-argparse",
128+
"sphinx-book-theme",
129+
"pandas",
130+
]
131+
65132
[tool.pytest.ini_options]
66133
addopts = "-n 4"
67134
testpaths = ["tests"]

python/requirements/CI-complete/requirements.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.

python/requirements/CI-docs/requirements.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

python/requirements/CI-tests-conda/requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)