From fed8252dcc0ced0a6cfc73a50ac82238ecd0500b Mon Sep 17 00:00:00 2001 From: Ben Jeffery Date: Mon, 8 Sep 2025 09:36:47 +0100 Subject: [PATCH] Move reqs into pyproject, remove setup.py --- .github/workflows/docs.yml | 9 ++- .github/workflows/tests.yml | 7 +- docs/development.md | 4 +- pyproject.toml | 91 ++++++++++++++++++++++++ requirements/CI-conda/ci-environment.yml | 15 ---- requirements/CI-conda/requirements.txt | 3 - requirements/CI-docs/requirements.txt | 9 --- requirements/CI-pip/requirements.txt | 6 -- requirements/conda-minimal.txt | 4 -- setup.py | 45 ------------ 10 files changed, 105 insertions(+), 88 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements/CI-conda/ci-environment.yml delete mode 100644 requirements/CI-conda/requirements.txt delete mode 100644 requirements/CI-docs/requirements.txt delete mode 100644 requirements/CI-pip/requirements.txt delete mode 100644 requirements/conda-minimal.txt delete mode 100644 setup.py diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 09d1bf8f..632f820b 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -36,7 +36,7 @@ jobs: /usr/share/miniconda/envs/anaconda-client-env ~/osx-conda ~/.profile - key: conda-v${{ env.CACHE_NUM }}-${{ hashFiles('requirements/CI-docs/requirements.txt') }} + key: conda-v${{ env.CACHE_NUM }}-${{ hashFiles('pyproject.toml') }} - name: Install Conda uses: conda-incubator/setup-miniconda@v3.1.1 @@ -54,11 +54,14 @@ jobs: run: | conda install --yes slim - - name: Install pip deps + - name: Install uv and pip deps if: steps.cache.outputs.cache-hit != 'true' shell: bash -l {0} run: | - pip install -r requirements/CI-docs/requirements.txt + pip install uv + uv pip install --system -r pyproject.toml --extra docs + # Install current pyslim as editable to ensure we get the latest version + uv pip install --system -e . # # Retaining commented block for next devel cycle # - name: Build SLiM diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 25e3827e..c159c99a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,7 +50,6 @@ jobs: uses: mamba-org/setup-micromamba@v2.0.4 with: environment-name: anaconda-client-env - environment-file: requirements/CI-conda/ci-environment.yml cache-environment: true create-args: | python=${{ matrix.python }} @@ -92,6 +91,12 @@ jobs: cmake -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release .. make -j 2 + - name: Install uv and dependencies + shell: bash -l {0} + run: | + pip install uv + uv pip install --system -r pyproject.toml --extra test + - name: Install SLiM macos / linux if: (matrix.os == 'macos-latest' || matrix.os == 'ubuntu-24.04') run: | diff --git a/docs/development.md b/docs/development.md index 1a403336..b28be4f1 100644 --- a/docs/development.md +++ b/docs/development.md @@ -21,7 +21,7 @@ To install a particular version of ``pyslim`` from source, e.g., to obtain a rec ```bash git clone https://github.com/tskit-dev/pyslim.git cd pyslim -python setup.py install --user +python -m pip install -e ".[dev]" ``` @@ -48,7 +48,7 @@ git clone git@github.com:YOUR_GITHUB/pyslim.git ``` - Install the development requirements using - ``python3 -m pip install -r requirements/development.txt``. + ``python3 -m pip install -e ".[dev]"``. - Run the tests to ensure everything has worked: ``python3 -m pytest tests``. These should all pass. - Make your changes in a local branch, and open a pull request on GitHub when you diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..e1637407 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,91 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "pyslim" +dynamic = ["version"] +description = "Manipulate tree sequences produced by SLiM." +readme = "README.md" +license = {text = "MIT"} +authors = [ + {name = "Peter Ralph", email = "petrel.harp@gmail.com"}, +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: MacOS :: MacOS X", + "Operating System :: POSIX", + "Operating System :: Microsoft :: Windows", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Bio-Informatics", +] +keywords = ["tree sequences", "tskit"] +requires-python = ">=3.9" +dependencies = [ + "msprime>=1.0.1", + "tskit", + "numpy", +] + +[project.urls] +homepage = "https://github.com/tskit-dev/pyslim" +repository = "https://github.com/tskit-dev/pyslim" +"Bug Reports" = "https://github.com/tskit-dev/pyslim/issues" + +[tool.setuptools] +packages = ["pyslim"] +include-package-data = true + +[tool.setuptools.dynamic] +version = {attr = "pyslim._version.pyslim_version"} + +[project.optional-dependencies] +test = [ + "flake8==7.1.2", + "pytest==8.3.5", + "pytest-cov==6.1.1", + "pytest-xdist==3.6.1", + "filelock==3.19.1", + "tskit==0.6.4", + "msprime>=1.2.0", + "matplotlib==3.9.4", + "pandas==2.3.2", +] + +docs = [ + "jupyter-book==1.0.4.post1", + "matplotlib==3.10.3", + "msprime==1.3.4", + "pandas==2.2.3", + "PyGithub==2.6.1", + "setuptools-scm==8.2.1", + "sphinx-argparse==0.5.2", + "sphinx-issues==5.0.0", + "tskit==0.6.3", +] + +dev = [ + "flake8>=7.0", + "pytest>=8.0", + "pytest-cov>=6.0", + "pytest-xdist>=3.0", + "numpy", + "filelock", + "tskit>=0.6.3", + "msprime>=1.2.0", + "matplotlib>=3.0", + "pandas>=2.0", + "jupyter-book>=1.0", + "setuptools-scm>=8.0", + "sphinx-argparse>=0.5", + "sphinx-issues>=5.0", +] \ No newline at end of file diff --git a/requirements/CI-conda/ci-environment.yml b/requirements/CI-conda/ci-environment.yml deleted file mode 100644 index 5b9b11a5..00000000 --- a/requirements/CI-conda/ci-environment.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: anaconda-client-env -channels: - - conda-forge - - anaconda - - defaults -dependencies: - - tskit>=0.6.3 - - msprime>=1.2.0 - - matplotlib - - pandas - - numpy - - pytest - - pytest-cov - - pytest-xdist - - filelock diff --git a/requirements/CI-conda/requirements.txt b/requirements/CI-conda/requirements.txt deleted file mode 100644 index 6b103443..00000000 --- a/requirements/CI-conda/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -tskit>=0.6.3 -msprime>=1.2.0 - diff --git a/requirements/CI-docs/requirements.txt b/requirements/CI-docs/requirements.txt deleted file mode 100644 index fdb68470..00000000 --- a/requirements/CI-docs/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -jupyter-book==1.0.4.post1 -matplotlib==3.10.3 -msprime==1.3.4 -pandas==2.2.3 -PyGithub==2.6.1 -setuptools-scm==8.2.1 -sphinx-argparse==0.5.2 -sphinx-issues==5.0.0 -tskit==0.6.3 diff --git a/requirements/CI-pip/requirements.txt b/requirements/CI-pip/requirements.txt deleted file mode 100644 index f1f5b14e..00000000 --- a/requirements/CI-pip/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -flake8==7.1.2 -pytest==8.3.5 -pytest-cov==6.1.1 -pytest-xdist==3.6.1 -numpy -filelock diff --git a/requirements/conda-minimal.txt b/requirements/conda-minimal.txt deleted file mode 100644 index c6bf88dd..00000000 --- a/requirements/conda-minimal.txt +++ /dev/null @@ -1,4 +0,0 @@ -tskit>=0.6.3 -msprime>=1.2.0 -kastore -numpy diff --git a/setup.py b/setup.py deleted file mode 100644 index 84f4f202..00000000 --- a/setup.py +++ /dev/null @@ -1,45 +0,0 @@ -from codecs import open as codecs_open -from setuptools import setup, find_packages -from warnings import warn -import os - - -# Get the long description from the relevant file -with codecs_open('README.md', encoding='utf-8') as f: - long_description = f.read() - -# After exec'ing this file we have tskit_version defined. -tskit_version = None # Keep PEP8 happy. -version_file = os.path.join("pyslim", "_version.py") -with open(version_file) as f: - exec(f.read()) - -setup(name='pyslim', - version=pyslim_version, - description=u"Manipulate tree sequences produced by SLiM.", - long_description=long_description, - long_description_content_type="text/markdown", - classifiers=[], - keywords=['tree sequences', 'tskit'], - author=u"Peter Ralph", - author_email='petrel.harp@gmail.com', - url='https://github.com/tskit-dev/pyslim', - license='MIT', - packages=['pyslim'], - include_package_data=True, - zip_safe=False, - install_requires=[ - 'msprime>=1.0.1', - 'tskit', - 'numpy' - ], - extras_require={ - 'dev': [], - }, - - setup_requires=[], - project_urls={ - 'Bug Reports': 'https://github.com/tskit-dev/pyslim/issues', - 'Source': 'https://github.com/tskit-dev/pyslim', - }, -)