Skip to content

Commit

Permalink
Generate a constraint file for tests and sphinx
Browse files Browse the repository at this point in the history
This solves a problem that when we pre-install packages for OSX, we need
to install the same version that is used in buildout profiles.
  • Loading branch information
perrinjerome committed Nov 1, 2024
1 parent 072af95 commit 1b40c56
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 6 deletions.
53 changes: 53 additions & 0 deletions constraints-tests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Babel==2.16.0
Jinja2==3.1.4
MarkupSafe==2.1.5; python_version == '3.8'
MarkupSafe==3.0.1; python_version > '3.8'
Missing==5.0
Products.BTreeFolder2==5.1
Products.ZCatalog==7.1
Pygments==2.18.0
Record==4.1
Sphinx==7.1.2; python_version == '3.8'
Sphinx==7.4.7; python_version == '3.9'
Sphinx==8.0.2; python_version > '3.9'
alabaster==0.7.13; python_version == '3.8'
alabaster==0.7.14; python_version == '3.9'
alabaster==1.0.0; python_version > '3.9'
certifi==2024.8.30
charset-normalizer==3.4.0
collective.recipe.template==2.2
colorama==0.4.6
docutils==0.20.1; python_version == '3.8'
docutils==0.20.1; python_version == '3.9'
docutils==0.21.2; python_version > '3.9'
five.localsitemanager==4.0
furo==2024.8.6
idna==3.10
imagesize==1.4.1
importlib-metadata==8.5.0
importlib-resources==6.4.0; python_version == '3.8'
legacy-cgi==2.6.1
mr.developer==2.0.2
packaging==24.1
plone.recipe.command==1.1
requests==2.32.3
snowballstemmer==2.2.0
sphinx-basic-ng==1.0.0b2
sphinxcontrib-applehelp==1.0.4; python_version == '3.8'
sphinxcontrib-applehelp==2.0.0; python_version > '3.8'
sphinxcontrib-devhelp==1.0.2; python_version == '3.8'
sphinxcontrib-devhelp==2.0.0; python_version > '3.8'
sphinxcontrib-htmlhelp==2.0.1; python_version == '3.8'
sphinxcontrib-htmlhelp==2.1.0; python_version > '3.8'
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3; python_version == '3.8'
sphinxcontrib-qthelp==2.0.0; python_version > '3.8'
sphinxcontrib-serializinghtml==1.1.5; python_version == '3.8'
sphinxcontrib-serializinghtml==2.0.0; python_version > '3.8'
tempstorage==6.0
tomli==2.0.2
urllib3==2.2.3
z3c.checkversions==2.1
zc.recipe.testrunner==3.1
zipp==3.20.2
zope.testrunner==6.5
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ deps =
# must be installed separately, zc.buildout is incompatible with the
# universal2 mode and cannot install them itself.
universal2: -c {toxinidir}/constraints.txt
universal2: -c {toxinidir}/constraints-tests.txt
universal2: zope.interface
universal2: zope.security
universal2: zope.container
Expand Down Expand Up @@ -60,6 +61,7 @@ deps =
# must be installed separately, zc.buildout is incompatible with the
# universal2 mode and cannot install them itself.
universal2: -c {toxinidir}/constraints.txt
universal2: -c {toxinidir}/constraints-tests.txt
universal2: zope.interface
universal2: zope.security
universal2: zope.container
Expand Down
18 changes: 12 additions & 6 deletions util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ def optionxform(self, value):
return value


def generate(in_, requirements_file, constraints_file):
def generate(
in_: str,
requirements_file: Optional[str],
constraints_file: str):
in_file = os.path.join(HERE, in_)
out_file_requirements = os.path.join(HERE, requirements_file)
if requirements_file:
out_file_requirements = os.path.join(HERE, requirements_file)
out_file_constraints = os.path.join(HERE, constraints_file)
parser = CaseSensitiveParser()
parser.read(in_file)
Expand All @@ -44,10 +48,11 @@ def generate(in_, requirements_file, constraints_file):
parser.items('versions'), None, requirements, constraints,
zope_requirement)

with open(out_file_requirements, 'w') as fd:
fd.write(zope_requirement)
for req in sorted(requirements):
fd.write(req)
if requirements_file:
with open(out_file_requirements, 'w') as fd:
fd.write(zope_requirement)
for req in sorted(requirements):
fd.write(req)
with open(out_file_constraints, 'w') as fcon:
for con in sorted(constraints):
fcon.write(con)
Expand Down Expand Up @@ -96,6 +101,7 @@ def _generate(

def main():
generate('versions-prod.cfg', 'requirements-full.txt', 'constraints.txt')
generate('versions.cfg', None, 'constraints-tests.txt')


if __name__ == '__main__':
Expand Down

0 comments on commit 1b40c56

Please sign in to comment.