Skip to content

Commit

Permalink
release/tox.ini: no longer generate constraints for Python 3.7.
Browse files Browse the repository at this point in the history
Also use python2.7 explicitly instead of python2.
For some reason, neither of those are found locally though.
So I generated the 2.7 constraints manually.
  • Loading branch information
mauritsvanrees committed Jul 19, 2023
1 parent 1f15fb7 commit e7a0b0d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
21 changes: 4 additions & 17 deletions release/combine-constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,54 +28,41 @@ def parse_file(filename):


constraints = os.path.join(directory, "constraints.txt")
constraints37 = os.path.join(directory, "constraints37.txt")
constraints38 = os.path.join(directory, "constraints38.txt")
constraints2 = os.path.join(directory, "constraints2.txt")
for filename in (constraints2, constraints37, constraints38):
for filename in (constraints2, constraints38):
if not os.path.exists(filename):
print(f"ERROR: {filename} does not exist.")
print(
"Run: tox -p auto -e constraints2,constraints37,constraints38,constraints"
"Run: tox -p auto -e constraints2,constraints38,constraints"
)
sys.exit(1)

c2 = parse_file(constraints2)
c37 = parse_file(constraints37)
c38 = parse_file(constraints38)

# Gather them all in one dictionary.
pins = defaultdict(dict)
for package, version in c2.items():
pins[package][2] = version
for package, version in c37.items():
pins[package][37] = version
for package, version in c38.items():
pins[package][38] = version

# Combine them.
combi = []
for package, versions in pins.items():
py2_version = versions.pop(2, None)
py37_version = versions.pop(37, None)
py38_version = versions.pop(38, None)
if py2_version == py37_version == py38_version:
if py2_version == py38_version:
# All versions are the same.
combi.append(f"{package}=={py2_version}")
continue
# Some versions are different or missing.
# Start with Python 2.
if py2_version is not None:
combi.append(f'{package}=={py2_version}; python_version < "3.0"')
if not (py37_version or py38_version):
continue
if py37_version == py38_version:
# All Py3 versions are the same.
combi.append(f'{package}=={py37_version}; python_version >= "3.0"')
continue
if py37_version is not None:
combi.append(f'{package}=={py37_version}; python_version == "3.7"')
if py38_version is not None:
combi.append(f'{package}=={py38_version}; python_version == "3.8"')
combi.append(f'{package}=={py38_version}; python_version >= "3.0"')

output = "\n".join(combi) + "\n"
# sanity check:
Expand Down
17 changes: 6 additions & 11 deletions release/tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[tox]
envlist =
constraints2,
constraints37,
constraints38,
constraints,
downloads2,
Expand All @@ -14,27 +13,23 @@ skip_install = true
commands_pre = python -m pip install -r {toxinidir}/../requirements.txt

[testenv:constraints2]
basepython = python2
basepython = python2.7
commands = python create-constraints.py {toxinidir}/../buildout.cfg {toxinidir}/constraints2.txt

[testenv:constraints37]
basepython = python3.7
commands = python create-constraints.py {toxinidir}/../buildout.cfg {toxinidir}/constraints37.txt

[testenv:constraints38]
basepython = python3.8
commands = python create-constraints.py {toxinidir}/../buildout.cfg {toxinidir}/constraints38.txt

[testenv:constraints]
basepython = python3
# Specifying other tox envs as dependencies helps when running in parallel.
depends = constraints2, constraints37, constraints38
depends = constraints2, constraints38
commands_pre =
commands = python combine-constraints.py {toxinidir}

[testenv:downloads2]
# Use pip to download all pinned packages.
basepython = python2
basepython = python2.7
depends = constraints
commands_pre = pip install -U pip
commands =
Expand All @@ -48,15 +43,15 @@ commands =
# pip download -r {toxinidir}/constraints.txt --dest {toxinidir}/dist --no-index --find-links {toxinidir}/olddist

[testenv:downloads3]
basepython = python3.7
basepython = python3.8
depends = constraints
commands_pre = pip install -U pip
commands =
pip download -r {toxinidir}/constraints37.txt --dest {toxinidir}/dist
pip download -r {toxinidir}/constraints38.txt --dest {toxinidir}/dist

[testenv:gather]
# Copy a few more files to the dist directory, for syncing with dist.plone.org.
basepython = python3
basepython = python3.8
depends = downloads2, downloads3
allowlist_externals =
cp
Expand Down

0 comments on commit e7a0b0d

Please sign in to comment.