Lele Gaifax <[email protected]> writes:
> Jim Fulton <[email protected]> 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'
_______________________________________________
Distutils-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/distutils-sig