Skip to content

Commit

Permalink
BREAKING CHANGE: drop support for python 3.7 (#2436)
Browse files Browse the repository at this point in the history
Python 3.7 will be end-of-life on the 27th of June 2023 and the next release of
RDFLib will be a new major version.

This changes the minimum supported version of Python to 3.8.1 as some of the
dependencies we use are not too fond of python 3.8.0. This change also removes
all accommodations for older python versions.
  • Loading branch information
aucampia committed Jun 13, 2023
1 parent d21a451 commit 1e5f56b
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 115 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/validate.yaml
Expand Up @@ -25,40 +25,37 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest, macos-latest, windows-latest]
# This is used for injecting additional tests for a specific python
# version and OS.
suffix: [""]
include:
- python-version: "3.7"
- python-version: "3.8"
os: ubuntu-latest
extensive-tests: true
TOXENV_SUFFIX: "-docs"
- python-version: "3.7"
- python-version: "3.8"
os: ubuntu-latest
extensive-tests: true
suffix: "-min"
TOXENV_SUFFIX: "-min"
- python-version: "3.8"
- python-version: "3.9"
os: ubuntu-latest
TOX_EXTRA_COMMAND: "- isort --check-only --diff ."
TOXENV_SUFFIX: "-docs"
- python-version: "3.9"
- python-version: "3.10"
os: ubuntu-latest
TOX_EXTRA_COMMAND: "- black --check --diff ./rdflib"
TOXENV_SUFFIX: "-lxml"
- python-version: "3.10"
- python-version: "3.11"
os: ubuntu-latest
TOX_EXTRA_COMMAND: "flake8 --exit-zero rdflib"
TOXENV_SUFFIX: "-docs"
PREPARATION: "sudo apt-get install -y firejail"
extensive-tests: true
TOX_TEST_HARNESS: "firejail --net=none --"
TOX_PYTEST_EXTRA_ARGS: "-m 'not webtest'"
- python-version: "3.11"
os: ubuntu-latest
TOXENV_SUFFIX: "-docs"
steps:
- uses: actions/checkout@v3
- name: Cache XDG_CACHE_HOME
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -43,7 +43,7 @@ Help with maintenance of all of the RDFLib family of packages is always welcome

## Versions & Releases

* `7.0.0a0` current `main` branch
* `7.0.0a0` current `main` branch and supports Python 3.8.1+ only.
* `6.x.y` current release and support Python 3.7+ only. Many improvements over 5.0.0
* see [Releases](https://github.com/RDFLib/rdflib/releases)
* `5.x.y` supports Python 2.7 and 3.4+ and is [mostly backwards compatible with 4.2.2](https://rdflib.readthedocs.io/en/stable/upgrade4to5.html).
Expand Down
5 changes: 1 addition & 4 deletions docs/conf.py
Expand Up @@ -256,7 +256,7 @@ def find_version(filename):

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"python": ("https://docs.python.org/3.7", None),
"python": ("https://docs.python.org/3.8", None),
}

html_experimental_html5_writer = True
Expand Down Expand Up @@ -331,9 +331,6 @@ def find_version(filename):
]
)

if sys.version_info < (3, 8):
nitpick_ignore.extend([("py:class", "importlib_metadata.EntryPoint")])


def autodoc_skip_member_handler(
app: sphinx.application.Sphinx,
Expand Down
2 changes: 2 additions & 0 deletions docs/developers.rst
Expand Up @@ -437,6 +437,8 @@ flag them as expecting to fail.
Compatibility
-------------

RDFlib 7.0.0 release and later only support Python 3.8.1 and newer.

RDFlib 6.0.0 release and later only support Python 3.7 and newer.

RDFLib 5.0.0 maintained compatibility with Python versions 2.7, 3.4, 3.5, 3.6, 3.7.
Expand Down
2 changes: 1 addition & 1 deletion docs/gettingstarted.rst
Expand Up @@ -51,7 +51,7 @@ methods that search triples and return them in arbitrary order.

RDFLib graphs also redefine certain built-in Python methods in order
to behave in a predictable way. They do this by `emulating container types
<https://docs.python.org/3.7/reference/datamodel.html#emulating-container-types>`_ and
<https://docs.python.org/3.8/reference/datamodel.html#emulating-container-types>`_ and
are best thought of as a set of 3-item tuples ("triples", in RDF-speak):

.. code-block:: text
Expand Down
5 changes: 5 additions & 0 deletions docs/upgrade6to7.rst
Expand Up @@ -4,6 +4,11 @@
Upgrading 6 to 7
============================================

Python version
----------------------------------------------------

RDFLib 7 requires Python 3.8.1 or later.

New behaviour for ``publicID`` in ``parse`` methods.
----------------------------------------------------

Expand Down
9 changes: 1 addition & 8 deletions examples/secure_with_audit.py
Expand Up @@ -61,15 +61,8 @@ def main() -> None:
),
)

if sys.version_info < (3, 8):
logging.warn("This example requires Python 3.8 or higher")
return None

# Install the audit hook
#
# note on type error: This is needed because we are running mypy with python
# 3.7 mode, so mypy thinks the previous condition will always be true.
sys.addaudithook(audit_hook) # type: ignore[unreachable]
sys.addaudithook(audit_hook)

graph = Graph()

Expand Down
50 changes: 2 additions & 48 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions pyproject.toml
Expand Up @@ -11,7 +11,6 @@ license = "BSD-3-Clause"
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down Expand Up @@ -39,10 +38,9 @@ rdfs2dot = 'rdflib.tools.rdfs2dot:main'
rdfgraphisomorphism = 'rdflib.tools.graphisomorphism:main'

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.8.1"
isodate = "^0.6.0"
pyparsing = ">=2.1.0,<4"
importlib-metadata = {version = ">=4,<7", python = ">=3.7,<3.8"}
berkeleydb = {version = "^18.1.0", optional = true}
networkx = {version = "^2.0.0", optional = true}
html5lib = {version = "^1.0", optional = true}
Expand All @@ -69,9 +67,9 @@ sphinx-autodoc-typehints = "^1.17.1"
typing-extensions = "^4.5.0"

[tool.poetry.group.flake8.dependencies]
flake8 = {version = ">=4.0.1", python = ">=3.8"} # flakeheaven is incompatible with flake8 >=5.0 (https://github.com/flakeheaven/flakeheaven/issues/132)
flakeheaven = {version = "^3.2.1", python = ">=3.8"}
pep8-naming = {version = "^0.13.2", python = ">=3.8"}
flake8 = {version = ">=4.0.1"} # flakeheaven is incompatible with flake8 >=5.0 (https://github.com/flakeheaven/flakeheaven/issues/132)
flakeheaven = {version = "^3.2.1"}
pep8-naming = {version = "^0.13.2"}

[tool.poetry.extras]
berkeleydb = ["berkeleydb"]
Expand Down Expand Up @@ -204,7 +202,7 @@ skip = [

[tool.mypy]
files = ['rdflib', 'test', 'devtools', 'examples']
python_version = "3.7"
python_version = "3.8"
warn_unused_configs = true
ignore_missing_imports = true
disallow_subclassing_any = false
Expand Down
7 changes: 1 addition & 6 deletions rdflib/__init__.py
Expand Up @@ -44,12 +44,7 @@
"""
import logging
import sys

if sys.version_info < (3, 8):
# importlib is only available in Python 3.8+; for 3.7 we must do this:
import importlib_metadata as metadata
else:
from importlib import metadata
from importlib import metadata

_DISTRIBUTION_METADATA = metadata.metadata("rdflib")

Expand Down
7 changes: 1 addition & 6 deletions rdflib/_type_checking.py
Expand Up @@ -14,18 +14,13 @@
and this module is not part the the RDFLib public API.
"""

import sys

__all__ = [
"_NamespaceSetString",
"_MulPathMod",
]


if sys.version_info >= (3, 8):
from typing import Literal as PyLiteral
else:
from typing_extensions import Literal as PyLiteral
from typing import Literal as PyLiteral

_NamespaceSetString = PyLiteral["core", "rdflib", "none"]
_MulPathMod = PyLiteral["*", "+", "?"] # noqa: F722
7 changes: 1 addition & 6 deletions rdflib/plugin.py
Expand Up @@ -25,7 +25,7 @@
"""

import sys
from importlib.metadata import EntryPoint, entry_points
from typing import (
TYPE_CHECKING,
Any,
Expand All @@ -52,11 +52,6 @@
from rdflib.serializer import Serializer
from rdflib.store import Store

if sys.version_info < (3, 8):
from importlib_metadata import EntryPoint, entry_points
else:
from importlib.metadata import EntryPoint, entry_points

__all__ = [
"register",
"get",
Expand Down
6 changes: 1 addition & 5 deletions rdflib/plugins/sparql/__init__.py
Expand Up @@ -4,7 +4,7 @@
.. versionadded:: 4.0
"""

import sys
from importlib.metadata import entry_points
from typing import TYPE_CHECKING

SPARQL_LOAD_GRAPHS = True
Expand Down Expand Up @@ -40,10 +40,6 @@
assert operators
assert parserutils

if sys.version_info < (3, 8):
from importlib_metadata import entry_points
else:
from importlib.metadata import entry_points

all_entry_points = entry_points()
if hasattr(all_entry_points, "select"):
Expand Down
11 changes: 4 additions & 7 deletions test/conftest.py
Expand Up @@ -85,13 +85,10 @@ def function_httpmocks(


@pytest.fixture(scope="session", autouse=True)
def audit_hook_dispatcher() -> Generator[Optional[AuditHookDispatcher], None, None]:
if sys.version_info >= (3, 8):
dispatcher = AuditHookDispatcher()
sys.addaudithook(dispatcher.audit)
yield dispatcher
else:
yield None
def audit_hook_dispatcher() -> Generator[AuditHookDispatcher, None, None]:
dispatcher = AuditHookDispatcher()
sys.addaudithook(dispatcher.audit)
yield dispatcher


@pytest.fixture(scope="function")
Expand Down

0 comments on commit 1e5f56b

Please sign in to comment.