From a17ecee306746b84617edece1e3c829b483222d9 Mon Sep 17 00:00:00 2001 From: Alistair Miles Date: Tue, 26 Mar 2024 09:53:54 +0000 Subject: [PATCH] Add Python 3.12 support (#409) * attempt upgrades * thrash * fix install * upgrade deploy action [ci skip] --- .github/workflows/deploy.yml | 27 ++++---- .github/workflows/test.yml | 11 ++-- allel/stats/roh.py | 4 +- pyproject.toml | 7 +- requirements_dev_base.txt | 6 +- requirements_dev_optional.txt | 24 +++---- setup.py | 118 +++++++++++++++++++--------------- tox.ini | 29 --------- 8 files changed, 107 insertions(+), 119 deletions(-) delete mode 100644 tox.ini diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index faf37c6d..4b432e3e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -11,37 +11,36 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, windows-2019, macos-11] + os: [ubuntu-latest, windows-latest, macos-13, macos-14] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 - name: Install Python - with: - python-version: '3.8' + - uses: actions/setup-python@v5 + + - name: Install cibuildwheel + run: python -m pip install cibuildwheel==2.17.0 - name: Build wheels - uses: pypa/cibuildwheel@v2.12.3 + run: python -m cibuildwheel --output-dir wheelhouse env: # Only build on Python 3 and skip 32-bit builds CIBW_BUILD: "cp3*-*" - CIBW_SKIP: "cp36-* cp37-* *-win32 *linux_i686" + CIBW_SKIP: "cp36-* cp37-* *-win32 *i686 *musl*" - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} path: ./wheelhouse/*.whl build_sdist: name: Build source distribution runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 name: Install Python - with: - python-version: '3.8' - name: Build sdist run: | @@ -63,7 +62,7 @@ jobs: name: artifact path: dist - - uses: pypa/gh-action-pypi-publish@master + - uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b73fe21e..b78316c4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,16 +14,17 @@ jobs: - windows-latest - macos-latest python-version: - - "3.8" - "3.9" - "3.10" + - "3.11" + - "3.12" steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -50,12 +51,12 @@ jobs: pytest -v allel - name: Test with doctest - if: matrix.platform == 'ubuntu-latest' && matrix.python-version == '3.10' + if: matrix.platform == 'ubuntu-latest' && matrix.python-version == '3.12' run: | pytest -v --cov=allel --doctest-modules allel coverage report -m - name: Build docs - if: matrix.platform == 'ubuntu-latest' && matrix.python-version == '3.10' + if: matrix.platform == 'ubuntu-latest' && matrix.python-version == '3.12' run: | cd docs && make html diff --git a/allel/stats/roh.py b/allel/stats/roh.py index 4b8520c8..244db04d 100644 --- a/allel/stats/roh.py +++ b/allel/stats/roh.py @@ -201,11 +201,11 @@ def roh_poissonhmm(gv, pos, phet_roh=0.001, phet_nonroh=(0.0025, 0.01), transiti Notes ----- - This function requires `pomegranate` (>= 0.9.0) to be installed. + This function requires `protopunica` to be installed. """ - from pomegranate import HiddenMarkovModel, PoissonDistribution + from protopunica import HiddenMarkovModel, PoissonDistribution is_accessible = asarray_ndim(is_accessible, 1, dtype=bool, allow_none=True) diff --git a/pyproject.toml b/pyproject.toml index 31c8d3ea..a22a53c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,10 @@ [project] name = "scikit-allel" -requires-python = ">=3.6" -dynamic = ["version", "description"] +requires-python = ">=3.9" +description = "A Python package for exploring and analysing genetic variation data." +readme = "README.rst" +dynamic = ["version", "classifiers", "license", "maintainers", "dependencies", "optional-dependencies"] + [build-system] # Minimum requirements for the build system to execute. diff --git a/requirements_dev_base.txt b/requirements_dev_base.txt index 2df611d8..c955fe5d 100644 --- a/requirements_dev_base.txt +++ b/requirements_dev_base.txt @@ -1,4 +1,4 @@ # required -cython==0.29.34 -numpy==1.24.3 -dask[array]==2023.4.1 +cython +numpy +dask[array] diff --git a/requirements_dev_optional.txt b/requirements_dev_optional.txt index 69e0507a..f72a5967 100644 --- a/requirements_dev_optional.txt +++ b/requirements_dev_optional.txt @@ -1,13 +1,13 @@ # optional -scipy==1.10.1 -matplotlib==3.7.1 -seaborn==0.12.2 -pandas==2.0.1 -scikit-learn==1.2.2 -h5py==3.8.0 -numexpr==2.8.4 -zarr==2.14.2 -hmmlearn==0.3.0 -pomegranate<1.0.0 -pyfasta==0.5.2 -ipython==8.13.0 +scipy +matplotlib +seaborn +pandas +scikit-learn +h5py +numexpr +zarr +hmmlearn +protopunica +pyfasta +ipython diff --git a/setup.py b/setup.py index d56982b8..1156cb95 100644 --- a/setup.py +++ b/setup.py @@ -3,90 +3,104 @@ import setuptools_scm -DISTNAME = 'scikit-allel' +DISTNAME = "scikit-allel" -PACKAGE_NAME = 'allel' +PACKAGE_NAME = "allel" -DESCRIPTION = 'A Python package for exploring and analysing genetic ' \ - 'variation data.' +DESCRIPTION = "A Python package for exploring and analysing genetic variation data." -with open('README.rst') as f: - LONG_DESCRIPTION = f.read() +MAINTAINER = "Alistair Miles" -MAINTAINER = 'Alistair Miles' +MAINTAINER_EMAIL = "alimanfoo@googlemail.com" -MAINTAINER_EMAIL = 'alimanfoo@googlemail.com' +URL = "https://github.com/cggh/scikit-allel" -URL = 'https://github.com/cggh/scikit-allel' +DOWNLOAD_URL = "http://pypi.python.org/pypi/scikit-allel" -DOWNLOAD_URL = 'http://pypi.python.org/pypi/scikit-allel' +LICENSE = "MIT" -LICENSE = 'MIT' - -INSTALL_REQUIRES = ['numpy', 'dask[array]'] +INSTALL_REQUIRES = ["numpy", "dask[array]"] # full installation with all optional dependencies -EXTRAS_REQUIRE = {'full': ['scipy', 'matplotlib', 'seaborn', 'pandas', 'scikit-learn', - 'h5py', 'numexpr', 'zarr', 'hmmlearn', 'pomegranate', 'nose']} +EXTRAS_REQUIRE = { + "full": [ + "scipy", + "matplotlib", + "seaborn", + "pandas", + "scikit-learn", + "h5py", + "numexpr", + "zarr", + "hmmlearn", + "protopunica", + "nose", + ] +} CLASSIFIERS = [ - 'Development Status :: 4 - Beta', - 'License :: OSI Approved :: MIT License', - 'Intended Audience :: Developers', - 'Intended Audience :: Science/Research', - 'Programming Language :: Python', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Scientific/Engineering', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX', - 'Operating System :: Unix', - 'Operating System :: MacOS', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', + "Development Status :: 4 - Beta", + "License :: OSI Approved :: MIT License", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Programming Language :: Python", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Scientific/Engineering", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Operating System :: MacOS", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] # noinspection PyUnresolvedReferences def setup_extensions(metadata): try: - print('[scikit-allel] setup extensions with cython') + print("[scikit-allel] setup extensions with cython") from Cython.Build import cythonize import numpy - ext_modules = cythonize([ - Extension('allel.opt.model', - sources=['allel/opt/model.pyx'], - include_dirs=[numpy.get_include()], - ), - Extension('allel.opt.stats', - sources=['allel/opt/stats.pyx'], - include_dirs=[numpy.get_include()], - ), - Extension('allel.opt.io_vcf_read', - sources=['allel/opt/io_vcf_read.pyx'], - include_dirs=[numpy.get_include()], - ), - ]) - metadata['ext_modules'] = ext_modules + + ext_modules = cythonize( + [ + Extension( + "allel.opt.model", + sources=["allel/opt/model.pyx"], + include_dirs=[numpy.get_include()], + ), + Extension( + "allel.opt.stats", + sources=["allel/opt/stats.pyx"], + include_dirs=[numpy.get_include()], + ), + Extension( + "allel.opt.io_vcf_read", + sources=["allel/opt/io_vcf_read.pyx"], + include_dirs=[numpy.get_include()], + ), + ] + ) + metadata["ext_modules"] = ext_modules except ImportError: - print('[scikit-allel] cython not available, not including extensions') + print("[scikit-allel] cython not available, not including extensions") def setup_package(): - metadata = dict( name=DISTNAME, maintainer=MAINTAINER, maintainer_email=MAINTAINER_EMAIL, description=DESCRIPTION, - long_description=LONG_DESCRIPTION, license=LICENSE, url=URL, download_url=DOWNLOAD_URL, - package_dir={'': '.'}, + package_dir={"": "."}, packages=find_packages(), - package_data={'allel.test': ['data/*']}, + package_data={"allel.test": ["data/*"]}, classifiers=CLASSIFIERS, install_requires=INSTALL_REQUIRES, extras_require=EXTRAS_REQUIRE, @@ -96,5 +110,5 @@ def setup_package(): setup(**metadata) -if __name__ == '__main__': +if __name__ == "__main__": setup_package() diff --git a/tox.ini b/tox.ini deleted file mode 100644 index f43c5f87..00000000 --- a/tox.ini +++ /dev/null @@ -1,29 +0,0 @@ -# Tox (http://tox.testrun.org/) is a tool for running tests -# in multiple virtualenvs. This configuration file will run the -# test suite on all supported python versions. To use it, "pip install tox" -# and then run "tox" from this directory. - -[tox] -envlist = py37, py38, docs - -[testenv] -setenv = - PYTHONHASHSEED = 42 -commands = - python setup.py build_ext --inplace - py37: pytest -v --cov=allel allel - py38: pytest -v --cov=allel --doctest-modules allel - coverage report -m - py38: flake8 allel --max-line-length=100 - pip freeze -deps = - -rrequirements_dev_base.txt - -rrequirements_test.txt - -rrequirements_dev_optional.txt - -[testenv:docs] -basepython = python3.8 -deps = -rrequirements_rtfd.txt -commands = - python setup.py install - sphinx-build -W -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html