-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #645 from plone/maurits/script-constraints-file
Let buildout run a script to create a constraints file. [5.2]
- Loading branch information
Showing
3 changed files
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Parse versions from buildout.cfg and write them into constraints.txt. | ||
This script is automatically called by buildout. | ||
Manual usage: bin/python create-constraints.py | ||
zc.buildout needs to be importable in that python. | ||
""" | ||
from zc.buildout import buildout | ||
|
||
|
||
# We could read a buildout config filename from the command line arguments, | ||
# but for now it is fine to hardcode it: | ||
configfile = "buildout.cfg" | ||
config = buildout.Buildout(configfile, []) | ||
|
||
# Get the constraints from the version pins. | ||
# Nice: the versions get set directly on the config. | ||
# Note: this works like a dictionary, but is a class 'zc.buildout.buildout.Options'. | ||
versions = config.versions | ||
constraints_file = "constraints.txt" | ||
with open(constraints_file, "w") as cfile: | ||
cfile.write("# File created by {}\n".format(__file__)) | ||
cfile.write("# Constraints parsed from {}\n".format(configfile)) | ||
for package, version in sorted(versions.items()): | ||
cfile.write("{}=={}\n".format(package, version)) | ||
print("Wrote all versions as constraints to {}.".format(constraints_file)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters