From 5e91db623ca94114c3cd600f914e4b6184556118 Mon Sep 17 00:00:00 2001 From: Aditya Vaidya <648148+kroq-gar78@users.noreply.github.com> Date: Sun, 1 Sep 2024 13:58:18 -0500 Subject: [PATCH] MNT Remove dependency on distutils (#553) * Fix obsolete numpy directory in setup * Remove setuptools version requirement * distutils.version.LooseVersion --> looseversion.LooseVersion * MNT run tests on python 3.12 * MNT let's test wheels on all python versions too * Install setuptools to build wheel --------- Co-authored-by: Aditya Vaidya Co-authored-by: Matteo Visconti di Oleggio Castello --- .github/workflows/install_from_wheel.yml | 4 ++-- .github/workflows/run_tests.yml | 4 ++-- cortex/svgoverlay.py | 2 +- cortex/utils.py | 2 +- pyproject.toml | 2 +- requirements.txt | 1 + setup.py | 10 +++++----- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/install_from_wheel.yml b/.github/workflows/install_from_wheel.yml index 7753caea..977f5045 100644 --- a/.github/workflows/install_from_wheel.yml +++ b/.github/workflows/install_from_wheel.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9] + python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"] max-parallel: 5 steps: @@ -35,7 +35,7 @@ jobs: sudo apt-get update sudo apt-get install -y inkscape pip install --upgrade pip - pip install build wheel numpy "cython<3.0" + pip install setuptools build wheel numpy "cython<3.0" - name: Create the wheel run: python setup.py bdist_wheel diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index e70ca67d..6c82b89d 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9, "3.10", "3.11"] + python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"] max-parallel: 5 steps: @@ -52,4 +52,4 @@ jobs: env_vars: OS,PYTHON fail_ci_if_error: true token: ${{ secrets.CODECOV_TOKEN }} - verbose: false \ No newline at end of file + verbose: false diff --git a/cortex/svgoverlay.py b/cortex/svgoverlay.py index 7dad915c..01ee4d6a 100644 --- a/cortex/svgoverlay.py +++ b/cortex/svgoverlay.py @@ -11,7 +11,7 @@ from scipy.spatial import cKDTree from builtins import zip, str -from distutils.version import LooseVersion +from looseversion import LooseVersion from lxml import etree from lxml.builder import E diff --git a/cortex/utils.py b/cortex/utils.py index 63c3c20b..887755c0 100644 --- a/cortex/utils.py +++ b/cortex/utils.py @@ -9,7 +9,7 @@ import tempfile import urllib.request import warnings -from distutils.version import LooseVersion +from looseversion import LooseVersion from importlib import import_module import h5py diff --git a/pyproject.toml b/pyproject.toml index ddda6017..fe641d85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [build-system] # Minimum requirements for the build system to execute, according to PEP518 # specification. -requires = ["setuptools<60.0", "build", "numpy", "cython<3.0", "wheel"] +requires = ["setuptools", "build", "numpy", "cython<3.0", "wheel"] build-backend = "setuptools.build_meta" [tool.codespell] diff --git a/requirements.txt b/requirements.txt index b30db96c..1094dd79 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,3 +14,4 @@ pillow nibabel>=2.1 networkx>=2.1 imageio +looseversion diff --git a/setup.py b/setup.py index 77bee040..ad2a9211 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ import os from glob import glob -from numpy.distutils.misc_util import get_numpy_include_dirs +import numpy try: import configparser @@ -78,10 +78,10 @@ def get_version(): 'OpenCTM-1.0.3/lib/liblzma/LzFind.c', 'OpenCTM-1.0.3/lib/liblzma/LzmaDec.c', 'OpenCTM-1.0.3/lib/liblzma/LzmaEnc.c', - 'OpenCTM-1.0.3/lib/liblzma/LzmaLib.c',], + 'OpenCTM-1.0.3/lib/liblzma/LzmaLib.c',], libraries=['m'], include_dirs=[ - 'OpenCTM-1.0.3/lib/', - 'OpenCTM-1.0.3/lib/liblzma/'] + get_numpy_include_dirs(), + 'OpenCTM-1.0.3/lib/', + 'OpenCTM-1.0.3/lib/liblzma/', numpy.get_include()], define_macros=[ ('LZMA_PREFIX_CTM', None), ('OPENCTM_BUILD', None), @@ -89,7 +89,7 @@ def get_version(): ] ) formats = Extension('cortex.formats', ['cortex/formats.pyx'], - include_dirs=get_numpy_include_dirs()) + include_dirs=[numpy.get_include()]) DISTNAME = 'pycortex' # VERSION needs to be modified under cortex/version.py