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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
slapos.buildout
Commits
8a087b51
Commit
8a087b51
authored
May 12, 2012
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
normalize the way default options are handled and documented
Cherry-picked from trunk. Thanks Gary.
parent
8a3f1e9f
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
259 additions
and
161 deletions
+259
-161
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+45
-31
src/zc/buildout/buildout.txt
src/zc/buildout/buildout.txt
+202
-123
src/zc/buildout/tests.py
src/zc/buildout/tests.py
+5
-0
zc.recipe.egg_/src/zc/recipe/egg/egg.py
zc.recipe.egg_/src/zc/recipe/egg/egg.py
+7
-7
No files found.
src/zc/buildout/buildout.py
View file @
8a087b51
...
...
@@ -108,13 +108,24 @@ def _unannotate(data):
return
data
_buildout_default_options
=
_annotate_section
({
'
eggs-directory'
:
'eggs
'
,
'
develop-eggs-directory'
:
'develop-eggs
'
,
'
allow-hosts'
:
'*
'
,
'
allow-picked-versions'
:
'true
'
,
'bin-directory'
:
'bin'
,
'parts-directory'
:
'parts'
,
'develop-eggs-directory'
:
'develop-eggs'
,
'eggs-directory'
:
'eggs'
,
'executable'
:
sys
.
executable
,
'find-links'
:
''
,
'install-from-cache'
:
'false'
,
'installed'
:
'.installed.cfg'
,
'log-level'
:
'INFO'
,
'log-format'
:
''
,
'log-level'
:
'INFO'
,
'newest'
:
'true'
,
'offline'
:
'false'
,
'parts-directory'
:
'parts'
,
'prefer-final'
:
'false'
,
'python'
:
'buildout'
,
'unzip'
:
'false'
,
'use-dependency-links'
:
'true'
,
},
'DEFAULT_VALUE'
)
# _buildout_version and _buildout_1_4_default_versions are part of a
...
...
@@ -201,7 +212,7 @@ class Buildout(UserDict.DictMixin):
# provide some defaults before options are parsed
# because while parsing options those attributes might be
# used already (Gottfried Ganssauge)
buildout_section
=
data
.
get
(
'buildout'
)
buildout_section
=
data
[
'buildout'
]
# Try to make sure we have absolute paths for standard
# directories. We do this before doing substitutions, in case
...
...
@@ -214,22 +225,28 @@ class Buildout(UserDict.DictMixin):
d
=
self
.
_buildout_path
(
buildout_section
[
name
+
'-directory'
])
buildout_section
[
name
+
'-directory'
]
=
d
links
=
buildout_section
and
buildout_section
.
get
(
'find-links'
,
''
)
# Attributes on this buildout object shouldn't be used by
# recipes in their __init__. It can cause bugs, because the
# recipes will be instantiated below (``options = self['buildout']``)
# before this has completed initializing. These attributes are
# left behind for legacy support but recipe authors should
# beware of using them. A better practice is for a recipe to
# use the buildout['buildout'] options.
links
=
buildout_section
[
'find-links'
]
self
.
_links
=
links
and
links
.
split
()
or
()
allow_hosts
=
buildout_section
and
buildout_section
.
get
(
'allow-hosts'
,
'*'
).
split
(
'
\
n
'
)
allow_hosts
=
buildout_section
[
'allow-hosts'
].
split
(
'
\
n
'
)
self
.
_allow_hosts
=
tuple
([
host
.
strip
()
for
host
in
allow_hosts
if
host
.
strip
()
!=
''
])
self
.
_logger
=
logging
.
getLogger
(
'zc.buildout'
)
self
.
offline
=
False
self
.
newest
=
True
self
.
offline
=
(
buildout_section
[
'offline'
]
==
'true'
)
self
.
newest
=
(
buildout_section
[
'newest'
]
==
'true'
)
##################################################################
## WARNING!!!
## ALL ATTRIBUTES MUST HAVE REASONABLE DEFAULTS AT THIS POINT
## OTHERWISE ATTRIBUTEERRORS MIGHT HAPPEN ANY TIME
## OTHERWISE ATTRIBUTEERRORS MIGHT HAPPEN ANY TIME FROM RECIPES.
## RECIPES SHOULD GENERALLY USE buildout['buildout'] OPTIONS, NOT
## BUILDOUT ATTRIBUTES.
##################################################################
# initialize some attrs and buildout directories.
options
=
self
[
'buildout'
]
...
...
@@ -238,7 +255,7 @@ class Buildout(UserDict.DictMixin):
links
=
options
.
get
(
'find-links'
,
''
)
self
.
_links
=
links
and
links
.
split
()
or
()
allow_hosts
=
options
.
get
(
'allow-hosts'
,
'*'
)
.
split
(
'
\
n
'
)
allow_hosts
=
options
[
'allow-hosts'
]
.
split
(
'
\
n
'
)
self
.
_allow_hosts
=
tuple
([
host
.
strip
()
for
host
in
allow_hosts
if
host
.
strip
()
!=
''
])
...
...
@@ -256,20 +273,18 @@ class Buildout(UserDict.DictMixin):
self
.
_setup_logging
()
offline
=
options
.
get
(
'offline'
,
'false'
)
offline
=
options
[
'offline'
]
if
offline
not
in
(
'true'
,
'false'
):
self
.
_error
(
'Invalid value for offline option: %s'
,
offline
)
options
[
'offline'
]
=
offline
self
.
offline
=
offline
==
'true'
self
.
offline
=
(
offline
==
'true'
)
if
self
.
offline
:
newest
=
options
[
'newest'
]
=
'false'
else
:
newest
=
options
.
get
(
'newest'
,
'true'
)
newest
=
options
[
'newest'
]
if
newest
not
in
(
'true'
,
'false'
):
self
.
_error
(
'Invalid value for newest option: %s'
,
newest
)
options
[
'newest'
]
=
newest
self
.
newest
=
newest
==
'true'
self
.
newest
=
(
newest
==
'true'
)
# This is a hacked version of zc.buildout for 1.4.4.
# This means that buildout uses the defaults set up above. The point
...
...
@@ -282,25 +297,25 @@ class Buildout(UserDict.DictMixin):
versions
.
update
(
dict
(
self
[
versions_section
]))
zc
.
buildout
.
easy_install
.
default_versions
(
versions
)
prefer_final
=
options
.
get
(
'prefer-final'
,
'false'
)
prefer_final
=
options
[
'prefer-final'
]
if
prefer_final
not
in
(
'true'
,
'false'
):
self
.
_error
(
'Invalid value for prefer-final option: %s'
,
prefer_final
)
zc
.
buildout
.
easy_install
.
prefer_final
(
prefer_final
==
'true'
)
use_dependency_links
=
options
.
get
(
'use-dependency-links'
,
'true'
)
use_dependency_links
=
options
[
'use-dependency-links'
]
if
use_dependency_links
not
in
(
'true'
,
'false'
):
self
.
_error
(
'Invalid value for use-dependency-links option: %s'
,
use_dependency_links
)
zc
.
buildout
.
easy_install
.
use_dependency_links
(
use_dependency_links
==
'true'
)
allow_picked_versions
=
options
.
get
(
'allow-picked-versions'
,
'true'
)
allow_picked_versions
=
options
[
'allow-picked-versions'
]
if
allow_picked_versions
not
in
(
'true'
,
'false'
):
self
.
_error
(
'Invalid value for allow-picked-versions option: %s'
,
allow_picked_versions
)
zc
.
buildout
.
easy_install
.
allow_picked_versions
(
allow_picked_versions
==
'true'
)
allow_picked_versions
==
'true'
)
download_cache
=
options
.
get
(
'download-cache'
)
if
download_cache
:
...
...
@@ -317,13 +332,12 @@ class Buildout(UserDict.DictMixin):
zc
.
buildout
.
easy_install
.
download_cache
(
download_cache
)
install_from_cache
=
options
.
get
(
'install-from-cache'
)
if
install_from_cache
:
install_from_cache
=
options
[
'install-from-cache'
]
if
install_from_cache
not
in
(
'true'
,
'false'
):
self
.
_error
(
'Invalid value for install-from-cache option: %s'
,
install_from_cache
)
if
install_from_cache
==
'true'
:
zc
.
buildout
.
easy_install
.
install_from_cache
(
True
)
zc
.
buildout
.
easy_install
.
install_from_cache
(
install_from_cache
==
'true'
)
# "Use" each of the defaults so they aren't reported as unused options.
for
name
in
_buildout_default_options
:
...
...
src/zc/buildout/buildout.txt
View file @
8a087b51
This diff is collapsed.
Click to expand it.
src/zc/buildout/tests.py
View file @
8a087b51
...
...
@@ -2851,6 +2851,8 @@ def test_suite():
r'
when
that
file
already
exists
:
'),
'
[
Errno
17
]
File
exists
:
'
),
(re.compile('
executable
=
%
s
' % re.escape(sys.executable)),
'
executable
=
python
'),
])
),
doctest.DocFileSuite(
...
...
@@ -2947,6 +2949,9 @@ def test_suite():
'-q develop -mxN -d /sample-buildout/develop-eggs'
),
(re.compile(r'^[*]...'), '...'),
# for bug_92891_bootstrap_crashes_with_egg_recipe_in_buildout_section
(re.compile(r"
Unused
options
for
buildout
:
'eggs'
'scripts'
\
.
"),
"
Unused
options
for
buildout
:
'scripts'
'eggs'
.
"),
]),
),
zc.buildout.rmtree.test_suite(),
...
...
zc.recipe.egg_/src/zc/recipe/egg/egg.py
View file @
8a087b51
...
...
@@ -27,8 +27,8 @@ class Eggs(object):
self
.
buildout
=
buildout
self
.
name
=
name
self
.
options
=
options
links
=
options
.
get
(
'find-links'
,
buildout
[
'buildout'
].
get
(
'find-links'
)
)
b_options
=
buildout
[
'buildout'
]
links
=
options
.
get
(
'find-links'
,
b_options
[
'find-links'
]
)
if
links
:
links
=
links
.
split
()
options
[
'find-links'
]
=
'
\
n
'
.
join
(
links
)
...
...
@@ -36,20 +36,19 @@ class Eggs(object):
links
=
()
self
.
links
=
links
index
=
options
.
get
(
'index'
,
b
uildout
[
'buildout'
]
.
get
(
'index'
))
index
=
options
.
get
(
'index'
,
b
_options
.
get
(
'index'
))
if
index
is
not
None
:
options
[
'index'
]
=
index
self
.
index
=
index
allow_hosts
=
b
uildout
[
'buildout'
].
get
(
'allow-hosts'
,
'*'
)
allow_hosts
=
b
_options
[
'allow-hosts'
]
allow_hosts
=
tuple
([
host
.
strip
()
for
host
in
allow_hosts
.
split
(
'
\
n
'
)
if
host
.
strip
()
!=
''
])
self
.
allow_hosts
=
allow_hosts
options
[
'eggs-directory'
]
=
b
uildout
[
'buildout'
]
[
'eggs-directory'
]
options
[
'eggs-directory'
]
=
b
_options
[
'eggs-directory'
]
options
[
'_e'
]
=
options
[
'eggs-directory'
]
# backward compat.
options
[
'develop-eggs-directory'
]
=
buildout
[
'buildout'
][
'develop-eggs-directory'
]
options
[
'develop-eggs-directory'
]
=
b_options
[
'develop-eggs-directory'
]
options
[
'_d'
]
=
options
[
'develop-eggs-directory'
]
# backward compat.
def
working_set
(
self
,
extra
=
()):
...
...
@@ -58,6 +57,7 @@ class Eggs(object):
This is intended for reuse by similar recipes.
"""
options
=
self
.
options
b_options
=
self
.
buildout
[
'buildout'
]
# Backward compat. :(
options
[
'executable'
]
=
sys
.
executable
...
...
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