From b1f5dd8a4ec6846bd1bc090147e4175670555e5b Mon Sep 17 00:00:00 2001 From: Hugo MacDermott-Opeskin Date: Tue, 20 Dec 2022 13:18:46 +1000 Subject: [PATCH] Add pyproject.toml and drop support for python < 3.8 (#101) * add pyproject.toml * clean up setup.py for py3.8 minimum * update CI * remove packaging * add wheel build * add in runtime deps * try python3 kludge * change shell to pickup right python version * revert python3 kludging * add activate step * Revert "add activate step" This reverts commit 5e74c6eb5a68eefecb53225032b1613f237c2875. * change shell for each setup * remove defaulkt shell * delete empty * split shell defaults * Update pyproject.toml Co-authored-by: Irfan Alibay * add install and setup_requires * remove print_function * remove pip install of reqs Co-authored-by: Irfan Alibay --- .github/workflows/build.yml | 45 ++++++++++++++++++++++++++++++++----- pyproject.toml | 20 +++++++++++++++++ setup.cfg | 9 +++++++- setup.py | 11 +-------- 4 files changed, 68 insertions(+), 17 deletions(-) create mode 100644 pyproject.toml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9f14f49..c45d39bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,22 +17,21 @@ concurrency: group: "${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }}" cancel-in-progress: true -defaults: - run: - shell: bash -l {0} - jobs: build: + defaults: + run: + shell: bash -l {0} runs-on: ${{matrix.os}} strategy: max-parallel: 12 fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Miniconda uses: conda-incubator/setup-miniconda@v2 with: @@ -47,3 +46,37 @@ jobs: - name: Test with pytest run: | pytest -v -ra ./tests/ + + + pip-install: + # A pure Python install, which relies purely on pyproject.toml contents + defaults: + run: + shell: bash {0} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python: ["3.8", "3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + - name: check_env + run: | + which python + python -m pip list + - name: build + run: python -m pip -v install . + + - name: install_reqs + run: pip install pytest + + - name: pytests + run: | + pytest -v -ra ./tests/ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..5663ad7a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,20 @@ +[build-system] +# Minimum requirements for the build system to execute +requires = [ + "cython>=0.28,<3.0", + "setuptools", + "wheel", + # below matches MDA + "numpy==1.20.0; python_version=='3.8' and (platform_machine!='arm64' or platform_system!='Darwin') and platform_python_implementation != 'PyPy'", + "numpy==1.20.0; python_version=='3.9' and (platform_machine!='arm64' or platform_system!='Darwin') and platform_python_implementation != 'PyPy'", + # arm64 on darwin for py3.8+ requires numpy >=1.21.0 + "numpy==1.21.0; python_version=='3.8' and platform_machine=='arm64' and platform_system=='Darwin' and platform_python_implementation != 'PyPy'", + "numpy==1.21.0; python_version=='3.9' and platform_machine=='arm64' and platform_system=='Darwin' and platform_python_implementation != 'PyPy'", + # Scipy: On windows avoid 1.21.6, 1.22.0, and 1.22.1 because they were built on vc142 + "numpy==1.22.3; python_version=='3.10' and platform_system=='Windows' and platform_python_implementation != 'PyPy'", + # As per https://github.com/scipy/oldest-supported-numpy/blob/main/setup.cfg + # safest to build at 1.21.6 for all other platforms + "numpy==1.21.6; python_version=='3.10' and platform_system !='Windows'and platform_python_implementation != 'PyPy'", + "numpy==1.23.2; python_version=='3.11' and platform_python_implementation != 'PyPy'", + "numpy<2.0; python_version>='3.12'", +] \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 4c856d8f..e62a39e9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,4 +4,11 @@ style = pep440 versionfile_source = pytng/_version.py versionfile_build = pytng/_version.py tag_prefix = -parentdir_prefix = pytng- \ No newline at end of file +parentdir_prefix = pytng- + +[options] +setup_requires = + numpy>=1.20.0 + cython>=0.28,<3.0 +install_requires = + numpy>=1.20.0 \ No newline at end of file diff --git a/setup.py b/setup.py index 44547423..cac6c0e3 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,3 @@ -from __future__ import print_function - import os import sys import versioneer @@ -7,13 +5,6 @@ from setuptools import setup, Command, Extension -# Make sure I have the right Python version. -if sys.version_info[:2] < (3, 6): - print('MDAnalysis requires Python 3.6 or better. Python {0:d}.{1:d} detected'.format(* - sys.version_info[:2])) - print('Please upgrade your version of Python.') - sys.exit(-1) - try: import numpy as np except ImportError: @@ -71,7 +62,7 @@ def extensions(): setup( name="pytng", - python_requires=">=3.6", + python_requires=">=3.8", version=versioneer.get_version(), description='Minimal Cython wrapper of the TNG trajectory library', long_description=long_description,