[Distutils] Buildout 2 and system packages
Ralf Schmitt
ralf at systemexit.de
Fri Feb 22 23:29:34 CET 2013
Lele Gaifax <lele at metapensiero.it> writes:
> Jim Fulton <jim at zope.com> writes:
>
>> The problem is that site-packages doesn't have a predictable
>> location, as demonstrated by the example given in this thread. On
>> some systems, there are multiple directories containing custom
>> modules.
>
> Sorry to insist (being dumb :), but couldn't buildout, that should know
> the list of explicitly requested distributions, sort the paths giving
> precedence to them?
The following uses working_set.resolve to do that. I may miss some
details here, but it looks like this can be done in a sane way...
diff --git a/src/zc/buildout/easy_install.py b/src/zc/buildout/easy_install.py
index 75f7047..48acda0 100644
--- a/src/zc/buildout/easy_install.py
+++ b/src/zc/buildout/easy_install.py
@@ -889,7 +889,14 @@ def scripts(reqs, working_set, executable, dest=None,
):
assert executable == sys.executable, (executable, sys.executable)
- path = [dist.location for dist in working_set]
+ if isinstance(reqs, str):
+ raise TypeError('Expected iterable of requirements or entry points,'
+ ' got string.')
+
+ parsed_requirements = [pkg_resources.Requirement.parse(req) for req in reqs if isinstance(req, str)]
+ path = [dist.location for dist in working_set.resolve(parsed_requirements)]
+ path.extend([dist.location for dist in working_set])
+
path.extend(extra_paths)
# order preserving unique
unique_path = []
@@ -900,9 +907,6 @@ def scripts(reqs, working_set, executable, dest=None,
generated = []
- if isinstance(reqs, str):
- raise TypeError('Expected iterable of requirements or entry points,'
- ' got string.')
if initialization:
initialization = '\n'+initialization+'\n'
More information about the Distutils-SIG
mailing list