diff --git a/.gitignore b/.gitignore index 0f89d67b6..44bdd6f67 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ build/ **/Random123 settings.json *.so +randomgen/_version.py randomgen/bounded_integers.pyx randomgen/bounded_integers.pxd randomgen/*.c diff --git a/README.md b/README.md index 939aabce0..9139bc62d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This package contains additional bit generators for NumPy's [![Build Status](https://dev.azure.com/kevinksheppard0207/kevinksheppard/_apis/build/status/bashtage.randomgen?branchName=main)](https://dev.azure.com/kevinksheppard0207/kevinksheppard/_build/latest?definitionId=2&branchName=main) [![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/46r9xsmuwi8bxsbj/branch/main?svg=true)](https://ci.appveyor.com/project/bashtage/randomgen/branch/main) [![Build Status](https://cloud.drone.io/api/badges/bashtage/randomgen/status.svg)](https://cloud.drone.io/bashtage/randomgen) -[![FreeBSD Status on Cirrus](https://api.cirrus-ci.com/github/bashtage/randomgen.svg)](https://cirrus-ci.com/github/bashtage/randomgen) +[![FreeBSD Status on Cirrus](https://api.cirrus-ci.com/github/bashtage/randomgen.svg?branch=main)](https://cirrus-ci.com/github/bashtage/randomgen) **Coverage** diff --git a/pyproject.toml b/pyproject.toml index 746b48084..030afccc0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "packaging>=21.0; platform_machine=='arm64'", + "packaging>=21.0", "setuptools", "wheel", "Cython>=0.29.24,<3.0", diff --git a/randomgen/examples/cython/setup.py b/randomgen/examples/cython/setup.py index de2b1cfd1..02fa6e9bc 100644 --- a/randomgen/examples/cython/setup.py +++ b/randomgen/examples/cython/setup.py @@ -1,7 +1,7 @@ # python setup.py build_ext -i +from setuptools import setup from setuptools.extension import Extension -from distutils.core import setup from os.path import join from Cython.Build import cythonize diff --git a/randomgen/tests/test_against_numpy.py b/randomgen/tests/test_against_numpy.py index b3ba37699..775ce6aca 100644 --- a/randomgen/tests/test_against_numpy.py +++ b/randomgen/tests/test_against_numpy.py @@ -1,5 +1,3 @@ -from distutils.version import LooseVersion - import numpy as np import numpy.random from numpy.testing import ( @@ -8,6 +6,7 @@ assert_equal, suppress_warnings, ) +from packaging.version import parse import pytest import randomgen @@ -15,8 +14,8 @@ import randomgen.generator from randomgen.mtrand import RandomState -NP_VERSION = LooseVersion(np.__version__) -NP_118 = LooseVersion("1.18") <= NP_VERSION < LooseVersion("1.19") +NP_VERSION = parse(np.__version__) +NP_118 = parse("1.18") <= NP_VERSION < parse("1.19") def compare_0_input(f1, f2): diff --git a/randomgen/tests/test_bit_generators_against_numpy.py b/randomgen/tests/test_bit_generators_against_numpy.py index 025700975..1405d1229 100644 --- a/randomgen/tests/test_bit_generators_against_numpy.py +++ b/randomgen/tests/test_bit_generators_against_numpy.py @@ -1,12 +1,11 @@ -from distutils.version import LooseVersion - import numpy as np +from packaging.version import parse import pytest import randomgen from randomgen import PCG64, SFC64, Philox, SeedSequence -NP_LT_119 = LooseVersion(np.__version__) < LooseVersion("1.19.0") +NP_LT_119 = parse(np.__version__) < parse("1.19.0") pytestmark = pytest.mark.skipif(NP_LT_119, reason="Only test Numpy 1.19+") diff --git a/randomgen/tests/test_extended_generator.py b/randomgen/tests/test_extended_generator.py index a8d66f068..0dbf19a7c 100644 --- a/randomgen/tests/test_extended_generator.py +++ b/randomgen/tests/test_extended_generator.py @@ -1,5 +1,4 @@ import copy -from distutils.version import LooseVersion import pickle import numpy as np @@ -13,6 +12,7 @@ assert_warns, suppress_warnings, ) +from packaging.version import parse import pytest from randomgen import MT19937, PCG64, ExtendedGenerator @@ -57,7 +57,7 @@ def extended_gen_legacy(): _mt19937 = MT19937(SEED, mode="legacy") random = ExtendedGenerator(_mt19937) -NP_LT_118 = LooseVersion(np.__version__) < LooseVersion("1.18.0") +NP_LT_118 = parse(np.__version__) < parse("1.18.0") @pytest.mark.skipif(NP_LT_118, reason="Can only test with NumPy >= 1.18") diff --git a/randomgen/tests/test_generator_117.py b/randomgen/tests/test_generator_117.py index b35928933..234d493f1 100644 --- a/randomgen/tests/test_generator_117.py +++ b/randomgen/tests/test_generator_117.py @@ -1,9 +1,9 @@ -from distutils.version import LooseVersion from itertools import product from typing import cast import numpy as np from numpy.testing import assert_allclose, assert_array_equal +from packaging.version import parse import pytest from randomgen import Generator @@ -20,10 +20,10 @@ from randomgen import PCG64 # type: ignore[misc] -NP_LT_1174 = LooseVersion(np.__version__) < LooseVersion("1.17.4") -NP_GTE_118 = LooseVersion(np.__version__) >= LooseVersion("1.18") -NP_GTE_120 = LooseVersion(np.__version__) >= LooseVersion("1.20") -NP_GTE_121 = LooseVersion(np.__version__) >= LooseVersion("1.21") +NP_LT_1174 = parse(np.__version__) < parse("1.17.4") +NP_GTE_118 = parse(np.__version__) >= parse("1.18") +NP_GTE_120 = parse(np.__version__) >= parse("1.20") +NP_GTE_121 = parse(np.__version__) >= parse("1.21") pytestmark = pytest.mark.skipif(NP_LT_1174, reason="Only test 1.17.4+") diff --git a/randomgen/tests/test_generator_mt19937.py b/randomgen/tests/test_generator_mt19937.py index 99a1aab59..1d919f535 100644 --- a/randomgen/tests/test_generator_mt19937.py +++ b/randomgen/tests/test_generator_mt19937.py @@ -1,4 +1,3 @@ -from distutils.version import LooseVersion import hashlib import sys import warnings @@ -16,6 +15,7 @@ assert_warns, suppress_warnings, ) +from packaging.version import parse import pytest from randomgen import MT19937, Generator @@ -23,7 +23,7 @@ random = Generator(MT19937(mode="legacy")) -NP_LT_118 = LooseVersion(np.__version__) < LooseVersion("1.18.0") +NP_LT_118 = parse(np.__version__) < parse("1.18.0") JUMP_TEST_DATA = { ("_jump_tester", (0,), 10): { diff --git a/randomgen/tests/test_recent_numpy_changes.py b/randomgen/tests/test_recent_numpy_changes.py index 38d1448da..01a30c733 100644 --- a/randomgen/tests/test_recent_numpy_changes.py +++ b/randomgen/tests/test_recent_numpy_changes.py @@ -1,14 +1,14 @@ -from distutils.version import LooseVersion from typing import cast import numpy as np from numpy.testing import assert_equal +from packaging.version import parse import pytest from randomgen import Generator -v119 = LooseVersion("1.19") -NP_LT_119 = LooseVersion(np.__version__) < v119 +v119 = parse("1.19") +NP_LT_119 = parse(np.__version__) < v119 pytestmark = pytest.mark.skipif(NP_LT_119, reason="Only test NumPy 1.19+") diff --git a/requirements-dev.txt b/requirements-dev.txt index e4c0f0256..d36ca8b22 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,3 +4,4 @@ pytest-cov scipy>=1.3.2 setuptools_scm[toml]>=6.4.2,<7.0.0 oldest_supported_numpy +packaging>=21.0 \ No newline at end of file