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
98b7c55c
Commit
98b7c55c
authored
Feb 20, 2010
by
Gary Poster
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support limiting packages from site-packages
parent
e73c70bb
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
628 additions
and
130 deletions
+628
-130
.bzrignore
.bzrignore
+9
-0
src/zc/buildout/easy_install.py
src/zc/buildout/easy_install.py
+215
-95
src/zc/buildout/easy_install.txt
src/zc/buildout/easy_install.txt
+72
-0
src/zc/buildout/testing.py
src/zc/buildout/testing.py
+33
-6
src/zc/buildout/tests.py
src/zc/buildout/tests.py
+299
-29
No files found.
.bzrignore
0 → 100644
View file @
98b7c55c
.installed.cfg
bin
build
develop-eggs
eggs
parts
src/zc.buildout.egg-info
z3c.recipe.scripts_/src/z3c.recipe.scripts.egg-info
zc.recipe.egg_/src/zc.recipe.egg.egg-info
src/zc/buildout/easy_install.py
View file @
98b7c55c
This diff is collapsed.
Click to expand it.
src/zc/buildout/easy_install.txt
View file @
98b7c55c
...
@@ -89,6 +89,14 @@ use_dependency_links
...
@@ -89,6 +89,14 @@ use_dependency_links
for using dependency_links in preference to other
for using dependency_links in preference to other
locations. Defaults to true.
locations. Defaults to true.
include_site_packages
A flag indicating whether Python's non-standard-library packages should
be available for finding dependencies. Defaults to true.
Paths outside of Python's standard library--or more precisely, those that
are not included when Python is started with the -S argument--are loosely
referred to as "site-packages" here.
relative_paths
relative_paths
Adjust egg paths so they are relative to the script path. This
Adjust egg paths so they are relative to the script path. This
allows scripts to work when scripts and eggs are moved, as long as
allows scripts to work when scripts and eggs are moved, as long as
...
@@ -399,6 +407,68 @@ dictionary:
...
@@ -399,6 +407,68 @@ dictionary:
>>> [d.version for d in ws]
>>> [d.version for d in ws]
['0.3', '1.1']
['0.3', '1.1']
Dependencies in Site Packages
-----------------------------
Paths outside of Python's standard library--or more precisely, those that are
not included when Python is started with the -S argument--are loosely referred
to as "site-packages" here. These site-packages are searched by default for
distributions. This can be disabled, so that, for instance, a system Python
can be used with buildout, cleaned of any packages installed by a user or
system package manager.
The default behavior can be controlled and introspected using
zc.buildout.easy_install.include_site_packages.
>>> zc.buildout.easy_install.include_site_packages()
True
Here's an example of using a Python executable that includes our dependencies.
Our "py_path" will have the "demoneeded," and "demo" packages available.
We'll simply be asking for "demoneeded" here, but without any external
index or links.
>>> from zc.buildout.tests import create_sample_sys_install
>>> py_path, site_packages_path = make_py()
>>> create_sample_sys_install(site_packages_path)
>>> example_dest = tmpdir('site-packages-example-install')
>>> workingset = zc.buildout.easy_install.install(
... ['demoneeded'], example_dest, links=[], executable=py_path,
... index=None)
>>> [dist.project_name for dist in workingset]
['demoneeded']
That worked fine. Let's try again with site packages not allowed. We'll
change the policy by changing the default. Notice that the function for
changing the default value returns the previous value.
>>> zc.buildout.easy_install.include_site_packages(False)
True
>>> zc.buildout.easy_install.include_site_packages()
False
>>> zc.buildout.easy_install.clear_index_cache()
>>> rmdir(example_dest)
>>> example_dest = tmpdir('site-packages-example-install')
>>> workingset = zc.buildout.easy_install.install(
... ['demoneeded'], example_dest, links=[], executable=py_path,
... index=None)
Traceback (most recent call last):
...
MissingDistribution: Couldn't find a distribution for 'demoneeded'.
>>> zc.buildout.easy_install.clear_index_cache()
Now we'll reset the default.
>>> zc.buildout.easy_install.include_site_packages(True)
False
>>> zc.buildout.easy_install.include_site_packages()
True
Dependency links
Dependency links
----------------
----------------
...
@@ -1259,6 +1329,7 @@ call to another text fixture to create.
...
@@ -1259,6 +1329,7 @@ call to another text fixture to create.
>>> namespace_eggs = tmpdir('namespace_eggs')
>>> namespace_eggs = tmpdir('namespace_eggs')
>>> create_sample_namespace_eggs(namespace_eggs)
>>> create_sample_namespace_eggs(namespace_eggs)
>>> reset_interpreter()
>>> ws = zc.buildout.easy_install.install(
>>> ws = zc.buildout.easy_install.install(
... ['demo', 'tellmy.fortune'], join(interpreter_dir, 'eggs'),
... ['demo', 'tellmy.fortune'], join(interpreter_dir, 'eggs'),
... links=[link_server, namespace_eggs], index=link_server+'index/')
... links=[link_server, namespace_eggs], index=link_server+'index/')
...
@@ -1319,6 +1390,7 @@ The most complex that this function gets is if you use namespace packages,
...
@@ -1319,6 +1390,7 @@ The most complex that this function gets is if you use namespace packages,
include site-packages, and use relative paths. For completeness, we'll look
include site-packages, and use relative paths. For completeness, we'll look
at that result.
at that result.
>>> reset_interpreter()
>>> generated = zc.buildout.easy_install.generate_scripts(
>>> generated = zc.buildout.easy_install.generate_scripts(
... interpreter_bin_dir, ws, sys.executable, interpreter_parts_dir,
... interpreter_bin_dir, ws, sys.executable, interpreter_parts_dir,
... interpreter='py', add_site_packages=True,
... interpreter='py', add_site_packages=True,
...
...
src/zc/buildout/testing.py
View file @
98b7c55c
...
@@ -222,11 +222,37 @@ def wait_until(label, func, *args, **kw):
...
@@ -222,11 +222,37 @@ def wait_until(label, func, *args, **kw):
time
.
sleep
(
0.01
)
time
.
sleep
(
0.01
)
raise
ValueError
(
'Timed out waiting for: '
+
label
)
raise
ValueError
(
'Timed out waiting for: '
+
label
)
def
get_installer_values
():
"""Get the current values for the easy_install module.
This is necessary because instantiating a Buildout will force the
Buildout's values on the installer.
Returns a dict of names-values suitable for set_installer_values."""
names
=
(
'default_versions'
,
'download_cache'
,
'install_from_cache'
,
'prefer_final'
,
'include_site_packages'
,
'allowed_eggs_from_site_packages'
,
'use_dependency_links'
,
'allow_picked_versions'
,
'always_unzip'
)
values
=
{}
for
name
in
names
:
values
[
name
]
=
getattr
(
zc
.
buildout
.
easy_install
,
name
)()
return
values
def
set_installer_values
(
values
):
"""Set the given values on the installer."""
for
name
,
value
in
values
.
items
():
getattr
(
zc
.
buildout
.
easy_install
,
name
)(
value
)
def
make_buildout
():
def
make_buildout
():
# Create a basic buildout.cfg to avoid a warning from buildout:
"""Make a buildout that uses this version of zc.buildout."""
# Create a basic buildout.cfg to avoid a warning from buildout.
open
(
'buildout.cfg'
,
'w'
).
write
(
open
(
'buildout.cfg'
,
'w'
).
write
(
"[buildout]
\
n
parts =
\
n
"
"[buildout]
\
n
parts =
\
n
"
)
)
# Get state of installer defaults so we can reinstate them (instantiating
# a Buildout will force the Buildout's defaults on the installer).
installer_values
=
get_installer_values
()
# Use the buildout bootstrap command to create a buildout
# Use the buildout bootstrap command to create a buildout
zc
.
buildout
.
buildout
.
Buildout
(
zc
.
buildout
.
buildout
.
Buildout
(
'buildout.cfg'
,
'buildout.cfg'
,
...
@@ -234,20 +260,23 @@ def make_buildout():
...
@@ -234,20 +260,23 @@ def make_buildout():
# trick bootstrap into putting the buildout develop egg
# trick bootstrap into putting the buildout develop egg
# in the eggs dir.
# in the eggs dir.
(
'buildout'
,
'develop-eggs-directory'
,
'eggs'
),
(
'buildout'
,
'develop-eggs-directory'
,
'eggs'
),
]
],
user_defaults
=
False
,
).
bootstrap
([])
).
bootstrap
([])
# Create the develop-eggs dir, which didn't get created the usual
# Create the develop-eggs dir, which didn't get created the usual
# way due to the trick above:
# way due to the trick above:
os
.
mkdir
(
'develop-eggs'
)
os
.
mkdir
(
'develop-eggs'
)
# Reinstate the default values of the installer.
set_installer_values
(
installer_values
)
def
buildoutSetUp
(
test
):
def
buildoutSetUp
(
test
):
test
.
globs
[
'__tear_downs'
]
=
__tear_downs
=
[]
test
.
globs
[
'__tear_downs'
]
=
__tear_downs
=
[]
test
.
globs
[
'register_teardown'
]
=
register_teardown
=
__tear_downs
.
append
test
.
globs
[
'register_teardown'
]
=
register_teardown
=
__tear_downs
.
append
prefer_final
=
zc
.
buildout
.
easy_install
.
prefer_final
()
installer_values
=
get_installer_values
()
register_teardown
(
register_teardown
(
lambda
:
zc
.
buildout
.
easy_install
.
prefer_final
(
prefer_final
)
lambda
:
set_installer_values
(
installer_values
)
)
)
here
=
os
.
getcwd
()
here
=
os
.
getcwd
()
...
@@ -367,8 +396,6 @@ def buildoutSetUp(test):
...
@@ -367,8 +396,6 @@ def buildoutSetUp(test):
make_py
=
make_py
make_py
=
make_py
))
))
zc
.
buildout
.
easy_install
.
prefer_final
(
prefer_final
)
def
buildoutTearDown
(
test
):
def
buildoutTearDown
(
test
):
for
f
in
test
.
globs
[
'__tear_downs'
]:
for
f
in
test
.
globs
[
'__tear_downs'
]:
f
()
f
()
...
...
src/zc/buildout/tests.py
View file @
98b7c55c
This diff is collapsed.
Click to expand it.
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