Skip to content

Commit

Permalink
Migrate from distutils to packaging
Browse files Browse the repository at this point in the history
The distutils package has been deprecated in Python 3.10 and will go
away in Python 3.12. Remove an unsightly deprecation warning by
migrating away from distutils now. Switch from
distutils.version.LooseVersion to packaging.version.Version. No other
code changes appear to be necessary.

Include a unit test to verify that pySHACL imports without raising any
warnings.
  • Loading branch information
tcmitchell committed Jun 22, 2022
1 parent 3d67789 commit 14e9738
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Expand Up @@ -57,6 +57,7 @@ python = "^3.7.0" # Compatible python versions must be declared here
rdflib = ">=6.1.1,<8"
owlrl = ">=6.0.2,<7"
prettytable = "^2.2.1"
packaging = ">=21.3"
rdflib-jsonld = { version=">=0.4.0,<0.6", optional=true}
pyduktape2 = {version="^0.4.1", optional=true}
flake8 = {version="^3.8.0", optional=true}
Expand Down
12 changes: 6 additions & 6 deletions pyshacl/monkey/__init__.py
@@ -1,17 +1,17 @@
# -*- coding: utf-8 -*-

from distutils.version import LooseVersion
from packaging.version import Version

import rdflib

from rdflib import plugin, store


RDFLIB_VERSION = LooseVersion(rdflib.__version__)
RDFLIB_421 = LooseVersion("4.2.1")
RDFLIB_500 = LooseVersion("5.0.0")
RDFLIB_600 = LooseVersion("6.0.0")
RDFLIB_602 = LooseVersion("6.0.2")
RDFLIB_VERSION = Version(rdflib.__version__)
RDFLIB_421 = Version("4.2.1")
RDFLIB_500 = Version("5.0.0")
RDFLIB_600 = Version("6.0.0")
RDFLIB_602 = Version("6.0.2")


def rdflib_bool_patch():
Expand Down
21 changes: 21 additions & 0 deletions test/issues/test_146.py
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
"""
https://github.com/RDFLib/pySHACL/issues/146
"""

import warnings


def test_146() -> None:
# Ensure that importing pyshacl triggers no warnings.
with warnings.catch_warnings(record=True) as warning_context:
# Cause all warnings to always be triggered.
warnings.simplefilter("always")
# Import pyshacl, which should not trigger any warnings
import pyshacl
# Verify some things
assert len(warning_context) == 0


if __name__ == "__main__":
test_146()

0 comments on commit 14e9738

Please sign in to comment.