Skip to content

Commit 811e93b

Browse files
authored
Merge pull request #458 from ExaWorks/use_packaging_version
Use packaging.versions insted of distutil.version, since the latter
2 parents 91ad420 + 8ba9db5 commit 811e93b

18 files changed

+48
-55
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ venv*
1818
.venv*
1919
build/
2020
docs/.web-build
21-
web-build/
21+
web-build/
22+
.packages/

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
autodoc_mock_imports = ['flux']
3232
nitpick_ignore = [
3333
('py:class', 'distutils.version.StrictVersion'),
34-
('py:class', 'distutils.version.Version')
34+
('py:class', 'distutils.version.Version'),
35+
('py:class', 'packaging.version.Version')
3536
]
3637

3738
if web_docs:

docs/development/tutorial_add_executor.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ Create a simple BatchSchedulerExecutor subclass that does nothing new in `psijpb
6868

6969
and create a descriptor file to tell PSI/J about this, ``psij-descriptors/pbspro.py``::
7070

71-
from distutils.version import StrictVersion
71+
from packaging.version import Version
7272

7373
from psij._descriptor import _Descriptor
7474

75-
__PSI_J_EXECUTORS__ = [_Descriptor(name='pbspro', version=StrictVersion('0.0.1'),
75+
__PSI_J_EXECUTORS__ = [_Descriptor(name='pbspro', version=Version('0.0.1'),
7676
cls='psijpbs.pbspro.PBSProJobExecutor')]
7777

7878
Now, run the test suite. It should fail with an error reporting that the resource manager specific methods of BatchSchedulerExecutor have not been implemented::

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ psutil~=5.9
33
pystache>=0.6.0
44
typeguard~=2.12
55
typing-compat
6+
packaging~=24.0
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from distutils.version import StrictVersion
2-
1+
from packaging.version import Version
32
from psij.descriptor import Descriptor
43

54
__PSI_J_LAUNCHERS__ = [
6-
Descriptor(name='aprun', version=StrictVersion('0.0.1'),
5+
Descriptor(name='aprun', version=Version('0.0.1'),
76
cls='psij.launchers.aprun.AprunLauncher'),
87
]
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from distutils.version import StrictVersion
2-
1+
from packaging.version import Version
32
from psij.descriptor import Descriptor
43

54

6-
__PSI_J_EXECUTORS__ = [Descriptor(name="cobalt", nice_name='Cobalt', version=StrictVersion("0.0.1"),
5+
__PSI_J_EXECUTORS__ = [Descriptor(name="cobalt", nice_name='Cobalt', version=Version("0.0.1"),
76
cls='psij.executors.batch.cobalt.CobaltJobExecutor')]
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
from distutils.version import StrictVersion
1+
from packaging.version import Version
22
from psij.descriptor import Descriptor
33

44
__PSI_J_EXECUTORS__ = [
5-
Descriptor(name='local', nice_name='Local', version=StrictVersion('0.0.1'),
5+
Descriptor(name='local', nice_name='Local', version=Version('0.0.1'),
66
cls='psij.executors.local.LocalJobExecutor')
77
]
88

99
__PSI_J_LAUNCHERS__ = [
10-
Descriptor(name='single', version=StrictVersion('0.0.1'),
10+
Descriptor(name='single', version=Version('0.0.1'),
1111
cls='psij.launchers.single.SingleLauncher'),
12-
Descriptor(name='multiple', version=StrictVersion('0.0.1'),
12+
Descriptor(name='multiple', version=Version('0.0.1'),
1313
cls='psij.launchers.multiple.MultipleLauncher'),
14-
Descriptor(name='mpirun', version=StrictVersion('0.0.1'),
14+
Descriptor(name='mpirun', version=Version('0.0.1'),
1515
cls='psij.launchers.mpirun.MPILauncher'),
1616
]
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from distutils.version import StrictVersion
2-
1+
from packaging.version import Version
32
from psij.descriptor import Descriptor
43

54

6-
__PSI_J_EXECUTORS__ = [Descriptor(name='flux', nice_name='Flux', version=StrictVersion('0.0.1'),
5+
__PSI_J_EXECUTORS__ = [Descriptor(name='flux', nice_name='Flux', version=Version('0.0.1'),
76
cls='psij.executors.flux.FluxJobExecutor')]
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from distutils.version import StrictVersion
2-
1+
from packaging.version import Version
32
from psij.descriptor import Descriptor
43

54
__PSI_J_LAUNCHERS__ = [
6-
Descriptor(name='jrun', version=StrictVersion('0.0.1'),
5+
Descriptor(name='jrun', version=Version('0.0.1'),
76
cls='psij.launchers.jsrun.JsrunLauncher'),
87
]
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from distutils.version import StrictVersion
2-
1+
from packaging.version import Version
32
from psij.descriptor import Descriptor
43

54

6-
__PSI_J_EXECUTORS__ = [Descriptor(name='lsf', nice_name='LSF', version=StrictVersion('0.0.1'),
5+
__PSI_J_EXECUTORS__ = [Descriptor(name='lsf', nice_name='LSF', version=Version('0.0.1'),
76
cls='psij.executors.batch.lsf.LsfJobExecutor')]
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from distutils.version import StrictVersion
2-
1+
from packaging.version import Version
32
from psij.descriptor import Descriptor
43

54

65
__PSI_J_EXECUTORS__ = [Descriptor(name='pbs', nice_name='PBS Pro', aliases=['pbspro'],
7-
version=StrictVersion('0.0.2'),
6+
version=Version('0.0.2'),
87
cls='psij.executors.batch.pbs.PBSJobExecutor'),
98
Descriptor(name='pbs_classic', nice_name='PBS Classic', aliases=['torque'],
10-
version=StrictVersion('0.0.2'),
9+
version=Version('0.0.2'),
1110
cls='psij.executors.batch.pbs_classic.PBSClassicJobExecutor')]

src/psij-descriptors/rp_descriptor.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from distutils.version import StrictVersion
2-
1+
from packaging.version import Version
32
from psij.descriptor import Descriptor
43

54

65
__PSI_J_EXECUTORS__ = [Descriptor(name='rp', nice_name='Radical Pilot',
7-
version=StrictVersion('0.0.1'),
6+
version=Version('0.0.1'),
87
cls='psij.executors.rp.RPJobExecutor')]
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from distutils.version import StrictVersion
2-
1+
from packaging.version import Version
32
from psij.descriptor import Descriptor
43

54

6-
__PSI_J_EXECUTORS__ = [Descriptor(name='slurm', nice_name='Slurm', version=StrictVersion('0.0.1'),
5+
__PSI_J_EXECUTORS__ = [Descriptor(name='slurm', nice_name='Slurm', version=Version('0.0.1'),
76
cls='psij.executors.batch.slurm.SlurmJobExecutor')]
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from distutils.version import StrictVersion
2-
1+
from packaging.version import Version
32
from psij.descriptor import Descriptor
43

54
__PSI_J_LAUNCHERS__ = [
6-
Descriptor(name='srun', version=StrictVersion('0.0.1'),
5+
Descriptor(name='srun', version=Version('0.0.1'),
76
cls='psij.launchers.srun.SrunLauncher'),
87
]

src/psij/_plugins.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import importlib
22
import logging
33
from bisect import bisect_left
4-
from distutils.versionpredicate import VersionPredicate
4+
from packaging.specifiers import SpecifierSet
55
from types import ModuleType
66
from typing import Tuple, Dict, List, Union, Type, Any, Optional, TypeVar
77

@@ -116,9 +116,9 @@ def _get_plugin_class(name: str, version_constraint: Optional[str], type: str,
116116
versions = store[name]
117117
selected = None
118118
if version_constraint:
119-
pred = VersionPredicate('x(' + version_constraint + ')')
119+
pred = SpecifierSet(version_constraint)
120120
for entry in reversed(versions):
121-
if pred.satisfied_by(entry.version):
121+
if entry.version in pred:
122122
selected = entry
123123
else:
124124
selected = versions[-1]

src/psij/descriptor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Executor/Launcher descriptor module."""
22

3-
from distutils.version import StrictVersion
3+
from packaging.version import Version
44
from typing import TypeVar, Generic, Optional, Type, List
55

66
T = TypeVar('T')
@@ -68,17 +68,17 @@ class Descriptor(object):
6868
6969
.. code-block:: python
7070
71-
from distutils.version import StrictVersion
71+
from packaging.version import Version
7272
from psij.descriptor import Descriptor
7373
7474
__PSI_J_EXECUTORS__ = [
75-
Descriptor(name=<name>, version=StrictVersion(<version_str>),
75+
Descriptor(name=<name>, version=Version(<version_str>),
7676
cls=<fqn_str>),
7777
...
7878
]
7979
8080
__PSI_J_LAUNCHERS__ = [
81-
Descriptor(name=<name>, version=StrictVersion(<version_str>),
81+
Descriptor(name=<name>, version=Version(<version_str>),
8282
cls=<fqn_str>),
8383
...
8484
]
@@ -89,7 +89,7 @@ class name that implements the executor or launcher such as
8989
`psij.executors.local.LocalJobExecutor`.
9090
"""
9191

92-
def __init__(self, name: str, version: StrictVersion, cls: str,
92+
def __init__(self, name: str, version: Version, cls: str,
9393
aliases: Optional[List[str]] = None, nice_name: Optional[str] = None) -> None:
9494
"""
9595
Parameters
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
from distutils.version import StrictVersion
1+
from packaging.version import Version
22
from psij.descriptor import Descriptor
33

44
__PSI_J_EXECUTORS__ = [
55
# executor in the same path as descriptor; should load
6-
Descriptor(name='p1-tp1', version=StrictVersion('0.0.1'),
6+
Descriptor(name='p1-tp1', version=Version('0.0.1'),
77
cls='_test_plugins1.ex1._Executor1'),
88
# executor in different path, but sharing module; should NOT load
9-
Descriptor(name='p2-tp1', version=StrictVersion('0.0.1'),
9+
Descriptor(name='p2-tp1', version=Version('0.0.1'),
1010
cls='_test_plugins1.ex2._Executor2'),
1111
# executor in different path with no shared module; should NOT load
12-
Descriptor(name='p2-tp3', version=StrictVersion('0.0.1'),
12+
Descriptor(name='p2-tp3', version=Version('0.0.1'),
1313
cls='_test_plugins3.ex3._Executor3'),
1414
# noop executor that should have no reason to not load
15-
Descriptor(name='_always_loads', version=StrictVersion('0.0.1'),
15+
Descriptor(name='_always_loads', version=Version('0.0.1'),
1616
cls='_test_plugins1._always_loads_executor.AlwaysLoadsExecutor'),
1717
# noop executor with an import of a package that does not exist
18-
Descriptor(name='_never_loads', version=StrictVersion('0.0.1'),
18+
Descriptor(name='_never_loads', version=Version('0.0.1'),
1919
cls='_test_plugins1._never_loads_executor.NeverLoadsExecutor'),
2020
# an executor that exercises some of the batch test stuff
21-
Descriptor(name='batch-test', version=StrictVersion('0.0.1'),
21+
Descriptor(name='batch-test', version=Version('0.0.1'),
2222
cls='_batch_test._batch_test._TestJobExecutor')
2323

2424
]
2525

2626
__PSI_J_LAUNCHERS__ = [
27-
Descriptor(name='batch-test', version=StrictVersion('0.0.1'),
27+
Descriptor(name='batch-test', version=Version('0.0.1'),
2828
cls='_batch_test._batch_test._TestLauncher')
2929
]

tests/test_executor_versions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
# This is meant as a simple test file to check if psi/j was installed successfully
44

5-
from distutils.version import Version
6-
5+
from packaging.version import Version
76
from psij import JobExecutor
87

98

0 commit comments

Comments
 (0)