Skip to content

Commit

Permalink
De-dup oldest Python and attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Apr 17, 2023
1 parent 5a2aefa commit bd4067a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
25 changes: 19 additions & 6 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,28 @@
nox.options.error_on_external_run = True


MATCH_PYTHON = re.compile(r"\s+python\: \"(\d\.\d\d)\"").match
# Avoid dependency on a YAML lib using a questionable hack.
# Avoid dependencies on YAML / TOML libs using a questionable hacks.
match_docs_python = re.compile(r"\s+python\: \"(\d\.\d\d)\"").fullmatch
for line in Path(".readthedocs.yaml").read_text().splitlines():
m = MATCH_PYTHON(line)
m = match_docs_python(line)
if m:
DOCS_PYTHON = m.group(1)
break

match_oldest_python = re.compile(
r"requires-python = \">=(\d\.\d+)\""
).fullmatch
match_oldest_attrs = re.compile(r".*\"attrs>=(\d+\.\d+\.\d+)\",.*").match
for line in Path("pyproject.toml").read_text().splitlines():
m = match_oldest_python(line)
if m:
OLDEST_PYTHON = m.group(1)

m = match_oldest_attrs(line)
if m:
OLDEST_ATTRS = m.group(1)
break # dependencies always come after requires-python


@nox.session
def pre_commit(session: nox.Session) -> None:
Expand Down Expand Up @@ -49,10 +63,9 @@ def tests(session: nox.Session) -> None:
session.run("pytest", *session.posargs)


@nox.session(python="3.7", tags=["tests"])
@nox.session(python=OLDEST_PYTHON, tags=["tests"])
def tests_oldest_attrs(session: nox.Session) -> None:
# Keeps attrs pin in sync with pyproject.toml/dependencies.
session.install(".[tests]", "attrs==17.4.0")
session.install(".[tests]", f"attrs=={OLDEST_ATTRS}")

_cov(session)

Expand Down
7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dynamic = ["readme", "version"]
name = "environ-config"
description = "Boilerplate-free configuration with env variables."
authors = [{ name = "Hynek Schlawack", email = "hs@ox.cx" }]
# Keep in sync with noxfile.py/tests_oldest_attrs
requires-python = ">=3.7"
license = "Apache-2.0"
keywords = ["app", "config", "env", "cfg"]
Expand All @@ -31,11 +30,7 @@ classifiers = [
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
# Keep in sync with noxfile.py/tests_oldest_attrs
"attrs>=17.4.0",
"importlib_metadata; python_version<'3.8'",
]
dependencies = ["attrs>=17.4.0", "importlib_metadata; python_version<'3.8'"]

[project.optional-dependencies]
tests = ["pytest", "coverage[toml]", "moto"]
Expand Down

0 comments on commit bd4067a

Please sign in to comment.