Commit 34c291ca authored by Julien Muchembled's avatar Julien Muchembled Committed by Xavier Thompson

[feat] Ignore directory containing the Python library

This is useful when using OS Python & eggs.

Useless for SlapOS.
parent 9f806b0b
......@@ -2190,7 +2190,8 @@ def _dists_sig(dists):
continue
seen.add(dist)
location = dist.location
if dist.precedence == pkg_resources.DEVELOP_DIST:
if (dist.precedence == pkg_resources.DEVELOP_DIST
and location != zc.buildout.easy_install.python_lib):
result.append(dist.project_name + '-' + _dir_hash(location))
else:
result.append(dist.project_name + '-' + dist.version)
......
......@@ -20,6 +20,7 @@ installed.
import copy
import distutils.errors
import distutils.sysconfig
import errno
import glob
import logging
......@@ -100,6 +101,8 @@ setuptools_path = buildout_and_setuptools_path
pip_path = buildout_and_setuptools_path
logger.debug('before restricting versions: pip_path %r', pip_path)
python_lib = distutils.sysconfig.get_python_lib()
FILE_SCHEME = re.compile('file://', re.I).match
DUNDER_FILE_PATTERN = re.compile(r"__file__ = '(?P<filename>.+)'$")
......@@ -1165,6 +1168,10 @@ def scripts(reqs, working_set, executable, dest=None,
if p not in unique_path:
unique_path.append(p)
path = [realpath(p) for p in unique_path]
try:
path.remove(python_lib)
except ValueError:
pass
generated = []
......@@ -1337,6 +1344,12 @@ join = os.path.join
base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
"""
def _initialization(path, initialization):
return """sys.path[0:0] = [
%s,
]
""" % path + initialization if path else initialization
def _script(module_name, attrs, path, dest, arguments, initialization, rsetup):
if is_win32:
dest += '-script.py'
......@@ -1345,11 +1358,10 @@ def _script(module_name, attrs, path, dest, arguments, initialization, rsetup):
contents = script_template % dict(
python = python,
path = path,
module_name = module_name,
attrs = attrs,
arguments = arguments,
initialization = initialization,
initialization = _initialization(path, initialization),
relative_paths_setup = rsetup,
)
return _create_script(contents, dest)
......@@ -1382,8 +1394,7 @@ def _distutils_script(path, dest, script_content, initialization, rsetup):
contents = distutils_script_template % dict(
python = python,
path = path,
initialization = initialization,
initialization = _initialization(path, initialization),
relative_paths_setup = rsetup,
before = before,
after = after
......@@ -1451,9 +1462,6 @@ script_template = script_header + '''\
%(relative_paths_setup)s
import sys
sys.path[0:0] = [
%(path)s,
]
%(initialization)s
import %(module_name)s
......@@ -1465,9 +1473,6 @@ distutils_script_template = script_header + '''
%(before)s
%(relative_paths_setup)s
import sys
sys.path[0:0] = [
%(path)s,
]
%(initialization)s
%(after)s'''
......@@ -1480,14 +1485,12 @@ def _pyscript(path, dest, rsetup, initialization=''):
dest += '-script.py'
python = _safe_arg(sys.executable)
if path:
path += ',' # Courtesy comma at the end of the list.
contents = py_script_template % dict(
python = python,
path = path,
relative_paths_setup = rsetup,
initialization=initialization,
initialization = _initialization(path, initialization),
)
changed = _file_changed(dest, contents)
......@@ -1522,9 +1525,6 @@ py_script_template = script_header + '''\
%%(relative_paths_setup)s
import sys
sys.path[0:0] = [
%%(path)s
]
%%(initialization)s
_interactive = True
......
......@@ -765,9 +765,9 @@ An interpreter can also be generated without other eggs:
<BLANKLINE>
import sys
<BLANKLINE>
sys.path[0:0] = [
<BLANKLINE>
]
<BLANKLINE>
_interactive = True
...
An additional argument can be passed to define which scripts to install
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment