Skip to content

Commit

Permalink
Modernize python package version specifiers (espressomd#4709)
Browse files Browse the repository at this point in the history
Description of changes:
- fix import errors in several tests, tutorials and benchmarks due to API changes in setuptools >= 67.3.0
  • Loading branch information
kodiakhq[bot] authored Apr 18, 2023
2 parents 97d06af + 111283a commit d22c24b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions doc/tutorials/constant_pH/constant_pH.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@
"plt.rcParams.update({'font.size': 18})\n",
"\n",
"import numpy as np\n",
"import setuptools\n",
"import pkg_resources\n",
"import pint # module for working with units and dimensions\n",
"import time\n",
"assert setuptools.version.pkg_resources.packaging.specifiers.SpecifierSet('>=0.10.1').contains(pint.__version__), \\\n",
"assert pkg_resources.packaging.specifiers.SpecifierSet('>=0.10.1').contains(pint.__version__), \\\n",
" f'pint version {pint.__version__} is too old: several numpy operations can cast away the unit'\n",
"\n",
"import espressomd\n",
Expand Down
4 changes: 2 additions & 2 deletions maintainer/benchmarks/mc_acid_base_reservoir.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import espressomd
import espressomd.electrostatics
import espressomd.reaction_methods
import setuptools
import pkg_resources
import argparse

parser = argparse.ArgumentParser(description="Benchmark MC simulations in the grand-reaction ensemble. "
Expand All @@ -45,7 +45,7 @@
# process and check arguments
assert args.particles_per_core >= 100, "you need to use at least 100 particles per core to avoid finite-size effects in the simulation"
espressomd.assert_features(['WCA', 'ELECTROSTATICS'])
assert setuptools.version.pkg_resources.packaging.specifiers.SpecifierSet('>=0.10.1').contains(pint.__version__), \
assert pkg_resources.packaging.specifiers.SpecifierSet('>=0.10.1').contains(pint.__version__), \
f'pint version {pint.__version__} is too old: several numpy operations can cast away the unit'


Expand Down
4 changes: 2 additions & 2 deletions testsuite/python/unittest_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import sys
import importlib
import setuptools
import pkg_resources
import unittest

import espressomd
Expand Down Expand Up @@ -74,7 +74,7 @@ def skipIfUnmetModuleVersionRequirement(module, version_requirement):
_module = importlib.import_module(module)
except ImportError:
return skipIfMissingModules(module)
if not setuptools.version.pkg_resources.packaging.specifiers.SpecifierSet(
if not pkg_resources.packaging.specifiers.SpecifierSet(
version_requirement).contains(_module.__version__):
return unittest.skip(
"Skipping test: version requirement not met for module {}".format(module))
Expand Down

0 comments on commit d22c24b

Please sign in to comment.