Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move to poetry for dependency management; consolidate more settings into pyproject.toml #2187

Merged
merged 29 commits into from Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c8e1f2e
first draft of moving to poetry for dependency management
jclerman Dec 29, 2022
debd140
update to get docs and flake8 tox environments running.
jclerman Dec 30, 2022
bd1d4c7
make html5lib an optional dependency, configured for installation as …
jclerman Dec 30, 2022
5609c41
preserving all previous extras, doing away with poetry dep-groups for…
jclerman Dec 30, 2022
5fd8da2
type-annotation to reassure mypy that __version__ is expected to be a…
jclerman Dec 30, 2022
df3a293
remove "flake8" from list of extras; use "dev" instead. also use last…
jclerman Dec 30, 2022
7f04648
install devcontainer development dependencies from pyproject.toml, in…
jclerman Dec 31, 2022
a4d9d57
update Taskfile to use pyproject.toml & poetry to determine/install d…
jclerman Dec 31, 2022
39184f5
move coverage config to pyproject.toml; update tox.ini to accommodate
jclerman Dec 31, 2022
d6a97ca
remove newline from package description to mollify poetry
jclerman Jan 2, 2023
16e61a4
Merge branch 'main' into switch-to-poetry
jclerman Jan 3, 2023
46e30c2
poetry related changes:
aucampia Jan 2, 2023
6aa9d6d
Merge pull request #1 from aucampia/switch-to-poetry
jclerman Jan 4, 2023
c873a53
removing now-obsolete packaging files
jclerman Jan 4, 2023
7341453
updating library-development-related docs to reflect use of poetry
jclerman Jan 4, 2023
fe43722
Move dev dependencies from extras into poetry dep groups
aucampia Jan 8, 2023
fa1cc18
chown mounted container volumes
edmondchuc Jan 11, 2023
8c113cd
Revert "chown mounted container volumes"
edmondchuc Jan 11, 2023
9539db6
Merge pull request #2 from aucampia/switch-to-poetry
jclerman Jan 11, 2023
95021f6
test: minimum versions
aucampia Jan 12, 2023
c154844
Merge pull request #4 from aucampia/switch-to-poetry
jclerman Jan 13, 2023
ead5864
Add chown for container volumes
edmondchuc Jan 11, 2023
76d82c7
Revert "Add chown for container volumes"
edmondchuc Jan 12, 2023
be4bba6
Add separate docker-compose for devcontainer. Add postCreateCommand t…
edmondchuc Jan 12, 2023
1832327
Use one docker-compose.yml with a new 'run' service to run one-off co…
edmondchuc Jan 12, 2023
2cee383
change local state directories
aucampia Jan 15, 2023
20e4b17
Merge pull request #5 from aucampia/switch-to-poetry
jclerman Jan 16, 2023
0a5db59
bump versions
aucampia Jan 16, 2023
807ad03
build: fix comment
aucampia Jan 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 14 additions & 9 deletions Dockerfile.devcontainer
Expand Up @@ -41,17 +41,22 @@ RUN \

RUN sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin

COPY requirements*.txt /var/tmp/
COPY docs/sphinx-requirements.txt /var/tmp/docs/sphinx-requirements.txt

RUN \
cd /var/tmp/ && \
grep -H . requirements*.txt docs/sphinx-requirements.txt && \
python -m pip install --upgrade \
-r requirements.txt \
-r requirements.dev.txt \
-r requirements.dev-extra.txt \
-r docs/sphinx-requirements.txt \
tox \
poetry==1.3.1 \
&& \
true

COPY pyproject.toml poetry.lock ./

RUN poetry export \
-E dev \
-E tests \
-E docs \
--output /var/tmp/requirements-via-poetry-including-all-dev.txt
RUN \
python -m pip install \
-r /var/tmp/requirements-via-poetry-including-all-dev.txt \
&& \
true
aucampia marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 4 additions & 2 deletions Taskfile.yml
Expand Up @@ -66,12 +66,14 @@ tasks:
install:pip-deps:
desc: Install pip dependencies
cmds:
- "{{._PYTHON | shellQuote}} -m pip install --upgrade -r requirements.txt -r requirements.dev.txt -r docs/sphinx-requirements.txt {{if (mustFromJson .INSTALL_PIP_EXTRAS)}}-r requirements.dev-extra.txt{{end}}"
- "poetry export -E dev -E tests -E docs {{if (mustFromJson .INSTALL_PIP_EXTRAS)}}-E berkeleydb -E networkx{{end}} --output /var/tmp/requirements-via-poetry-incl-dev.txt"
- "{{._PYTHON | shellQuote}} -m pip install --upgrade -r /var/tmp/requirements-via-poetry-incl-dev.txt"

install:flake8:
desc: Install flake8 dependencies
cmds:
- "{{._PYTHON | shellQuote}} -m pip install --upgrade -r requirements.flake8.txt"
- poetry export --only flake8 --output /var/tmp/requirements.flake8.txt
- "{{._PYTHON | shellQuote}} -m pip install --upgrade -r /var/tmp/requirements.flake8.txt"

install:deps:
desc: Install all dependencies
Expand Down
6 changes: 5 additions & 1 deletion docs/conf.py
Expand Up @@ -15,6 +15,8 @@
import re
import sys

import rdflib

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand Down Expand Up @@ -82,6 +84,8 @@

# Find version. We have to do this because we can't import it in Python 3 until
# its been automatically converted in the setup process.
# UPDATE: This function is no longer used; once builds are confirmed to succeed, it
# can/should be removed. --JCL 2022-12-30
def find_version(filename):
_version_re = re.compile(r'__version__ = "(.*)"')
for line in open(filename):
Expand All @@ -91,7 +95,7 @@ def find_version(filename):


# The full version, including alpha/beta/rc tags.
release = find_version("../rdflib/__init__.py")
release = rdflib.__version__
# The short X.Y version.
version = re.sub("[0-9]+\\.[0-9]\\..*", "\1", release)

Expand Down
1,295 changes: 1,295 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

149 changes: 149 additions & 0 deletions pyproject.toml
@@ -1,3 +1,86 @@
[tool.poetry]
name = "rdflib"
version = "6.3.0a0"
description = """
RDFLib is a Python library for working with RDF, \
a simple yet powerful language for representing information."""
authors = ["Daniel 'eikeon' Krech <eikeon@eikeon.com>"]
maintainers = ["RDFLib Team <rdflib-dev@googlegroups.com>"]
repository = "https://github.com/RDFLib/rdflib"
documentation = "https://rdflib.readthedocs.org/"
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",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: BSD License",
"Topic :: Software Development :: Libraries :: Python Modules",
"Operating System :: OS Independent",
"Natural Language :: English"
]
readme = "README.md"

[tool.poetry.scripts]
rdfpipe = 'rdflib.tools.rdfpipe:main'
csv2rdf = 'rdflib.tools.csv2rdf:main'
rdf2dot = 'rdflib.tools.rdf2dot:main'
rdfs2dot = 'rdflib.tools.rdfs2dot:main'
rdfgraphisomorphism = 'rdflib.tools.graphisomorphism:main'

[tool.poetry.dependencies]
python = "^3.7"
isodate = "^0.6.1"
pyparsing = "^3.0.9"
#setuptools # not needed anymore?
importlib_metadata = {version = "^4.2.0", python = ">=3.7,<3.8"}
berkeleydb = {version = "^18.1.5", optional = true}
networkx = [
{version = "^2.6.2", python = ">3.7,<3.8", optional = true},
{version = "^2.8.8", python = "^3.8", optional = true},
]
html5lib = {version = "^1.1", optional = true}
black = {version = "22.12.0", optional = true}
flake8 = {version = ">=4.0.1", optional = true} # flakeheaven is incompatible with flake8 >=5.0 (https://github.com/flakeheaven/flakeheaven/issues/132)
flakeheaven = {version = "^3.2.1", optional = true}
pep8-naming = {version = "^0.13.2", optional = true}
isort = {version = "^5.10.0", optional = true}
mypy = {version = "0.991", optional = true}
sphinx = {version = ">4.0.0", optional = true}
myst-parser = {version = "^0.18.0", optional = true}
sphinxcontrib-apidoc = {version = "^0.3.0", optional = true}
sphinxcontrib-kroki = {version = "^1.3.0", optional = true}
sphinx-autodoc-typehints = {version = "^1.17.1", optional = true}
pytest = {version = "^7.1.3", optional = true}
pytest-cov = {version = "^4.0.0", optional = true}
coverage = {version = "^7.0.1", extras = ["toml"], optional = true}

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

[tool.poetry.extras]
berkeleydb = ["berkeleydb"]
networkx = ["networkx"]
jclerman marked this conversation as resolved.
Show resolved Hide resolved
html = ["html5lib"]
dev = ["black", "flake8", "flakeheaven", "isort", "mypy", "pep8-naming"]
docs = [
"sphinx",
"myst-parser",
"sphinxcontrib-apidoc",
"sphinxcontrib-kroki",
"sphinx-autodoc-typehints"
]
tests = ["html5lib", "pytest", "pytest-cov", "coverage"]

[build-system]
requires = ["poetry-core>=1.4.0"]
build-backend = "poetry.core.masonry.api"

[tool.flakeheaven]
format = "grouped"
baseline = ".flakeheaven.baseline"
Expand Down Expand Up @@ -82,3 +165,69 @@ log_format = "%(asctime)s.%(msecs)03d %(levelname)-8s %(name)-12s %(filename)s:%
log_date_format = "%Y-%m-%dT%H:%M:%S"
log_cli_format = "%(asctime)s.%(msecs)03d %(levelname)-8s %(name)-12s %(filename)s:%(lineno)s:%(funcName)s %(message)s"
log_cli_date_format = "%Y-%m-%dT%H:%M:%S"

[tool.isort]
profile = "black"
py_version = 37
line_length = 88
src_paths= ["rdflib", "test"]
supported_extensions = ["pyw", "pyi", "py"]
skip = [
'.eggs', # exclude a few common directories in the
'.git', # root of the project
'.hg',
'.mypy_cache',
'.pytest_cache',
'.tox',
'.venv',
'.github',
'_build',
'htmlcov',
'benchmarks',
'examples', # No need to Black examples
aucampia marked this conversation as resolved.
Show resolved Hide resolved
'test_reports',
'rdflib.egg-info',
'buck-out',
'build',
'dist',
'venv',
]

[tool.mypy]
files = ['rdflib', 'test', 'devtools']
python_version = "3.7"
warn_unused_configs = true
ignore_missing_imports = true
disallow_subclassing_any = false
warn_unreachable = true
warn_unused_ignores = true
no_implicit_optional = false

[[tool.mypy.overrides]]
module = "pyparsing.*"
# This is here because of an upstream issue with pyparsing:
# https://github.com/pyparsing/pyparsing/issues/385
# Once the issue is fixed this should be removed.
follow_imports = "skip"
jclerman marked this conversation as resolved.
Show resolved Hide resolved

[tool.coverage.run]
branch = true
source = ["rdflib"]
omit = ["*/_type_checking.py"]

[tool.coverage.report]
exclude_lines = [
# Have to re-enable the standard pragma
"pragma: no cover",

# TYPE_CHECKING guarded code only affects type checkers.
"^ *if (False|TYPE_CHECKING):",
# constant used in protocols and abstract methods, does not run anything
# and has no side effects.
'^ +\.\.\.$',

# Don't complain if non-runnable code isn't run:
"if 0:",
"if __name__ == .__main__.:",
"if __name__==.__main__.:"
]
17 changes: 12 additions & 5 deletions rdflib/__init__.py
Expand Up @@ -42,10 +42,20 @@
True

"""
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

_DISTRIBUTION_METADATA = metadata.metadata("rdflib")

__docformat__ = "restructuredtext en"

# The format of the __version__ line is matched by a regex in setup.py
__version__ = "6.3.0a0"
__version__: str = _DISTRIBUTION_METADATA["Version"]
__date__ = "2022-12-20"

__all__ = [
Expand Down Expand Up @@ -88,9 +98,6 @@
"query",
]

import logging
import sys

logger = logging.getLogger(__name__)

try:
Expand Down
74 changes: 0 additions & 74 deletions setup.cfg
Expand Up @@ -25,77 +25,3 @@ extend-ignore =
W503, # Line break occurred before a binary operator
# Disabled because this bumps heads with black
E231, # missing whitespace after ','

[coverage:run]
branch = True
source = rdflib
omit =
*/_type_checking.py

[coverage:report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover

# TYPE_CHECKING guarded code only affects type checkers.
^ *if (False|TYPE_CHECKING):
# constant used in protocols and abstract methods, does not run anything
# and has no side effects.
^ +\.\.\.$

# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:
if __name__==.__main__.:

[mypy]
files = rdflib,test,devtools
python_version = 3.7
warn_unused_configs = True
ignore_missing_imports = True
disallow_subclassing_any = False
warn_unreachable = True
warn_unused_ignores = True
no_implicit_optional = False

# This is here to exclude the setup.py files in test plugins because these
# confuse mypy as mypy think they are the same module.
exclude = (?x)(
^.*test/plugins/.*/setup.py$
)

[mypy-pyparsing.*]
# This is here because of an upstream issue with pyparsing:
# https://github.com/pyparsing/pyparsing/issues/385
# Once the issue is fixed this should be removed.
follow_imports = skip

[isort]
profile = black
py_version = 37
line_length = 88
src_paths=rdflib,test
supported_extensions =
pyw
pyi
py
skip =
.eggs, # exclude a few common directories in the
.git, # root of the project
.hg,
.mypy_cache,
.pytest_cache,
.tox,
.venv,
.github,
_build,
htmlcov,
benchmarks,
examples, # No need to Black examples
test_reports,
rdflib.egg-info,
buck-out,
build,
dist,
venv,
8 changes: 3 additions & 5 deletions tox.ini
Expand Up @@ -2,6 +2,7 @@
[tox]
envlist =
flake8,py3{7,8,9,10,11},covreport,docs,precommit
isolated_build = True

[testenv]
deps =
Expand All @@ -25,8 +26,7 @@ commands =
docs: sphinx-build -n -T -W -b html -d {envdir}/doctree docs docs/_build/html

[testenv:covreport]
deps = coverage
skip_install = true
extras = tests
parallel_show_output = true
depends = py3{7,8,9,10}{-extensive,}{-docs,}
setenv =
Expand All @@ -36,9 +36,7 @@ commands =
{envpython} -m coverage report

[testenv:flake8]
deps =
-rrequirements.flake8.txt
skip_install = true
aucampia marked this conversation as resolved.
Show resolved Hide resolved
extras = dev
commands =
{envpython} -m flakeheaven lint

Expand Down