Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.buildout
Commits
67fd1da8
Commit
67fd1da8
authored
Jun 18, 2010
by
Gary Poster
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some problems with allowed_eggs_from_site_packages
parent
525254ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
10 deletions
+91
-10
src/zc/buildout/easy_install.py
src/zc/buildout/easy_install.py
+22
-10
src/zc/buildout/tests.py
src/zc/buildout/tests.py
+69
-0
No files found.
src/zc/buildout/easy_install.py
View file @
67fd1da8
...
...
@@ -58,7 +58,6 @@ if is_jython:
import
java.lang.System
jython_os_name
=
(
java
.
lang
.
System
.
getProperties
()[
'os.name'
]).
lower
()
setuptools_loc
=
pkg_resources
.
working_set
.
find
(
pkg_resources
.
Requirement
.
parse
(
'setuptools'
)
).
location
...
...
@@ -873,7 +872,13 @@ class Installer:
dist
=
best
[
req
.
key
]
=
env
.
best_match
(
req
,
ws
)
except
pkg_resources
.
VersionConflict
,
err
:
raise
VersionConflict
(
err
,
ws
)
if
dist
is
None
:
if
dist
is
None
or
(
dist
.
location
in
self
.
_site_packages
and
not
self
.
allow_site_package_egg
(
dist
.
project_name
)):
# If we didn't find a distribution in the
# environment, or what we found is from site
# packages and not allowed to be there, try
# again.
if
destination
:
logger
.
debug
(
'Getting required %r'
,
str
(
req
))
else
:
...
...
@@ -1548,15 +1553,15 @@ def _generate_site(dest, working_set, executable, extra_paths=(),
"""
path
=
_get_path
(
working_set
,
extra_paths
)
site_path
=
os
.
path
.
join
(
dest
,
'site.py'
)
egg_path_string
,
preamble
=
_relative_path_and_setup
(
site_path
,
path
,
relative_paths
,
indent_level
=
2
,
omit_os_import
=
True
)
if
preamble
:
preamble
=
'
\
n
'
.
join
(
[(
line
and
' %s'
%
(
line
,)
or
line
)
for
line
in
preamble
.
split
(
'
\
n
'
)])
original_path_setup
=
''
original_path_setup
=
preamble
=
''
if
include_site_packages
:
stdlib
,
site_paths
=
_get_system_paths
(
executable
)
# We want to make sure that paths from site-packages, such as those
# allowed by allowed_eggs_from_site_packages, always come last, or
# else site-packages paths may include packages that mask the eggs we
# really want.
path
=
[
p
for
p
in
path
if
p
not
in
site_paths
]
# Now we set up the code we need.
original_path_setup
=
original_path_snippet
%
(
_format_paths
((
repr
(
p
)
for
p
in
site_paths
),
2
),)
distribution
=
working_set
.
find
(
...
...
@@ -1570,10 +1575,17 @@ def _generate_site(dest, working_set, executable, extra_paths=(),
relative_paths
)
else
:
location
=
repr
(
distribution
.
location
)
preamble
+
=
namespace_include_site_packages_setup
%
(
location
,)
preamble
=
namespace_include_site_packages_setup
%
(
location
,)
original_path_setup
=
(
addsitedir_namespace_originalpackages_snippet
+
original_path_setup
)
egg_path_string
,
relative_preamble
=
_relative_path_and_setup
(
site_path
,
path
,
relative_paths
,
indent_level
=
2
,
omit_os_import
=
True
)
if
relative_preamble
:
relative_preamble
=
'
\
n
'
.
join
(
[(
line
and
' %s'
%
(
line
,)
or
line
)
for
line
in
relative_preamble
.
split
(
'
\
n
'
)])
preamble
=
relative_preamble
+
preamble
addsitepackages_marker
=
'def addsitepackages('
enableusersite_marker
=
'ENABLE_USER_SITE = '
successful_rewrite
=
False
...
...
src/zc/buildout/tests.py
View file @
67fd1da8
...
...
@@ -2255,6 +2255,75 @@ include-site-packages.
"""
def
allowed_eggs_from_site_packages_dependencies_bugfix
():
"""
If you specify that a package with a dependency may come from site-packages,
that doesn't mean that the dependency may come from site-packages. This
is a test for a bug fix to verify that this is true.
>>> py_path, site_packages_path = make_py()
>>> create_sample_sys_install(site_packages_path)
>>> interpreter_dir = tmpdir('interpreter')
>>> interpreter_parts_dir = os.path.join(
... interpreter_dir, 'parts', 'interpreter')
>>> interpreter_bin_dir = os.path.join(interpreter_dir, 'bin')
>>> mkdir(interpreter_bin_dir)
>>> mkdir(interpreter_dir, 'eggs')
>>> mkdir(interpreter_dir, 'parts')
>>> mkdir(interpreter_parts_dir)
>>> ws = zc.buildout.easy_install.install(
... ['demo'], join(interpreter_dir, 'eggs'), executable=py_path,
... links=[link_server], index=link_server+'index/',
... allowed_eggs_from_site_packages=['demo'])
>>> [dist.project_name for dist in ws]
['demo', 'demoneeded']
>>> from pprint import pprint
>>> pprint([dist.location for dist in ws])
['/executable_buildout/site-packages',
'/interpreter/eggs/demoneeded-1.1-pyN.N.egg']
"""
def
allowed_eggs_from_site_packages_bug_592524
():
"""
When we use allowed_eggs_from_site_packages, we need to make sure that the
site-packages paths are not inserted with the normal egg paths. They already
included at the end, and including them along with the normal egg paths will
possibly mask subsequent egg paths. This affects interpreters and scripts
generated by sitepackage_safe_scripts.
Our "py_path" has the "demoneeded" and "demo" packages available.
>>> py_path, site_packages_path = make_py()
>>> create_sample_sys_install(site_packages_path)
>>> interpreter_dir = tmpdir('interpreter')
>>> interpreter_parts_dir = os.path.join(
... interpreter_dir, 'parts', 'interpreter')
>>> interpreter_bin_dir = os.path.join(interpreter_dir, 'bin')
>>> mkdir(interpreter_bin_dir)
>>> mkdir(interpreter_dir, 'eggs')
>>> mkdir(interpreter_dir, 'parts')
>>> mkdir(interpreter_parts_dir)
>>> ws = zc.buildout.easy_install.install(
... ['demo', 'other'], join(interpreter_dir, 'eggs'), executable=py_path,
... links=[link_server], index=link_server+'index/',
... allowed_eggs_from_site_packages=['demo'])
>>> generated = zc.buildout.easy_install.sitepackage_safe_scripts(
... interpreter_bin_dir, ws, py_path, interpreter_parts_dir,
... interpreter='py', include_site_packages=True)
Now we will look at the paths in the site.py we generated. Notice that the
site-packages are at the end. They were not before this bugfix.
>>> test = 'import pprint, sys; pprint.pprint(sys.path[-4:])'
>>> print call_py(join(interpreter_bin_dir, 'py'), test)
['/interpreter/eggs/other-1.0-pyN.N.egg',
'/interpreter/eggs/demoneeded-1.1-pyN.N.egg',
'/executable_buildout/eggs/setuptools-0.0-pyN.N.egg',
'/executable_buildout/site-packages']
<BLANKLINE>
"""
def
subprocesses_have_same_environment_by_default
():
"""
The scripts generated by sitepackage_safe_scripts set the PYTHONPATH so that,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment