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
83d53da5
Commit
83d53da5
authored
Jun 11, 2012
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkout: core tests passing w python 3.2
parent
493394b7
Changes
28
Show whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
1857 additions
and
1616 deletions
+1857
-1616
bootstrap/bootstrap.py
bootstrap/bootstrap.py
+3
-3
buildout.cfg
buildout.cfg
+1
-1
dev.py
dev.py
+3
-3
src/zc/buildout/__init__.py
src/zc/buildout/__init__.py
+1
-1
src/zc/buildout/allowhosts.txt
src/zc/buildout/allowhosts.txt
+3
-3
src/zc/buildout/bootstrap.txt
src/zc/buildout/bootstrap.txt
+11
-11
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+79
-83
src/zc/buildout/buildout.txt
src/zc/buildout/buildout.txt
+87
-85
src/zc/buildout/configparser.py
src/zc/buildout/configparser.py
+164
-0
src/zc/buildout/debugging.txt
src/zc/buildout/debugging.txt
+3
-3
src/zc/buildout/dependencylinks.txt
src/zc/buildout/dependencylinks.txt
+6
-12
src/zc/buildout/download.py
src/zc/buildout/download.py
+11
-10
src/zc/buildout/download.txt
src/zc/buildout/download.txt
+24
-24
src/zc/buildout/downloadcache.txt
src/zc/buildout/downloadcache.txt
+4
-4
src/zc/buildout/easy_install.py
src/zc/buildout/easy_install.py
+17
-13
src/zc/buildout/easy_install.txt
src/zc/buildout/easy_install.txt
+1162
-1156
src/zc/buildout/extends-cache.txt
src/zc/buildout/extends-cache.txt
+25
-25
src/zc/buildout/isolation.txt
src/zc/buildout/isolation.txt
+6
-5
src/zc/buildout/repeatable.txt
src/zc/buildout/repeatable.txt
+12
-8
src/zc/buildout/rmtree.py
src/zc/buildout/rmtree.py
+3
-2
src/zc/buildout/runsetup.txt
src/zc/buildout/runsetup.txt
+3
-2
src/zc/buildout/setup.txt
src/zc/buildout/setup.txt
+3
-3
src/zc/buildout/testing.py
src/zc/buildout/testing.py
+29
-22
src/zc/buildout/testrecipes.py
src/zc/buildout/testrecipes.py
+3
-2
src/zc/buildout/tests.py
src/zc/buildout/tests.py
+179
-124
src/zc/buildout/update.txt
src/zc/buildout/update.txt
+8
-6
src/zc/buildout/windows.txt
src/zc/buildout/windows.txt
+5
-3
zc.recipe.egg_/src/zc/recipe/egg/custom.py
zc.recipe.egg_/src/zc/recipe/egg/custom.py
+2
-2
No files found.
bootstrap/bootstrap.py
View file @
83d53da5
...
@@ -18,7 +18,7 @@ The script accepts buildout command-line options, so you can
...
@@ -18,7 +18,7 @@ The script accepts buildout command-line options, so you can
use the -c option to specify an alternate configuration file.
use the -c option to specify an alternate configuration file.
"""
"""
import
os
,
shutil
,
sys
,
tempfile
,
urllib
2
import
os
,
shutil
,
sys
,
tempfile
,
urllib
.
request
,
urllib
.
error
,
urllib
.
parse
from
optparse
import
OptionParser
from
optparse
import
OptionParser
tmpeggs
=
tempfile
.
mkdtemp
()
tmpeggs
=
tempfile
.
mkdtemp
()
...
@@ -80,9 +80,9 @@ try:
...
@@ -80,9 +80,9 @@ try:
raise
ImportError
raise
ImportError
except
ImportError
:
except
ImportError
:
ez
=
{}
ez
=
{}
exec
urllib2
.
urlopen
(
exec
(
urllib
.
request
.
urlopen
(
'http://python-distribute.org/distribute_setup.py'
'http://python-distribute.org/distribute_setup.py'
).
read
()
in
ez
).
read
()
,
ez
)
setup_args
=
dict
(
to_dir
=
tmpeggs
,
download_delay
=
0
,
no_fake
=
True
)
setup_args
=
dict
(
to_dir
=
tmpeggs
,
download_delay
=
0
,
no_fake
=
True
)
ez
[
'use_setuptools'
](
**
setup_args
)
ez
[
'use_setuptools'
](
**
setup_args
)
...
...
buildout.cfg
View file @
83d53da5
...
@@ -9,7 +9,7 @@ eggs = zc.buildout
...
@@ -9,7 +9,7 @@ eggs = zc.buildout
interpreter = py
interpreter = py
[test]
[test]
recipe = zc.recipe.testrunner
recipe = zc.recipe.testrunner
==1.3.0
eggs =
eggs =
zc.buildout[test]
zc.buildout[test]
zc.recipe.egg
zc.recipe.egg
...
...
dev.py
View file @
83d53da5
...
@@ -17,7 +17,7 @@ This is different from a normal boostrapping process because the
...
@@ -17,7 +17,7 @@ This is different from a normal boostrapping process because the
buildout egg itself is installed as a develop egg.
buildout egg itself is installed as a develop egg.
"""
"""
import
os
,
shutil
,
sys
,
subprocess
,
urllib
2
import
os
,
shutil
,
sys
,
subprocess
,
urllib
.
request
,
urllib
.
error
,
urllib
.
parse
for
d
in
'eggs'
,
'develop-eggs'
,
'bin'
,
'parts'
:
for
d
in
'eggs'
,
'develop-eggs'
,
'bin'
,
'parts'
:
if
not
os
.
path
.
exists
(
d
):
if
not
os
.
path
.
exists
(
d
):
...
@@ -57,8 +57,8 @@ else:
...
@@ -57,8 +57,8 @@ else:
######################################################################
######################################################################
# Install distribute
# Install distribute
ez
=
{}
ez
=
{}
exec
urllib2
.
urlopen
(
exec
(
urllib
.
request
.
urlopen
(
'http://python-distribute.org/distribute_setup.py'
).
read
()
in
ez
'http://python-distribute.org/distribute_setup.py'
).
read
()
,
ez
)
ez
[
'use_setuptools'
](
to_dir
=
'eggs'
,
download_delay
=
0
)
ez
[
'use_setuptools'
](
to_dir
=
'eggs'
,
download_delay
=
0
)
import
pkg_resources
import
pkg_resources
...
...
src/zc/buildout/__init__.py
View file @
83d53da5
...
@@ -19,4 +19,4 @@ class UserError(Exception):
...
@@ -19,4 +19,4 @@ class UserError(Exception):
"""
"""
def
__str__
(
self
):
def
__str__
(
self
):
return
" "
.
join
(
map
(
str
,
self
))
return
" "
.
join
(
map
(
str
,
self
.
args
))
src/zc/buildout/allowhosts.txt
View file @
83d53da5
...
@@ -55,7 +55,7 @@ local files::
...
@@ -55,7 +55,7 @@ local files::
Now we can run the buildout and make sure all attempts to dist.plone.org fails::
Now we can run the buildout and make sure all attempts to dist.plone.org fails::
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
Develop: '/sample-buildout/allowdemo'
Develop: '/sample-buildout/allowdemo'
Installing eggs.
Installing eggs.
<BLANKLINE>
<BLANKLINE>
...
@@ -91,7 +91,7 @@ XXX (showcase with a svn:// file)
...
@@ -91,7 +91,7 @@ XXX (showcase with a svn:// file)
Now we can run the buildout and make sure all attempts to dist.plone.org fails::
Now we can run the buildout and make sure all attempts to dist.plone.org fails::
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
Develop: '/sample-buildout/allowdemo'
Develop: '/sample-buildout/allowdemo'
Installing eggs.
Installing eggs.
<BLANKLINE>
<BLANKLINE>
...
@@ -121,7 +121,7 @@ Test for 1.0.5 breakage as in https://bugs.launchpad.net/zc.buildout/+bug/239212
...
@@ -121,7 +121,7 @@ Test for 1.0.5 breakage as in https://bugs.launchpad.net/zc.buildout/+bug/239212
... eggs=zc.buildout
... eggs=zc.buildout
... interpreter=python
... interpreter=python
... ''')
... ''')
>>> print
'XX'; print system(buildout
) # doctest: +ELLIPSIS
>>> print
_('XX'; print system(buildout)
) # doctest: +ELLIPSIS
X...
X...
Unused options for buildout: 'foo'.
Unused options for buildout: 'foo'.
Installing python.
Installing python.
...
...
src/zc/buildout/bootstrap.txt
View file @
83d53da5
...
@@ -20,9 +20,9 @@ Make sure the bootstrap script actually works::
...
@@ -20,9 +20,9 @@ Make sure the bootstrap script actually works::
... parts =
... parts =
... ''')
... ''')
>>> write('bootstrap.py', open(bootstrap_py).read())
>>> write('bootstrap.py', open(bootstrap_py).read())
>>> print
'X'; print system(
>>> print
_(
'X'; print system(
... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
... 'bootstrap.py')
; print 'X'
# doctest: +ELLIPSIS
... 'bootstrap.py')
); print_('X')
# doctest: +ELLIPSIS
X...
X...
Creating directory '/sample/bin'.
Creating directory '/sample/bin'.
Creating directory '/sample/parts'.
Creating directory '/sample/parts'.
...
@@ -43,7 +43,7 @@ Make sure the bootstrap script actually works::
...
@@ -43,7 +43,7 @@ Make sure the bootstrap script actually works::
>>> ls(sample_buildout, 'bin')
>>> ls(sample_buildout, 'bin')
- buildout
- buildout
>>> print
'X'
; ls(sample_buildout, 'eggs') # doctest: +ELLIPSIS
>>> print
_('X')
; ls(sample_buildout, 'eggs') # doctest: +ELLIPSIS
X...
X...
d zc.buildout-...egg
d zc.buildout-...egg
...
@@ -52,9 +52,9 @@ Now trying the `--version` option, that let you define a version for
...
@@ -52,9 +52,9 @@ Now trying the `--version` option, that let you define a version for
Let's try with an unknown version::
Let's try with an unknown version::
>>> print
'X'; print
system(
>>> print
_('X'); print_(
system(
... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
... 'bootstrap.py --version UNKNOWN')
; print 'X'
# doctest: +ELLIPSIS
... 'bootstrap.py --version UNKNOWN')
); print_('X')
# doctest: +ELLIPSIS
...
...
X
X
...
...
...
@@ -63,9 +63,9 @@ Let's try with an unknown version::
...
@@ -63,9 +63,9 @@ Let's try with an unknown version::
Now let's try with `1.1.2`, which happens to exist::
Now let's try with `1.1.2`, which happens to exist::
>>> print
'X'; print
system(
>>> print
_('X'); print_(
system(
... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
... 'bootstrap.py --version 1.1.2')
; print 'X'
... 'bootstrap.py --version 1.1.2')
); print_('X')
... # doctest: +ELLIPSIS
... # doctest: +ELLIPSIS
X
X
...
...
...
@@ -78,7 +78,7 @@ Let's make sure the generated `buildout` script uses it::
...
@@ -78,7 +78,7 @@ Let's make sure the generated `buildout` script uses it::
>>> buildout_script = join(sample_buildout, 'bin', 'buildout')
>>> buildout_script = join(sample_buildout, 'bin', 'buildout')
>>> if sys.platform.startswith('win'):
>>> if sys.platform.startswith('win'):
... buildout_script += '-script.py'
... buildout_script += '-script.py'
>>> print
open(buildout_script).read(
) # doctest: +ELLIPSIS
>>> print
_(open(buildout_script).read()
) # doctest: +ELLIPSIS
#...
#...
<BLANKLINE>
<BLANKLINE>
import sys
import sys
...
@@ -95,9 +95,9 @@ Let's make sure the generated `buildout` script uses it::
...
@@ -95,9 +95,9 @@ Let's make sure the generated `buildout` script uses it::
Let's try with `1.2.1`::
Let's try with `1.2.1`::
>>> print
'X'; print
system(
>>> print
_('X'); print_(
system(
... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
... 'bootstrap.py --version 1.2.1')
; print 'X'
# doctest: +ELLIPSIS
... 'bootstrap.py --version 1.2.1')
); print_('X')
# doctest: +ELLIPSIS
...
...
X
X
...
...
...
@@ -107,7 +107,7 @@ Let's try with `1.2.1`::
...
@@ -107,7 +107,7 @@ Let's try with `1.2.1`::
Let's make sure the generated `buildout` script uses it::
Let's make sure the generated `buildout` script uses it::
>>> print
open(buildout_script).read(
) # doctest: +ELLIPSIS
>>> print
_(open(buildout_script).read()
) # doctest: +ELLIPSIS
#...
#...
<BLANKLINE>
<BLANKLINE>
import sys
import sys
...
...
src/zc/buildout/buildout.py
View file @
83d53da5
...
@@ -18,10 +18,15 @@
...
@@ -18,10 +18,15 @@
import
zc.buildout.easy_install
import
zc.buildout.easy_install
no_site
=
zc
.
buildout
.
easy_install
.
no_site
no_site
=
zc
.
buildout
.
easy_install
.
no_site
from
rmtree
import
rmtree
from
.
rmtree
import
rmtree
from
hashlib
import
md5
from
hashlib
import
md5
import
ConfigParser
try
:
from
UserDict
import
DictMixin
except
ImportError
:
from
collections
import
MutableMapping
as
DictMixin
import
zc.buildout.configparser
import
copy
import
copy
import
distutils.errors
import
distutils.errors
import
glob
import
glob
...
@@ -34,10 +39,17 @@ import shutil
...
@@ -34,10 +39,17 @@ import shutil
import
subprocess
import
subprocess
import
sys
import
sys
import
tempfile
import
tempfile
import
UserDict
import
zc.buildout
import
zc.buildout
import
zc.buildout.download
import
zc.buildout.download
def
_print_options
(
sep
=
' '
,
end
=
'
\
n
'
,
file
=
None
):
return
sep
,
end
,
file
def
print_
(
*
args
,
**
kw
):
sep
,
end
,
file
=
_print_options
(
**
kw
)
if
file
is
None
:
file
=
sys
.
stdout
file
.
write
(
sep
.
join
(
map
(
str
,
args
))
+
end
)
realpath
=
zc
.
buildout
.
easy_install
.
realpath
realpath
=
zc
.
buildout
.
easy_install
.
realpath
...
@@ -69,20 +81,20 @@ def _annotate(data, note):
...
@@ -69,20 +81,20 @@ def _annotate(data, note):
return
data
return
data
def
_print_annotate
(
data
):
def
_print_annotate
(
data
):
sections
=
data
.
keys
(
)
sections
=
list
(
data
.
keys
()
)
sections
.
sort
()
sections
.
sort
()
print
print
_
()
print
"Annotated sections"
print
_
(
"Annotated sections"
)
print
"="
*
len
(
"Annotated sections"
)
print
_
(
"="
*
len
(
"Annotated sections"
)
)
for
section
in
sections
:
for
section
in
sections
:
print
print
_
()
print
'[%s]'
%
section
print
_
(
'[%s]'
%
section
)
keys
=
data
[
section
].
keys
(
)
keys
=
list
(
data
[
section
].
keys
()
)
keys
.
sort
()
keys
.
sort
()
for
key
in
keys
:
for
key
in
keys
:
value
,
notes
=
data
[
section
][
key
]
value
,
notes
=
data
[
section
][
key
]
keyvalue
=
"%s= %s"
%
(
key
,
value
)
keyvalue
=
"%s= %s"
%
(
key
,
value
)
print
keyvalue
print
_
(
keyvalue
)
line
=
' '
line
=
' '
for
note
in
notes
.
split
():
for
note
in
notes
.
split
():
if
note
==
'[+]'
:
if
note
==
'[+]'
:
...
@@ -90,9 +102,9 @@ def _print_annotate(data):
...
@@ -90,9 +102,9 @@ def _print_annotate(data):
elif
note
==
'[-]'
:
elif
note
==
'[-]'
:
line
=
'-= '
line
=
'-= '
else
:
else
:
print
line
,
note
print
_
(
line
,
note
)
line
=
' '
line
=
' '
print
print
_
()
def
_unannotate_section
(
section
):
def
_unannotate_section
(
section
):
...
@@ -127,24 +139,7 @@ _buildout_default_options = _annotate_section({
...
@@ -127,24 +139,7 @@ _buildout_default_options = _annotate_section({
'use-dependency-links'
:
'true'
,
'use-dependency-links'
:
'true'
,
},
'DEFAULT_VALUE'
)
},
'DEFAULT_VALUE'
)
# _buildout_version and _buildout_1_4_default_versions are part of a
class
Buildout
(
DictMixin
):
# hack specific to zc.buildout 1.4.4. Search for
# _buildout_1_4_default_versions below to see the usage.
_buildout_version
=
pkg_resources
.
working_set
.
find
(
pkg_resources
.
Requirement
.
parse
(
'zc.buildout'
)).
version
_buildout_1_4_default_versions
=
{
# Buildout and recipes that are likely to change to 1.5.0 sooner rather
# than later.
'zc.buildout'
:
_buildout_version
,
# 'zc.recipe.egg': '1.2.2',
'zc.recipe.testrunner'
:
'1.3.0'
,
'z3c.recipe.i18n'
:
'0.7.0'
,
'z3c.recipe.tag:'
:
'0.3.0'
,
'djangorecipe'
:
'0.20'
,
}
class
Buildout
(
UserDict
.
DictMixin
):
def
__init__
(
self
,
config_file
,
cloptions
,
def
__init__
(
self
,
config_file
,
cloptions
,
user_defaults
=
True
,
windows_restart
=
False
,
user_defaults
=
True
,
windows_restart
=
False
,
...
@@ -295,7 +290,7 @@ class Buildout(UserDict.DictMixin):
...
@@ -295,7 +290,7 @@ class Buildout(UserDict.DictMixin):
# of it is to keep from migrating to 1.5 unless explicitly
# of it is to keep from migrating to 1.5 unless explicitly
# requested. This lets 1.4.4 be an "aspirin release" that people can
# requested. This lets 1.4.4 be an "aspirin release" that people can
# use if they are having trouble with the 1.5 releases.
# use if they are having trouble with the 1.5 releases.
versions
=
_buildout_1_4_default_versions
.
copy
()
versions
=
{}
versions_section
=
options
.
get
(
'versions'
)
versions_section
=
options
.
get
(
'versions'
)
if
versions_section
:
if
versions_section
:
versions
.
update
(
dict
(
self
[
versions_section
]))
versions
.
update
(
dict
(
self
[
versions_section
]))
...
@@ -392,7 +387,7 @@ class Buildout(UserDict.DictMixin):
...
@@ -392,7 +387,7 @@ class Buildout(UserDict.DictMixin):
self
[
'buildout'
][
'bin-directory'
])
self
[
'buildout'
][
'bin-directory'
])
def
_init_config
(
self
,
config_file
,
args
):
def
_init_config
(
self
,
config_file
,
args
):
print
'Creating %r.'
%
config_file
print
_
(
'Creating %r.'
%
config_file
)
f
=
open
(
config_file
,
'w'
)
f
=
open
(
config_file
,
'w'
)
sep
=
re
.
compile
(
r'[\\/]'
)
sep
=
re
.
compile
(
r'[\\/]'
)
if
args
:
if
args
:
...
@@ -477,11 +472,11 @@ class Buildout(UserDict.DictMixin):
...
@@ -477,11 +472,11 @@ class Buildout(UserDict.DictMixin):
if
self
.
_log_level
<
logging
.
DEBUG
:
if
self
.
_log_level
<
logging
.
DEBUG
:
sections
=
list
(
self
)
sections
=
list
(
self
)
sections
.
sort
()
sections
.
sort
()
print
print
_
()
print
'Configuration data:'
print
_
(
'Configuration data:'
)
for
section
in
self
.
_data
:
for
section
in
self
.
_data
:
_save_options
(
section
,
self
[
section
],
sys
.
stdout
)
_save_options
(
section
,
self
[
section
],
sys
.
stdout
)
print
print
_
()
# compute new part recipe signatures
# compute new part recipe signatures
...
@@ -628,7 +623,7 @@ class Buildout(UserDict.DictMixin):
...
@@ -628,7 +623,7 @@ class Buildout(UserDict.DictMixin):
installed
=
self
[
'buildout'
][
'installed'
]
installed
=
self
[
'buildout'
][
'installed'
]
f
=
open
(
installed
,
'a'
)
f
=
open
(
installed
,
'a'
)
f
.
write
(
'
\
n
[buildout]
\
n
'
)
f
.
write
(
'
\
n
[buildout]
\
n
'
)
for
option
,
value
in
buildout_options
.
items
(
):
for
option
,
value
in
list
(
buildout_options
.
items
()
):
_save_option
(
option
,
value
,
f
)
_save_option
(
option
,
value
,
f
)
f
.
close
()
f
.
close
()
...
@@ -644,7 +639,7 @@ class Buildout(UserDict.DictMixin):
...
@@ -644,7 +639,7 @@ class Buildout(UserDict.DictMixin):
recipe
,
'zc.buildout.uninstall'
,
entry
,
self
)
recipe
,
'zc.buildout.uninstall'
,
entry
,
self
)
self
.
_logger
.
info
(
'Running uninstall recipe.'
)
self
.
_logger
.
info
(
'Running uninstall recipe.'
)
uninstaller
(
part
,
installed_part_options
[
part
])
uninstaller
(
part
,
installed_part_options
[
part
])
except
(
ImportError
,
pkg_resources
.
DistributionNotFound
)
,
v
:
except
(
ImportError
,
pkg_resources
.
DistributionNotFound
):
pass
pass
# remove created files and directories
# remove created files and directories
...
@@ -734,13 +729,11 @@ class Buildout(UserDict.DictMixin):
...
@@ -734,13 +729,11 @@ class Buildout(UserDict.DictMixin):
def
_read_installed_part_options
(
self
):
def
_read_installed_part_options
(
self
):
old
=
self
[
'buildout'
][
'installed'
]
old
=
self
[
'buildout'
][
'installed'
]
if
old
and
os
.
path
.
isfile
(
old
):
if
old
and
os
.
path
.
isfile
(
old
):
parser
=
ConfigParser
.
RawConfigParser
()
with
open
(
old
)
as
fp
:
parser
.
optionxform
=
lambda
s
:
s
sections
=
zc
.
buildout
.
configparser
.
parse
(
fp
,
old
)
parser
.
read
(
old
)
result
=
{}
result
=
{}
for
section
in
parser
.
sections
():
for
section
,
options
in
sections
.
items
():
options
=
{}
for
option
,
value
in
options
.
items
():
for
option
,
value
in
parser
.
items
(
section
):
if
'%('
in
value
:
if
'%('
in
value
:
for
k
,
v
in
_spacey_defaults
:
for
k
,
v
in
_spacey_defaults
:
value
=
value
.
replace
(
k
,
v
)
value
=
value
.
replace
(
k
,
v
)
...
@@ -784,7 +777,7 @@ class Buildout(UserDict.DictMixin):
...
@@ -784,7 +777,7 @@ class Buildout(UserDict.DictMixin):
installed
=
recipe_class
(
self
,
part
,
options
).
install
()
installed
=
recipe_class
(
self
,
part
,
options
).
install
()
if
installed
is
None
:
if
installed
is
None
:
installed
=
[]
installed
=
[]
elif
isinstance
(
installed
,
basestring
):
elif
isinstance
(
installed
,
str
):
installed
=
[
installed
]
installed
=
[
installed
]
base
=
self
.
_buildout_path
(
''
)
base
=
self
.
_buildout_path
(
''
)
installed
=
[
d
.
startswith
(
base
)
and
d
[
len
(
base
):]
or
d
installed
=
[
d
.
startswith
(
base
)
and
d
[
len
(
base
):]
or
d
...
@@ -799,7 +792,7 @@ class Buildout(UserDict.DictMixin):
...
@@ -799,7 +792,7 @@ class Buildout(UserDict.DictMixin):
f
=
open
(
installed
,
'w'
)
f
=
open
(
installed
,
'w'
)
_save_options
(
'buildout'
,
installed_options
[
'buildout'
],
f
)
_save_options
(
'buildout'
,
installed_options
[
'buildout'
],
f
)
for
part
in
installed_options
[
'buildout'
][
'parts'
].
split
():
for
part
in
installed_options
[
'buildout'
][
'parts'
].
split
():
print
>>
f
print
_
(
file
=
f
)
_save_options
(
part
,
installed_options
[
part
],
f
)
_save_options
(
part
,
installed_options
[
part
],
f
)
f
.
close
()
f
.
close
()
...
@@ -808,7 +801,7 @@ class Buildout(UserDict.DictMixin):
...
@@ -808,7 +801,7 @@ class Buildout(UserDict.DictMixin):
def
_setup_socket_timeout
(
self
):
def
_setup_socket_timeout
(
self
):
timeout
=
self
[
'buildout'
][
'socket-timeout'
]
timeout
=
self
[
'buildout'
][
'socket-timeout'
]
if
timeout
<>
''
:
if
timeout
!=
''
:
try
:
try
:
timeout
=
int
(
timeout
)
timeout
=
int
(
timeout
)
import
socket
import
socket
...
@@ -901,7 +894,7 @@ class Buildout(UserDict.DictMixin):
...
@@ -901,7 +894,7 @@ class Buildout(UserDict.DictMixin):
return
return
if
sys
.
platform
==
'win32'
and
not
self
.
__windows_restart
:
if
sys
.
platform
==
'win32'
and
not
self
.
__windows_restart
:
args
=
map
(
zc
.
buildout
.
easy_install
.
_safe_arg
,
sys
.
argv
)
args
=
list
(
map
(
zc
.
buildout
.
easy_install
.
_safe_arg
,
sys
.
argv
)
)
args
.
insert
(
1
,
'-W'
)
args
.
insert
(
1
,
'-W'
)
if
not
__debug__
:
if
not
__debug__
:
args
.
insert
(
0
,
'-O'
)
args
.
insert
(
0
,
'-O'
)
...
@@ -986,12 +979,12 @@ class Buildout(UserDict.DictMixin):
...
@@ -986,12 +979,12 @@ class Buildout(UserDict.DictMixin):
fd
,
tsetup
=
tempfile
.
mkstemp
()
fd
,
tsetup
=
tempfile
.
mkstemp
()
try
:
try
:
os
.
write
(
fd
,
zc
.
buildout
.
easy_install
.
runsetup_template
%
dict
(
os
.
write
(
fd
,
(
zc
.
buildout
.
easy_install
.
runsetup_template
%
dict
(
distribute
=
pkg_resources_loc
,
distribute
=
pkg_resources_loc
,
setupdir
=
os
.
path
.
dirname
(
setup
),
setupdir
=
os
.
path
.
dirname
(
setup
),
setup
=
setup
,
setup
=
setup
,
__file__
=
setup
,
__file__
=
setup
,
))
))
.
encode
())
args
=
[
sys
.
executable
,
tsetup
]
+
args
args
=
[
sys
.
executable
,
tsetup
]
+
args
if
no_site
:
if
no_site
:
args
.
insert
(
1
,
'-S'
)
args
.
insert
(
1
,
'-S'
)
...
@@ -1029,11 +1022,14 @@ class Buildout(UserDict.DictMixin):
...
@@ -1029,11 +1022,14 @@ class Buildout(UserDict.DictMixin):
raise
NotImplementedError
(
'__delitem__'
)
raise
NotImplementedError
(
'__delitem__'
)
def
keys
(
self
):
def
keys
(
self
):
return
self
.
_raw
.
keys
(
)
return
list
(
self
.
_raw
.
keys
()
)
def
__iter__
(
self
):
def
__iter__
(
self
):
return
iter
(
self
.
_raw
)
return
iter
(
self
.
_raw
)
def
__len__
(
self
):
return
len
(
self
.
_raw
)
def
_install_and_load
(
spec
,
group
,
entry
,
buildout
):
def
_install_and_load
(
spec
,
group
,
entry
,
buildout
):
__doing__
=
'Loading recipe %r.'
,
spec
__doing__
=
'Loading recipe %r.'
,
spec
...
@@ -1066,14 +1062,15 @@ def _install_and_load(spec, group, entry, buildout):
...
@@ -1066,14 +1062,15 @@ def _install_and_load(spec, group, entry, buildout):
return
pkg_resources
.
load_entry_point
(
return
pkg_resources
.
load_entry_point
(
req
.
project_name
,
group
,
entry
)
req
.
project_name
,
group
,
entry
)
except
Exception
,
v
:
except
Exception
:
v
=
sys
.
exc_info
()[
1
]
buildout
.
_logger
.
log
(
buildout
.
_logger
.
log
(
1
,
1
,
"Could't load %s entry point %s
\
n
from %s:
\
n
%s."
,
"Could't load %s entry point %s
\
n
from %s:
\
n
%s."
,
group
,
entry
,
spec
,
v
)
group
,
entry
,
spec
,
v
)
raise
raise
class
Options
(
UserDict
.
DictMixin
):
class
Options
(
DictMixin
):
def
__init__
(
self
,
buildout
,
section
,
data
):
def
__init__
(
self
,
buildout
,
section
,
data
):
self
.
buildout
=
buildout
self
.
buildout
=
buildout
...
@@ -1090,7 +1087,7 @@ class Options(UserDict.DictMixin):
...
@@ -1090,7 +1087,7 @@ class Options(UserDict.DictMixin):
self
.
_raw
=
self
.
_do_extend_raw
(
name
,
self
.
_raw
,
[])
self
.
_raw
=
self
.
_do_extend_raw
(
name
,
self
.
_raw
,
[])
# force substitutions
# force substitutions
for
k
,
v
in
self
.
_raw
.
items
(
):
for
k
,
v
in
list
(
self
.
_raw
.
items
()
):
if
'${'
in
v
:
if
'${'
in
v
:
self
.
_dosub
(
k
,
v
)
self
.
_dosub
(
k
,
v
)
...
@@ -1241,12 +1238,18 @@ class Options(UserDict.DictMixin):
...
@@ -1241,12 +1238,18 @@ class Options(UserDict.DictMixin):
elif
key
in
self
.
_data
:
elif
key
in
self
.
_data
:
del
self
.
_data
[
key
]
del
self
.
_data
[
key
]
else
:
else
:
raise
KeyError
,
key
raise
KeyError
(
key
)
def
keys
(
self
):
def
keys
(
self
):
raw
=
self
.
_raw
raw
=
self
.
_raw
return
list
(
self
.
_raw
)
+
[
k
for
k
in
self
.
_data
if
k
not
in
raw
]
return
list
(
self
.
_raw
)
+
[
k
for
k
in
self
.
_data
if
k
not
in
raw
]
def
__iter__
(
self
):
return
iter
(
self
.
keys
())
def
__len__
(
self
):
return
len
(
self
.
keys
())
def
copy
(
self
):
def
copy
(
self
):
result
=
self
.
_raw
.
copy
()
result
=
self
.
_raw
.
copy
()
result
.
update
(
self
.
_cooked
)
result
.
update
(
self
.
_cooked
)
...
@@ -1317,11 +1320,11 @@ def _save_option(option, value, f):
...
@@ -1317,11 +1320,11 @@ def _save_option(option, value, f):
value
=
'%(__buildout_space_n__)s'
+
value
[
2
:]
value
=
'%(__buildout_space_n__)s'
+
value
[
2
:]
if
value
.
endswith
(
'
\
n
\
t
'
):
if
value
.
endswith
(
'
\
n
\
t
'
):
value
=
value
[:
-
2
]
+
'%(__buildout_space_n__)s'
value
=
value
[:
-
2
]
+
'%(__buildout_space_n__)s'
print
>>
f
,
option
,
'='
,
value
print
_
(
option
,
'='
,
value
,
file
=
f
)
def
_save_options
(
section
,
options
,
f
):
def
_save_options
(
section
,
options
,
f
):
print
>>
f
,
'[%s]'
%
section
print
_
(
'[%s]'
%
section
,
file
=
f
)
items
=
options
.
items
(
)
items
=
list
(
options
.
items
()
)
items
.
sort
()
items
.
sort
()
for
option
,
value
in
items
:
for
option
,
value
in
items
:
_save_option
(
option
,
value
,
f
)
_save_option
(
option
,
value
,
f
)
...
@@ -1374,25 +1377,17 @@ def _open(base, filename, seen, dl_options, override, downloaded):
...
@@ -1374,25 +1377,17 @@ def _open(base, filename, seen, dl_options, override, downloaded):
root_config_file
=
not
seen
root_config_file
=
not
seen
seen
.
append
(
filename
)
seen
.
append
(
filename
)
result
=
{}
result
=
zc
.
buildout
.
configparser
.
parse
(
fp
,
filename
)
parser
=
ConfigParser
.
RawConfigParser
()
parser
.
optionxform
=
lambda
s
:
s
parser
.
readfp
(
fp
)
if
is_temp
:
fp
.
close
()
fp
.
close
()
if
is_temp
:
os
.
remove
(
path
)
os
.
remove
(
path
)
extends
=
None
options
=
result
.
get
(
'buildout'
,
{})
for
section
in
parser
.
sections
():
extends
=
options
.
pop
(
'extends'
,
None
)
options
=
dict
(
parser
.
items
(
section
))
if
section
==
'buildout'
:
extends
=
options
.
pop
(
'extends'
,
extends
)
if
'extended-by'
in
options
:
if
'extended-by'
in
options
:
raise
zc
.
buildout
.
UserError
(
raise
zc
.
buildout
.
UserError
(
'No-longer supported "extended-by" option found in %s.'
%
'No-longer supported "extended-by" option found in %s.'
%
filename
)
filename
)
result
[
section
]
=
options
result
=
_annotate
(
result
,
filename
)
result
=
_annotate
(
result
,
filename
)
...
@@ -1425,11 +1420,11 @@ def _dir_hash(dir):
...
@@ -1425,11 +1420,11 @@ def _dir_hash(dir):
if
(
not
(
f
.
endswith
(
'pyc'
)
or
f
.
endswith
(
'pyo'
))
if
(
not
(
f
.
endswith
(
'pyc'
)
or
f
.
endswith
(
'pyo'
))
and
os
.
path
.
exists
(
os
.
path
.
join
(
dirpath
,
f
)))
and
os
.
path
.
exists
(
os
.
path
.
join
(
dirpath
,
f
)))
]
]
hash
.
update
(
' '
.
join
(
dirnames
))
hash
.
update
(
' '
.
join
(
dirnames
)
.
encode
()
)
hash
.
update
(
' '
.
join
(
filenames
))
hash
.
update
(
' '
.
join
(
filenames
)
.
encode
()
)
for
name
in
filenames
:
for
name
in
filenames
:
hash
.
update
(
open
(
os
.
path
.
join
(
dirpath
,
name
)).
read
())
hash
.
update
(
open
(
os
.
path
.
join
(
dirpath
,
name
)
,
'rb'
).
read
())
_dir_hashes
[
dir
]
=
dir_hash
=
hash
.
digest
().
encode
(
'base64'
).
strip
()
_dir_hashes
[
dir
]
=
dir_hash
=
hash
.
hexdigest
()
return
dir_hash
return
dir_hash
def
_dists_sig
(
dists
):
def
_dists_sig
(
dists
):
...
@@ -1444,7 +1439,7 @@ def _dists_sig(dists):
...
@@ -1444,7 +1439,7 @@ def _dists_sig(dists):
def
_update_section
(
s1
,
s2
):
def
_update_section
(
s1
,
s2
):
s2
=
s2
.
copy
()
# avoid mutating the second argument, which is unexpected
s2
=
s2
.
copy
()
# avoid mutating the second argument, which is unexpected
for
k
,
v
in
s2
.
items
(
):
for
k
,
v
in
list
(
s2
.
items
()
):
v2
,
note2
=
v
v2
,
note2
=
v
if
k
.
endswith
(
'+'
):
if
k
.
endswith
(
'+'
):
key
=
k
.
rstrip
(
' +'
)
key
=
k
.
rstrip
(
' +'
)
...
@@ -1631,7 +1626,7 @@ Commands:
...
@@ -1631,7 +1626,7 @@ Commands:
"""
"""
def
_help
():
def
_help
():
print
_usage
print
_
(
_usage
)
sys
.
exit
(
0
)
sys
.
exit
(
0
)
def
main
(
args
=
None
):
def
main
(
args
=
None
):
...
@@ -1728,7 +1723,8 @@ def main(args=None):
...
@@ -1728,7 +1723,8 @@ def main(args=None):
getattr
(
buildout
,
command
)(
args
)
getattr
(
buildout
,
command
)(
args
)
except
SystemExit
:
except
SystemExit
:
pass
pass
except
Exception
,
v
:
except
Exception
:
v
=
sys
.
exc_info
()[
1
]
_doing
()
_doing
()
exc_info
=
sys
.
exc_info
()
exc_info
=
sys
.
exc_info
()
import
pdb
,
traceback
import
pdb
,
traceback
...
@@ -1738,7 +1734,7 @@ def main(args=None):
...
@@ -1738,7 +1734,7 @@ def main(args=None):
pdb
.
post_mortem
(
exc_info
[
2
])
pdb
.
post_mortem
(
exc_info
[
2
])
else
:
else
:
if
isinstance
(
v
,
(
zc
.
buildout
.
UserError
,
if
isinstance
(
v
,
(
zc
.
buildout
.
UserError
,
distutils
.
errors
.
DistutilsError
,
distutils
.
errors
.
DistutilsError
)
)
):
):
_error
(
str
(
v
))
_error
(
str
(
v
))
...
...
src/zc/buildout/buildout.txt
View file @
83d53da5
...
@@ -284,7 +284,7 @@ buildout:
...
@@ -284,7 +284,7 @@ buildout:
>>> import os
>>> import os
>>> os.chdir(sample_buildout)
>>> os.chdir(sample_buildout)
>>> buildout = os.path.join(sample_buildout, 'bin', 'buildout')
>>> buildout = os.path.join(sample_buildout, 'bin', 'buildout')
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing data-dir.
Installing data-dir.
data-dir: Creating directory mystuff
data-dir: Creating directory mystuff
...
@@ -333,7 +333,7 @@ we'll see that the directory gets removed and recreated:
...
@@ -333,7 +333,7 @@ we'll see that the directory gets removed and recreated:
... path = mydata
... path = mydata
... """)
... """)
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling data-dir.
Uninstalling data-dir.
Installing data-dir.
Installing data-dir.
...
@@ -353,7 +353,7 @@ If any of the files or directories created by a recipe are removed,
...
@@ -353,7 +353,7 @@ If any of the files or directories created by a recipe are removed,
the part will be reinstalled:
the part will be reinstalled:
>>> rmdir(sample_buildout, 'mydata')
>>> rmdir(sample_buildout, 'mydata')
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling data-dir.
Uninstalling data-dir.
Installing data-dir.
Installing data-dir.
...
@@ -384,7 +384,7 @@ non-existent directory to create the directory in:
...
@@ -384,7 +384,7 @@ non-existent directory to create the directory in:
We'll get a user error, not a traceback.
We'll get a user error, not a traceback.
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
data-dir: Cannot create /xxx/mydata. /xxx is not a directory.
data-dir: Cannot create /xxx/mydata. /xxx is not a directory.
While:
While:
...
@@ -449,7 +449,7 @@ leave previously created paths in place:
...
@@ -449,7 +449,7 @@ leave previously created paths in place:
... path = foo bin
... path = foo bin
... """)
... """)
>>> print
system(buildout),
# doctest: +ELLIPSIS
>>> print
_(system(buildout))
# doctest: +ELLIPSIS
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling data-dir.
Uninstalling data-dir.
Installing data-dir.
Installing data-dir.
...
@@ -483,7 +483,7 @@ If we fix the typo:
...
@@ -483,7 +483,7 @@ If we fix the typo:
... path = foo bins
... path = foo bins
... """)
... """)
>>> print
system(buildout),
# doctest: +ELLIPSIS
>>> print
_(system(buildout))
# doctest: +ELLIPSIS
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing data-dir.
Installing data-dir.
data-dir: Creating directory foo
data-dir: Creating directory foo
...
@@ -565,7 +565,7 @@ And put back the typo:
...
@@ -565,7 +565,7 @@ And put back the typo:
When we rerun the buildout:
When we rerun the buildout:
>>> print
system(buildout),
# doctest: +ELLIPSIS
>>> print
_(system(buildout))
# doctest: +ELLIPSIS
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing data-dir.
Installing data-dir.
data-dir: Creating directory foo
data-dir: Creating directory foo
...
@@ -638,7 +638,12 @@ recipe:
...
@@ -638,7 +638,12 @@ recipe:
..
..
>>> remove(sample_buildout, 'recipes', 'mkdir.pyc')
>>> for path in (
... join(sample_buildout, 'recipes', 'mkdir.pyc'),
... join(sample_buildout, 'recipes', '__pycache__', 'mkdir.pyc'),
... ):
... if os.path.exists(path):
... remove(path)
We returned by calling created, taking advantage of the fact that it
We returned by calling created, taking advantage of the fact that it
returns the registered paths. We did this for illustrative purposes.
returns the registered paths. We did this for illustrative purposes.
...
@@ -647,7 +652,7 @@ It would be simpler just to return the paths as before.
...
@@ -647,7 +652,7 @@ It would be simpler just to return the paths as before.
If we rerun the buildout, again, we'll get the error and no
If we rerun the buildout, again, we'll get the error and no
directories will be created:
directories will be created:
>>> print
system(buildout),
# doctest: +ELLIPSIS
>>> print
_(system(buildout))
# doctest: +ELLIPSIS
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing data-dir.
Installing data-dir.
data-dir: Creating directory foo
data-dir: Creating directory foo
...
@@ -677,7 +682,7 @@ Now, we'll fix the typo again and we'll get the directories we expect:
...
@@ -677,7 +682,7 @@ Now, we'll fix the typo again and we'll get the directories we expect:
... path = foo bins
... path = foo bins
... """)
... """)
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing data-dir.
Installing data-dir.
data-dir: Creating directory foo
data-dir: Creating directory foo
...
@@ -724,7 +729,7 @@ all key-value pairs are displayed, sorted alphabetically, along with
...
@@ -724,7 +729,7 @@ all key-value pairs are displayed, sorted alphabetically, along with
the origin of the value (file name or COMPUTED_VALUE, DEFAULT_VALUE,
the origin of the value (file name or COMPUTED_VALUE, DEFAULT_VALUE,
COMMAND_LINE_VALUE).
COMMAND_LINE_VALUE).
>>> print
system(buildout+ ' annotate'),
>>> print
_(system(buildout+ ' annotate'), end='')
... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
<BLANKLINE>
<BLANKLINE>
Annotated sections
Annotated sections
...
@@ -790,6 +795,7 @@ allow us to see interactions with the buildout:
...
@@ -790,6 +795,7 @@ allow us to see interactions with the buildout:
>>> write(sample_buildout, 'recipes', 'debug.py',
>>> write(sample_buildout, 'recipes', 'debug.py',
... """
... """
... import sys
... class Debug:
... class Debug:
...
...
... def __init__(self, buildout, name, options):
... def __init__(self, buildout, name, options):
...
@@ -798,10 +804,8 @@ allow us to see interactions with the buildout:
...
@@ -798,10 +804,8 @@ allow us to see interactions with the buildout:
... self.options = options
... self.options = options
...
...
... def install(self):
... def install(self):
... items = self.options.items()
... for option, value in sorted(self.options.items()):
... items.sort()
... sys.stdout.write('%s %s\\n' % (option, value))
... for option, value in items:
... print option, value
... return ()
... return ()
...
...
... update = install
... update = install
...
@@ -857,7 +861,7 @@ and option name joined by a colon.
...
@@ -857,7 +861,7 @@ and option name joined by a colon.
Now, if we run the buildout, we'll see the options with the values
Now, if we run the buildout, we'll see the options with the values
substituted.
substituted.
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling data-dir.
Uninstalling data-dir.
Installing data-dir.
Installing data-dir.
...
@@ -876,7 +880,7 @@ The buildout system didn't know if this module could effect the mkdir
...
@@ -876,7 +880,7 @@ The buildout system didn't know if this module could effect the mkdir
recipe, so it assumed it could and reinstalled mydata. If we rerun
recipe, so it assumed it could and reinstalled mydata. If we rerun
the buildout:
the buildout:
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Updating data-dir.
Updating data-dir.
Updating debug.
Updating debug.
...
@@ -915,7 +919,7 @@ _buildout_section_name_ to get the current section name.
...
@@ -915,7 +919,7 @@ _buildout_section_name_ to get the current section name.
... path = mydata
... path = mydata
... """)
... """)
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Uninstalling debug.
Updating data-dir.
Updating data-dir.
...
@@ -953,7 +957,7 @@ example, we can leave data-dir out of the parts list:
...
@@ -953,7 +957,7 @@ example, we can leave data-dir out of the parts list:
It will still be treated as a part:
It will still be treated as a part:
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Uninstalling debug.
Updating data-dir.
Updating data-dir.
...
@@ -992,7 +996,7 @@ the data-dir part after the debug part, it will be included before:
...
@@ -992,7 +996,7 @@ the data-dir part after the debug part, it will be included before:
It will still be treated as a part:
It will still be treated as a part:
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Updating data-dir.
Updating data-dir.
Updating debug.
Updating debug.
...
@@ -1041,7 +1045,7 @@ of the current section allows sections to be used as macros.
...
@@ -1041,7 +1045,7 @@ of the current section allows sections to be used as macros.
... path = mydata
... path = mydata
... """)
... """)
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Uninstalling debug.
Uninstalling data-dir.
Uninstalling data-dir.
...
@@ -1132,9 +1136,11 @@ extension that prints out the options.
...
@@ -1132,9 +1136,11 @@ extension that prints out the options.
>>> mkdir(sample_buildout, 'demo')
>>> mkdir(sample_buildout, 'demo')
>>> write(sample_buildout, 'demo', 'demo.py',
>>> write(sample_buildout, 'demo', 'demo.py',
... """
... """
... import sys
... def ext(buildout):
... def ext(buildout):
... print [part['option'] for name, part in buildout.items() \
... sys.stdout.write(str(
... if name.startswith('part')]
... [part['option'] for name, part in buildout.items()
... if name.startswith('part')])+'\\n')
... """)
... """)
>>> write(sample_buildout, 'demo', 'setup.py',
>>> write(sample_buildout, 'demo', 'setup.py',
...
@@ -1157,13 +1163,9 @@ Set up a buildout configuration for this extension.
...
@@ -1157,13 +1163,9 @@ Set up a buildout configuration for this extension.
... """)
... """)
>>> os.chdir(sample_buildout)
>>> os.chdir(sample_buildout)
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
>>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout')), end='')
Develop: '/sample-buildout/demo'
... # doctest: +ELLIPSIS
Uninstalling myfiles.
Develop: '/sample-buildout/demo'...
Getting distribution for 'recipes'.
zip_safe flag not set; analyzing archive contents...
Got recipes 0.0.0.
warning: install_lib: 'build/lib' does not exist -- no Python modules to install
Verify option values.
Verify option values.
...
@@ -1175,14 +1177,14 @@ Verify option values.
...
@@ -1175,14 +1177,14 @@ Verify option values.
... extends = extension2.cfg
... extends = extension2.cfg
... """)
... """)
>>> print
system(os.path.join('bin', 'buildout')),
>>> print
_(system(os.path.join('bin', 'buildout')), end='')
['a1 a2/na3 a4/na5', 'b1 b2 b3 b4', 'c1 c2/nc3 c4 c5', 'h1 h2']
['a1 a2/na3 a4/na5', 'b1 b2 b3 b4', 'c1 c2/nc3 c4 c5', 'h1 h2']
Develop: '/sample-buildout/demo'
Develop: '/sample-buildout/demo'
Annotated sections output shows which files are responsible for which
Annotated sections output shows which files are responsible for which
operations.
operations.
>>> print
system(os.path.join('bin', 'buildout') + ' annotate'),
>>> print
_(system(os.path.join('bin', 'buildout') + ' annotate'), end='')
... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
<BLANKLINE>
<BLANKLINE>
Annotated sections
Annotated sections
...
@@ -1258,7 +1260,7 @@ To see how this works, we use an example:
...
@@ -1258,7 +1260,7 @@ To see how this works, we use an example:
... op = base
... op = base
... """)
... """)
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing debug.
Installing debug.
op buildout
op buildout
...
@@ -1328,7 +1330,7 @@ Here is a more elaborate example.
...
@@ -1328,7 +1330,7 @@ Here is a more elaborate example.
... name = base
... name = base
... """)
... """)
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Uninstalling debug.
Installing debug.
Installing debug.
...
@@ -1390,7 +1392,7 @@ we'll set up a web server with some configuration files.
...
@@ -1390,7 +1392,7 @@ we'll set up a web server with some configuration files.
... """ % dict(url=server_url))
... """ % dict(url=server_url))
>>> print
system(buildout+ ' -c client.cfg'),
>>> print
_(system(buildout+ ' -c client.cfg'), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Uninstalling debug.
Installing debug.
Installing debug.
...
@@ -1421,7 +1423,7 @@ buildout.
...
@@ -1421,7 +1423,7 @@ buildout.
... name = remote
... name = remote
... """)
... """)
>>> print
system(buildout + ' -c ' + server_url + '/remote.cfg'),
>>> print
_(system(buildout + ' -c ' + server_url + '/remote.cfg'), end='')
While:
While:
Initializing.
Initializing.
Error: Missing option: buildout:directory
Error: Missing option: buildout:directory
...
@@ -1431,10 +1433,10 @@ containing a configuration file. This won't work for configuration
...
@@ -1431,10 +1433,10 @@ containing a configuration file. This won't work for configuration
files loaded from URLs. In this case, the buildout directory would
files loaded from URLs. In this case, the buildout directory would
normally be defined on the command line:
normally be defined on the command line:
>>> print
system(buildout
>>> print
_(
system(buildout
... + ' -c ' + server_url + '/remote.cfg'
... + ' -c ' + server_url + '/remote.cfg'
... + ' buildout:directory=' + sample_buildout
... + ' buildout:directory=' + sample_buildout
... ),
... ),
end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Uninstalling debug.
Installing debug.
Installing debug.
...
@@ -1463,7 +1465,7 @@ delimiter.)
...
@@ -1463,7 +1465,7 @@ delimiter.)
... """)
... """)
>>> os.environ['HOME'] = home
>>> os.environ['HOME'] = home
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Uninstalling debug.
Installing debug.
Installing debug.
...
@@ -1480,7 +1482,7 @@ delimiter.)
...
@@ -1480,7 +1482,7 @@ delimiter.)
A buildout command-line argument, -U, can be used to suppress reading
A buildout command-line argument, -U, can be used to suppress reading
user defaults:
user defaults:
>>> print
system(buildout + ' -U'),
>>> print
_(system(buildout + ' -U'), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Uninstalling debug.
Installing debug.
Installing debug.
...
@@ -1509,7 +1511,7 @@ set the logging level to WARNING
...
@@ -1509,7 +1511,7 @@ set the logging level to WARNING
... extends = b1.cfg b2.cfg
... extends = b1.cfg b2.cfg
... """)
... """)
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
name base
name base
op1 b1 1
op1 b1 1
op2 b2 2
op2 b2 2
...
@@ -1534,7 +1536,7 @@ configured in the buildout section. Its value is configured in seconds.
...
@@ -1534,7 +1536,7 @@ configured in the buildout section. Its value is configured in seconds.
... op = timeout
... op = timeout
... """)
... """)
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Setting socket time out to 5 seconds.
Setting socket time out to 5 seconds.
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Uninstalling debug.
...
@@ -1557,7 +1559,7 @@ timeout of the Python socket module is used.
...
@@ -1557,7 +1559,7 @@ timeout of the Python socket module is used.
... op = timeout
... op = timeout
... """)
... """)
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Default socket timeout is used !
Default socket timeout is used !
Value in configuration is not numeric: [5s].
Value in configuration is not numeric: [5s].
<BLANKLINE>
<BLANKLINE>
...
@@ -1594,6 +1596,7 @@ with an uninstall recipe that simulates removing the service.
...
@@ -1594,6 +1596,7 @@ with an uninstall recipe that simulates removing the service.
>>> write(sample_buildout, 'recipes', 'service.py',
>>> write(sample_buildout, 'recipes', 'service.py',
... """
... """
... import sys
... class Service:
... class Service:
...
...
... def __init__(self, buildout, name, options):
... def __init__(self, buildout, name, options):
...
@@ -1602,7 +1605,8 @@ with an uninstall recipe that simulates removing the service.
...
@@ -1602,7 +1605,8 @@ with an uninstall recipe that simulates removing the service.
... self.options = options
... self.options = options
...
...
... def install(self):
... def install(self):
... print "chkconfig --add %s" % self.options['script']
... sys.stdout.write("chkconfig --add %s\\n"
... % self.options['script'])
... return ()
... return ()
...
...
... def update(self):
... def update(self):
...
@@ -1610,7 +1614,7 @@ with an uninstall recipe that simulates removing the service.
...
@@ -1610,7 +1614,7 @@ with an uninstall recipe that simulates removing the service.
...
...
...
...
... def uninstall_service(name, options):
... def uninstall_service(name, options):
...
print "chkconfig --del %s" % options['script']
...
sys.stdout.write("chkconfig --del %s\\n" % options['script'])
... """)
... """)
To use these recipes we must register them using entry points. Make
To use these recipes we must register them using entry points. Make
...
@@ -1649,20 +1653,18 @@ Here's how these recipes could be used in a buildout:
...
@@ -1649,20 +1653,18 @@ Here's how these recipes could be used in a buildout:
When the buildout is run the service will be installed
When the buildout is run the service will be installed
>>> print
system(buildout
)
>>> print
_(system(buildout), end=''
)
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Uninstalling debug.
Installing service.
Installing service.
chkconfig --add /path/to/script
chkconfig --add /path/to/script
<BLANKLINE>
The service has been installed. If the buildout is run again with no
The service has been installed. If the buildout is run again with no
changes, the service shouldn't be changed.
changes, the service shouldn't be changed.
>>> print
system(buildout
)
>>> print
_(system(buildout), end=''
)
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Updating service.
Updating service.
<BLANKLINE>
Now we change the service part to trigger uninstallation and
Now we change the service part to trigger uninstallation and
re-installation.
re-installation.
...
@@ -1678,14 +1680,13 @@ re-installation.
...
@@ -1678,14 +1680,13 @@ re-installation.
... script = /path/to/a/different/script
... script = /path/to/a/different/script
... """)
... """)
>>> print
system(buildout
)
>>> print
_(system(buildout), end=''
)
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling service.
Uninstalling service.
Running uninstall recipe.
Running uninstall recipe.
chkconfig --del /path/to/script
chkconfig --del /path/to/script
Installing service.
Installing service.
chkconfig --add /path/to/a/different/script
chkconfig --add /path/to/a/different/script
<BLANKLINE>
Now we remove the service part, and add another part.
Now we remove the service part, and add another part.
...
@@ -1699,14 +1700,13 @@ Now we remove the service part, and add another part.
...
@@ -1699,14 +1700,13 @@ Now we remove the service part, and add another part.
... recipe = recipes:debug
... recipe = recipes:debug
... """)
... """)
>>> print
system(buildout
)
>>> print
_(system(buildout), end=''
)
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling service.
Uninstalling service.
Running uninstall recipe.
Running uninstall recipe.
chkconfig --del /path/to/a/different/script
chkconfig --del /path/to/a/different/script
Installing debug.
Installing debug.
recipe recipes:debug
recipe recipes:debug
<BLANKLINE>
Uninstall recipes don't have to take care of removing all the files
Uninstall recipes don't have to take care of removing all the files
and directories created by the part. This is still done automatically,
and directories created by the part. This is still done automatically,
...
@@ -1720,11 +1720,12 @@ mkdir recipe introduced earlier.
...
@@ -1720,11 +1720,12 @@ mkdir recipe introduced earlier.
>>> write(sample_buildout, 'recipes', 'backup.py',
>>> write(sample_buildout, 'recipes', 'backup.py',
... """
... """
... import os
... import os
, sys
... def backup_directory(name, options):
... def backup_directory(name, options):
... path = options['path']
... path = options['path']
... size = len(os.listdir(path))
... size = len(os.listdir(path))
... print "backing up directory %s of size %s" % (path, size)
... sys.stdout.write("backing up directory %s of size %s\\n"
... % (path, size))
... """)
... """)
It must be registered with the zc.buildout.uninstall entry
It must be registered with the zc.buildout.uninstall entry
...
@@ -1766,14 +1767,13 @@ Now we can use it with a mkdir part.
...
@@ -1766,14 +1767,13 @@ Now we can use it with a mkdir part.
Run the buildout to install the part.
Run the buildout to install the part.
>>> print
system(buildout
)
>>> print
_(system(buildout), end=''
)
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Uninstalling debug.
Installing dir.
Installing dir.
dir: Creating directory my_directory
dir: Creating directory my_directory
Installing debug.
Installing debug.
recipe recipes:debug
recipe recipes:debug
<BLANKLINE>
Now we remove the part from the configuration file.
Now we remove the part from the configuration file.
...
@@ -1790,14 +1790,13 @@ Now we remove the part from the configuration file.
...
@@ -1790,14 +1790,13 @@ Now we remove the part from the configuration file.
When the buildout is run the part is removed, and the uninstall recipe
When the buildout is run the part is removed, and the uninstall recipe
is run before the directory is deleted.
is run before the directory is deleted.
>>> print
system(buildout
)
>>> print
_(system(buildout), end=''
)
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling dir.
Uninstalling dir.
Running uninstall recipe.
Running uninstall recipe.
backing up directory /sample-buildout/my_directory of size 0
backing up directory /sample-buildout/my_directory of size 0
Updating debug.
Updating debug.
recipe recipes:debug
recipe recipes:debug
<BLANKLINE>
Now we will return the registration to normal for the benefit of the
Now we will return the registration to normal for the benefit of the
rest of the examples.
rest of the examples.
...
@@ -1895,7 +1894,7 @@ Here's an example:
...
@@ -1895,7 +1894,7 @@ Here's an example:
Note that we used the installed buildout option to specify an
Note that we used the installed buildout option to specify an
alternate file to store information about installed parts.
alternate file to store information about installed parts.
>>> print
system(buildout+' -c other.cfg debug:op1=foo -v'),
>>> print
_(system(buildout+' -c other.cfg debug:op1=foo -v'), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing debug.
Installing debug.
name other
name other
...
@@ -1908,7 +1907,7 @@ WARNING.
...
@@ -1908,7 +1907,7 @@ WARNING.
Options can also be combined in the usual Unix way, as in:
Options can also be combined in the usual Unix way, as in:
>>> print
system(buildout+' -vcother.cfg debug:op1=foo'),
>>> print
_(system(buildout+' -vcother.cfg debug:op1=foo'), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Updating debug.
Updating debug.
name other
name other
...
@@ -1949,7 +1948,7 @@ the buildout in the usual way:
...
@@ -1949,7 +1948,7 @@ the buildout in the usual way:
... recipe = recipes:debug
... recipe = recipes:debug
... """)
... """)
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling debug.
Uninstalling debug.
Installing debug.
Installing debug.
...
@@ -2033,7 +2032,7 @@ Now we'll update our configuration file:
...
@@ -2033,7 +2032,7 @@ Now we'll update our configuration file:
and run the buildout specifying just d3 and d4:
and run the buildout specifying just d3 and d4:
>>> print
system(buildout+' install d3 d4'),
>>> print
_(system(buildout+' install d3 d4'), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling d3.
Uninstalling d3.
Installing d3.
Installing d3.
...
@@ -2104,7 +2103,7 @@ directories are still there.
...
@@ -2104,7 +2103,7 @@ directories are still there.
Now, if we run the buildout without the install command:
Now, if we run the buildout without the install command:
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling d2.
Uninstalling d2.
Uninstalling d1.
Uninstalling d1.
...
@@ -2161,7 +2160,7 @@ provide alternate locations, and even names for these directories.
...
@@ -2161,7 +2160,7 @@ provide alternate locations, and even names for these directories.
... work = os.path.join(alt, 'work'),
... work = os.path.join(alt, 'work'),
... ))
... ))
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Creating directory '/sample-alt/scripts'.
Creating directory '/sample-alt/scripts'.
Creating directory '/sample-alt/work'.
Creating directory '/sample-alt/work'.
Creating directory '/sample-alt/basket'.
Creating directory '/sample-alt/basket'.
...
@@ -2197,7 +2196,7 @@ You can also specify an alternate buildout directory:
...
@@ -2197,7 +2196,7 @@ You can also specify an alternate buildout directory:
... recipes=os.path.join(sample_buildout, 'recipes'),
... recipes=os.path.join(sample_buildout, 'recipes'),
... ))
... ))
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Creating directory '/sample-alt/bin'.
Creating directory '/sample-alt/bin'.
Creating directory '/sample-alt/parts'.
Creating directory '/sample-alt/parts'.
Creating directory '/sample-alt/eggs'.
Creating directory '/sample-alt/eggs'.
...
@@ -2249,7 +2248,7 @@ can be a numeric value and that the verbosity can be specified in the
...
@@ -2249,7 +2248,7 @@ can be a numeric value and that the verbosity can be specified in the
configuration file. Because the verbosity is subtracted from the log
configuration file. Because the verbosity is subtracted from the log
level, we get a final log level of 20, which is the INFO level.
level, we get a final log level of 20, which is the INFO level.
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
INFO Develop: '/sample-buildout/recipes'
INFO Develop: '/sample-buildout/recipes'
Predefined buildout options
Predefined buildout options
...
@@ -2267,7 +2266,7 @@ database is shown.
...
@@ -2267,7 +2266,7 @@ database is shown.
... parts =
... parts =
... """)
... """)
>>> print
system(buildout+' -vv'),
# doctest: +NORMALIZE_WHITESPACE
>>> print
_(system(buildout+' -vv'), end='')
# doctest: +NORMALIZE_WHITESPACE
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout', 'distribute'.
We have a develop egg: zc.buildout 1.0.0.
We have a develop egg: zc.buildout 1.0.0.
We have the best distribution that satisfies 'distribute'.
We have the best distribution that satisfies 'distribute'.
...
@@ -2492,9 +2491,9 @@ local buildout scripts.
...
@@ -2492,9 +2491,9 @@ local buildout scripts.
>>> sample_bootstrapped = tmpdir('sample-bootstrapped')
>>> sample_bootstrapped = tmpdir('sample-bootstrapped')
>>> print
system(buildout
>>> print
_(
system(buildout
... +' -c'+os.path.join(sample_bootstrapped, 'setup.cfg')
... +' -c'+os.path.join(sample_bootstrapped, 'setup.cfg')
... +' init'),
... +' init'),
end='')
Creating '/sample-bootstrapped/setup.cfg'.
Creating '/sample-bootstrapped/setup.cfg'.
Creating directory '/sample-bootstrapped/bin'.
Creating directory '/sample-bootstrapped/bin'.
Creating directory '/sample-bootstrapped/parts'.
Creating directory '/sample-bootstrapped/parts'.
...
@@ -2541,9 +2540,9 @@ if there isn't a configuration file:
...
@@ -2541,9 +2540,9 @@ if there isn't a configuration file:
>>> sample_bootstrapped2 = tmpdir('sample-bootstrapped2')
>>> sample_bootstrapped2 = tmpdir('sample-bootstrapped2')
>>> print
system(buildout
>>> print
_(
system(buildout
... +' -c'+os.path.join(sample_bootstrapped2, 'setup.cfg')
... +' -c'+os.path.join(sample_bootstrapped2, 'setup.cfg')
... +' bootstrap'),
... +' bootstrap'),
end='')
While:
While:
Initializing.
Initializing.
Error: Couldn't open /sample-bootstrapped2/setup.cfg
Error: Couldn't open /sample-bootstrapped2/setup.cfg
...
@@ -2554,9 +2553,9 @@ if there isn't a configuration file:
...
@@ -2554,9 +2553,9 @@ if there isn't a configuration file:
... parts =
... parts =
... """)
... """)
>>> print
system(buildout
>>> print
_(
system(buildout
... +' -c'+os.path.join(sample_bootstrapped2, 'setup.cfg')
... +' -c'+os.path.join(sample_bootstrapped2, 'setup.cfg')
... +' bootstrap'),
... +' bootstrap'),
end='')
Creating directory '/sample-bootstrapped2/bin'.
Creating directory '/sample-bootstrapped2/bin'.
Creating directory '/sample-bootstrapped2/parts'.
Creating directory '/sample-bootstrapped2/parts'.
Creating directory '/sample-bootstrapped2/eggs'.
Creating directory '/sample-bootstrapped2/eggs'.
...
@@ -2567,9 +2566,9 @@ Similarly, if there is a configuration file and we use the init
...
@@ -2567,9 +2566,9 @@ Similarly, if there is a configuration file and we use the init
command, we'll get an error that the configuration file already
command, we'll get an error that the configuration file already
exists:
exists:
>>> print
system(buildout
>>> print
_(
system(buildout
... +' -c'+os.path.join(sample_bootstrapped, 'setup.cfg')
... +' -c'+os.path.join(sample_bootstrapped, 'setup.cfg')
... +' init'),
... +' init'),
end='')
While:
While:
Initializing.
Initializing.
Error: '/sample-bootstrapped/setup.cfg' already exists.
Error: '/sample-bootstrapped/setup.cfg' already exists.
...
@@ -2583,7 +2582,7 @@ or paths to use:
...
@@ -2583,7 +2582,7 @@ or paths to use:
>>> cd(sample_bootstrapped)
>>> cd(sample_bootstrapped)
>>> remove('setup.cfg')
>>> remove('setup.cfg')
>>> remove('bin', 'buildout')
>>> remove('bin', 'buildout')
>>> print
system(buildout + ' -csetup.cfg init demo other ./src'),
>>> print
_(system(buildout + ' -csetup.cfg init demo other ./src'), end='')
Creating '/sample-bootstrapped/setup.cfg'.
Creating '/sample-bootstrapped/setup.cfg'.
Generated script '/sample-bootstrapped/bin/buildout'.
Generated script '/sample-bootstrapped/bin/buildout'.
Getting distribution for 'zc.recipe.egg'.
Getting distribution for 'zc.recipe.egg'.
...
@@ -2642,7 +2641,7 @@ for us:
...
@@ -2642,7 +2641,7 @@ for us:
>>> cd(sample_bootstrapped)
>>> cd(sample_bootstrapped)
>>> _ = system(buildout + ' -csetup.cfg buildout:parts=')
>>> _ = system(buildout + ' -csetup.cfg buildout:parts=')
>>> remove('setup.cfg')
>>> remove('setup.cfg')
>>> print
system(buildout + ' -csetup.cfg init demo other ./src'),
>>> print
_(system(buildout + ' -csetup.cfg init demo other ./src'), end='')
Creating '/sample-bootstrapped/setup.cfg'.
Creating '/sample-bootstrapped/setup.cfg'.
Installing py.
Installing py.
Generated script '/sample-bootstrapped/bin/demo'.
Generated script '/sample-bootstrapped/bin/demo'.
...
@@ -2692,7 +2691,7 @@ or on the command line:
...
@@ -2692,7 +2691,7 @@ or on the command line:
... recipe = recipes:debug
... recipe = recipes:debug
... """)
... """)
>>> print
system(buildout+' buildout:installed=inst.cfg'),
>>> print
_(system(buildout+' buildout:installed=inst.cfg'), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing debug.
Installing debug.
recipe recipes:debug
recipe recipes:debug
...
@@ -2714,7 +2713,7 @@ The installation database can be disabled by supplying an empty
...
@@ -2714,7 +2713,7 @@ The installation database can be disabled by supplying an empty
buildout installed option:
buildout installed option:
>>> os.remove('inst.cfg')
>>> os.remove('inst.cfg')
>>> print
system(buildout+' buildout:installed='),
>>> print
_(system(buildout+' buildout:installed='), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing debug.
Installing debug.
recipe recipes:debug
recipe recipes:debug
...
@@ -2740,7 +2739,7 @@ Note that there will be no installation database if there are no parts:
...
@@ -2740,7 +2739,7 @@ Note that there will be no installation database if there are no parts:
... parts =
... parts =
... """)
... """)
>>> print
system(buildout+' buildout:installed=inst.cfg'),
>>> print
_(system(buildout+' buildout:installed=inst.cfg'), end='')
>>> ls(sample_buildout)
>>> ls(sample_buildout)
- b1.cfg
- b1.cfg
...
@@ -2776,10 +2775,11 @@ previous section:
...
@@ -2776,10 +2775,11 @@ previous section:
>>> write(sample_bootstrapped, 'demo', 'demo.py',
>>> write(sample_bootstrapped, 'demo', 'demo.py',
... """
... """
... import sys
... def ext(buildout):
... def ext(buildout):
...
print 'ext', list(buildout
)
...
sys.stdout.write('%s %s\\n' % ('ext', list(buildout))
)
... def unload(buildout):
... def unload(buildout):
...
print 'unload', list(buildout
)
...
sys.stdout.write('%s %s\\n' % ('unload', list(buildout))
)
... """)
... """)
>>> write(sample_bootstrapped, 'demo', 'setup.py',
>>> write(sample_bootstrapped, 'demo', 'setup.py',
...
@@ -2809,7 +2809,8 @@ egg to be built:
...
@@ -2809,7 +2809,8 @@ egg to be built:
... """)
... """)
>>> os.chdir(sample_bootstrapped)
>>> os.chdir(sample_bootstrapped)
>>> print system(os.path.join(sample_bootstrapped, 'bin', 'buildout')),
>>> print_(system(os.path.join(sample_bootstrapped, 'bin', 'buildout')),
... end='')
Develop: '/sample-bootstrapped/demo'
Develop: '/sample-bootstrapped/demo'
Now we can add the extensions option. We were a bit tricky and ran
Now we can add the extensions option. We were a bit tricky and ran
...
@@ -2829,7 +2830,8 @@ the network, we wouldn't need to do anything special.
...
@@ -2829,7 +2830,8 @@ the network, we wouldn't need to do anything special.
We see that our extension is loaded and executed:
We see that our extension is loaded and executed:
>>> print system(os.path.join(sample_bootstrapped, 'bin', 'buildout')),
>>> print_(system(os.path.join(sample_bootstrapped, 'bin', 'buildout')),
... end='')
ext ['buildout']
ext ['buildout']
Develop: '/sample-bootstrapped/demo'
Develop: '/sample-bootstrapped/demo'
unload ['buildout']
unload ['buildout']
src/zc/buildout/configparser.py
0 → 100644
View file @
83d53da5
##############################################################################
#
# Copyright Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
# The following copied from Python 2 config parser because:
# - The py3 configparser isn't backward compatible
# - Both strip option values in undesireable ways
# - dict of dicts is a much simpler api
import
re
class
Error
(
Exception
):
"""Base class for ConfigParser exceptions."""
def
_get_message
(
self
):
"""Getter for 'message'; needed only to override deprecation in
BaseException."""
return
self
.
__message
def
_set_message
(
self
,
value
):
"""Setter for 'message'; needed only to override deprecation in
BaseException."""
self
.
__message
=
value
# BaseException.message has been deprecated since Python 2.6. To prevent
# DeprecationWarning from popping up over this pre-existing attribute, use
# a new property that takes lookup precedence.
message
=
property
(
_get_message
,
_set_message
)
def
__init__
(
self
,
msg
=
''
):
self
.
message
=
msg
Exception
.
__init__
(
self
,
msg
)
def
__repr__
(
self
):
return
self
.
message
class
ParsingError
(
Error
):
"""Raised when a configuration file does not follow legal syntax."""
def
__init__
(
self
,
filename
):
Error
.
__init__
(
self
,
'File contains parsing errors: %s'
%
filename
)
self
.
filename
=
filename
self
.
errors
=
[]
def
append
(
self
,
lineno
,
line
):
self
.
errors
.
append
((
lineno
,
line
))
self
.
message
+=
'
\
n
\
t
[line %2d]: %s'
%
(
lineno
,
line
)
class
MissingSectionHeaderError
(
ParsingError
):
"""Raised when a key-value pair is found before any section header."""
def
__init__
(
self
,
filename
,
lineno
,
line
):
Error
.
__init__
(
self
,
'File contains no section headers.
\
n
file: %s, line: %d
\
n
%r'
%
(
filename
,
lineno
,
line
))
self
.
filename
=
filename
self
.
lineno
=
lineno
self
.
line
=
line
SECTCRE
=
re
.
compile
(
r'\
[
' # [
r'
(
?
P
<
header
>
[
^
]]
+
)
' # very permissive!
r'
\
]
' # ]
)
OPTCRE = re.compile(
r'
(
?
P
<
option
>
[
^
:
=
\
s
][
^
:
=
]
*
)
' # very permissive!
r'
\
s
*
(
?
P
<
vi
>
[:
=
])
\
s
*
' # any number of space/tab,
# followed by separator
# (either : or =), followed
# by any # space/tab
r'
(
?
P
<
value
>
.
*
)
$
' # everything up to eol
)
def parse(fp, fpname):
"""Parse a sectioned setup file.
The sections in setup file contains a title line at the top,
indicated by a name in square brackets (`[]'
),
plus
key
/
value
options
lines
,
indicated
by
`
name
:
value
' format lines.
Continuations are represented by an embedded newline then
leading whitespace. Blank lines, lines beginning with a '
#',
and
just
about
everything
else
are
ignored
.
"""
_sections = {}
cursect = None # None, or a dictionary
optname = None
lineno = 0
e = None # None, or an exception
while True:
line = fp.readline()
if not line:
break
lineno = lineno + 1
# comment or blank line?
if line.strip() == '' or line[0] in '#;':
continue
if line.split(None, 1)[0].lower() == 'rem' and line[0] in "rR":
# no leading whitespace
continue
# continuation line?
if line[0].isspace() and cursect is not None and optname:
value = line.strip()
if value:
cursect[optname] = "%s
\
n
%s" % (cursect[optname], value)
# a section header or option header?
else:
# is it a section header?
mo = SECTCRE.match(line)
if mo:
sectname = mo.group('header')
if sectname in _sections:
cursect = _sections[sectname]
else:
cursect = {}
_sections[sectname] = cursect
# So sections can't start with a continuation line
optname = None
# no section header in the file?
elif cursect is None:
raise MissingSectionHeaderError(fpname, lineno, line)
# an option line?
else:
mo = OPTCRE.match(line)
if mo:
optname, vi, optval = mo.group('option', 'vi', 'value')
# This check is fine because the OPTCRE cannot
# match if it would set optval to None
if optval is not None:
if vi in ('=', ':') and ';' in optval:
# ';' is a comment delimiter only if it follows
# a spacing character
pos = optval.find(';')
if pos != -1 and optval[pos-1].isspace():
optval = optval[:pos]
optval = optval.strip()
# allow empty values
if optval == '""':
optval = ''
optname = optname.rstrip()
cursect[optname] = optval
else:
# a non-fatal parsing error occurred. set up the
# exception but keep going. the exception will be
# raised at the end of the file and will contain a
# list of all bogus lines
if not e:
e = ParsingError(fpname)
e.append(lineno, repr(line))
# if any parsing errors occurred, raise an exception
if e:
raise e
return _sections
src/zc/buildout/debugging.txt
View file @
83d53da5
...
@@ -56,7 +56,7 @@ And create a buildout that uses it:
...
@@ -56,7 +56,7 @@ And create a buildout that uses it:
If we run the buildout, we'll get an error:
If we run the buildout, we'll get an error:
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing data-dir.
Installing data-dir.
While:
While:
...
@@ -67,11 +67,11 @@ If we run the buildout, we'll get an error:
...
@@ -67,11 +67,11 @@ If we run the buildout, we'll get an error:
If we want to debug the error, we can add the -D option. Here's we'll
If we want to debug the error, we can add the -D option. Here's we'll
supply some input:
supply some input:
>>> print
system(buildout+" -D", """\
>>> print
_(
system(buildout+" -D", """\
... up
... up
... p self.options.keys()
... p self.options.keys()
... q
... q
... """),
... """),
end='')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing data-dir.
Installing data-dir.
> /zc/buildout/buildout.py(925)__getitem__()
> /zc/buildout/buildout.py(925)__getitem__()
...
...
src/zc/buildout/dependencylinks.txt
View file @
83d53da5
...
@@ -54,14 +54,13 @@ Now let's configure the buildout to use the develop egg.
...
@@ -54,14 +54,13 @@ Now let's configure the buildout to use the develop egg.
Now we can run the buildout.
Now we can run the buildout.
>>> print
system(buildout
)
>>> print
_(system(buildout), end=''
)
GET 200 /
GET 200 /
GET 200 /demoneeded-1.2c1.zip
GET 200 /demoneeded-1.2c1.zip
Develop: '/sample-buildout/depdemo'
Develop: '/sample-buildout/depdemo'
Installing eggs.
Installing eggs.
Getting distribution for 'demoneeded'.
Getting distribution for 'demoneeded'.
Got demoneeded 1.2c1.
Got demoneeded 1.2c1.
<BLANKLINE>
Notice that the egg was retrieved from the logging server.
Notice that the egg was retrieved from the logging server.
...
@@ -83,7 +82,7 @@ buildout to see where the egg comes from this time.
...
@@ -83,7 +82,7 @@ buildout to see where the egg comes from this time.
... for egg in glob(join(sample_buildout, 'eggs', 'demoneeded*.egg')):
... for egg in glob(join(sample_buildout, 'eggs', 'demoneeded*.egg')):
... remove(sample_buildout, 'eggs', egg)
... remove(sample_buildout, 'eggs', egg)
>>> remove_demoneeded_egg()
>>> remove_demoneeded_egg()
>>> print
system(buildout
)
>>> print
_(system(buildout), end=''
)
Develop: '/sample-buildout/depdemo'
Develop: '/sample-buildout/depdemo'
Updating eggs.
Updating eggs.
Couldn't find index page for 'demoneeded' (maybe misspelled?)
Couldn't find index page for 'demoneeded' (maybe misspelled?)
...
@@ -92,7 +91,6 @@ buildout to see where the egg comes from this time.
...
@@ -92,7 +91,6 @@ buildout to see where the egg comes from this time.
Updating eggs.
Updating eggs.
Getting distribution for 'demoneeded'.
Getting distribution for 'demoneeded'.
Error: Couldn't find a distribution for 'demoneeded'.
Error: Couldn't find a distribution for 'demoneeded'.
<BLANKLINE>
Now it can't find the dependency since neither the buildout
Now it can't find the dependency since neither the buildout
configuration nor setup specifies where to look.
configuration nor setup specifies where to look.
...
@@ -112,12 +110,11 @@ to look for eggs.
...
@@ -112,12 +110,11 @@ to look for eggs.
... eggs = depdemo
... eggs = depdemo
... ''' % link_server)
... ''' % link_server)
>>> print
system(buildout
)
>>> print
_(system(buildout), end=''
)
Develop: '/sample-buildout/depdemo'
Develop: '/sample-buildout/depdemo'
Installing eggs.
Installing eggs.
Getting distribution for 'demoneeded'.
Getting distribution for 'demoneeded'.
Got demoneeded 1.2c1.
Got demoneeded 1.2c1.
<BLANKLINE>
This time the dependency egg was found on the server without logging
This time the dependency egg was found on the server without logging
configured.
configured.
...
@@ -134,13 +131,12 @@ specify different places to look for the dependency egg.
...
@@ -134,13 +131,12 @@ specify different places to look for the dependency egg.
... ''' % link_server2)
... ''' % link_server2)
>>> remove_demoneeded_egg()
>>> remove_demoneeded_egg()
>>> print
system(buildout
) #doctest: +ELLIPSIS
>>> print
_(system(buildout), end=''
) #doctest: +ELLIPSIS
GET 200 /...
GET 200 /...
Develop: '/sample-buildout/depdemo'
Develop: '/sample-buildout/depdemo'
Updating eggs.
Updating eggs.
Getting distribution for 'demoneeded'.
Getting distribution for 'demoneeded'.
Got demoneeded 1.2c1.
Got demoneeded 1.2c1.
<BLANKLINE>
So when both setuptools and buildout specify places to search for
So when both setuptools and buildout specify places to search for
eggs, the dependency_links takes precedence over find-links.
eggs, the dependency_links takes precedence over find-links.
...
@@ -166,12 +162,11 @@ Here is an example of using this option to disable dependency_links.
...
@@ -166,12 +162,11 @@ Here is an example of using this option to disable dependency_links.
... ''' % link_server)
... ''' % link_server)
>>> remove_demoneeded_egg()
>>> remove_demoneeded_egg()
>>> print
system(buildout
)
>>> print
_(system(buildout), end=''
)
Develop: '/sample-buildout/depdemo'
Develop: '/sample-buildout/depdemo'
Updating eggs.
Updating eggs.
Getting distribution for 'demoneeded'.
Getting distribution for 'demoneeded'.
Got demoneeded 1.2c1.
Got demoneeded 1.2c1.
<BLANKLINE>
Notice that this time the egg isn't downloaded from the logging server.
Notice that this time the egg isn't downloaded from the logging server.
...
@@ -191,10 +186,9 @@ before. The dependency's are looked for first in the logging server.
...
@@ -191,10 +186,9 @@ before. The dependency's are looked for first in the logging server.
... eggs = depdemo
... eggs = depdemo
... ''' % link_server)
... ''' % link_server)
>>> remove_demoneeded_egg()
>>> remove_demoneeded_egg()
>>> print
system(buildout
) #doctest: +ELLIPSIS
>>> print
_(system(buildout), end=''
) #doctest: +ELLIPSIS
GET 200 /...
GET 200 /...
Develop: '/sample-buildout/depdemo'
Develop: '/sample-buildout/depdemo'
Updating eggs.
Updating eggs.
Getting distribution for 'demoneeded'.
Getting distribution for 'demoneeded'.
Got demoneeded 1.2c1.
Got demoneeded 1.2c1.
<BLANKLINE>
src/zc/buildout/download.py
View file @
83d53da5
...
@@ -24,13 +24,13 @@ import os.path
...
@@ -24,13 +24,13 @@ import os.path
import
re
import
re
import
shutil
import
shutil
import
tempfile
import
tempfile
import
urllib
import
urllib
.request
,
urllib
.
parse
,
urllib
.
error
import
urlparse
import
url
lib.
parse
import
zc.buildout
import
zc.buildout
class
URLOpener
(
urllib
.
FancyURLopener
):
class
URLOpener
(
urllib
.
request
.
FancyURLopener
):
http_error_default
=
urllib
.
URLopener
.
http_error_default
http_error_default
=
urllib
.
request
.
URLopener
.
http_error_default
class
ChecksumError
(
zc
.
buildout
.
UserError
):
class
ChecksumError
(
zc
.
buildout
.
UserError
):
...
@@ -157,7 +157,7 @@ class Download(object):
...
@@ -157,7 +157,7 @@ class Download(object):
if
re
.
match
(
r"^[A-Za-z]:\\"
,
url
):
if
re
.
match
(
r"^[A-Za-z]:\\"
,
url
):
url
=
'file:'
+
url
url
=
'file:'
+
url
parsed_url
=
urlparse
.
urlparse
(
url
,
'file'
)
parsed_url
=
url
lib
.
parse
.
urlparse
(
url
,
'file'
)
url_scheme
,
_
,
url_path
=
parsed_url
[:
3
]
url_scheme
,
_
,
url_path
=
parsed_url
[:
3
]
if
url_scheme
==
'file'
:
if
url_scheme
==
'file'
:
self
.
logger
.
debug
(
'Using local resource %s'
%
url
)
self
.
logger
.
debug
(
'Using local resource %s'
%
url
)
...
@@ -172,18 +172,19 @@ class Download(object):
...
@@ -172,18 +172,19 @@ class Download(object):
"Couldn't download %r in offline mode."
%
url
)
"Couldn't download %r in offline mode."
%
url
)
self
.
logger
.
info
(
'Downloading %s'
%
url
)
self
.
logger
.
info
(
'Downloading %s'
%
url
)
urllib
.
_urlopener
=
url_opener
urllib
.
request
.
_urlopener
=
url_opener
handle
,
tmp_path
=
tempfile
.
mkstemp
(
prefix
=
'buildout-'
)
handle
,
tmp_path
=
tempfile
.
mkstemp
(
prefix
=
'buildout-'
)
try
:
try
:
tmp_path
,
headers
=
urllib
.
urlretrieve
(
url
,
tmp_path
)
tmp_path
,
headers
=
urllib
.
request
.
urlretrieve
(
url
,
tmp_path
)
if
not
check_md5sum
(
tmp_path
,
md5sum
):
if
not
check_md5sum
(
tmp_path
,
md5sum
):
raise
ChecksumError
(
raise
ChecksumError
(
'MD5 checksum mismatch downloading %r'
%
url
)
'MD5 checksum mismatch downloading %r'
%
url
)
except
IOError
,
e
:
except
IOError
:
e
=
sys
.
exc_info
()[
1
]
os
.
remove
(
tmp_path
)
os
.
remove
(
tmp_path
)
raise
zc
.
buildout
.
UserError
(
"Error downloading extends for URL "
raise
zc
.
buildout
.
UserError
(
"Error downloading extends for URL "
"%s: %r"
%
(
url
,
e
[
1
:
3
]))
"%s: %r"
%
(
url
,
e
[
1
:
3
]))
except
Exception
,
e
:
except
Exception
:
os
.
remove
(
tmp_path
)
os
.
remove
(
tmp_path
)
raise
raise
finally
:
finally
:
...
@@ -204,7 +205,7 @@ class Download(object):
...
@@ -204,7 +205,7 @@ class Download(object):
else
:
else
:
if
re
.
match
(
r"^[A-Za-z]:\\"
,
url
):
if
re
.
match
(
r"^[A-Za-z]:\\"
,
url
):
url
=
'file:'
+
url
url
=
'file:'
+
url
parsed
=
urlparse
.
urlparse
(
url
,
'file'
)
parsed
=
url
lib
.
parse
.
urlparse
(
url
,
'file'
)
url_path
=
parsed
[
2
]
url_path
=
parsed
[
2
]
if
parsed
[
0
]
==
'file'
:
if
parsed
[
0
]
==
'file'
:
...
...
src/zc/buildout/download.txt
View file @
83d53da5
...
@@ -28,7 +28,7 @@ without any arguments:
...
@@ -28,7 +28,7 @@ without any arguments:
>>> from zc.buildout.download import Download
>>> from zc.buildout.download import Download
>>> download = Download()
>>> download = Download()
>>> print
download.cache_dir
>>> print
_(download.cache_dir)
None
None
Downloading a file is achieved by calling the utility with the URL as an
Downloading a file is achieved by calling the utility with the URL as an
...
@@ -37,7 +37,7 @@ of the file and a boolean value indicating whether this is a temporary file
...
@@ -37,7 +37,7 @@ of the file and a boolean value indicating whether this is a temporary file
meant to be cleaned up during the same buildout run:
meant to be cleaned up during the same buildout run:
>>> path, is_temp = download(server_url+'foo.txt')
>>> path, is_temp = download(server_url+'foo.txt')
>>> print
path
>>> print
_(path)
/.../buildout-...
/.../buildout-...
>>> cat(path)
>>> cat(path)
This is a foo text.
This is a foo text.
...
@@ -59,8 +59,8 @@ We are responsible for cleaning up temporary files behind us:
...
@@ -59,8 +59,8 @@ We are responsible for cleaning up temporary files behind us:
When trying to access a file that doesn't exist, we'll get an exception:
When trying to access a file that doesn't exist, we'll get an exception:
>>> try: download(server_url+'not-there') # doctest: +ELLIPSIS
>>> try: download(server_url+'not-there') # doctest: +ELLIPSIS
... except: print
'download error'
... except: print
_('download error')
... else: print
'woops'
... else: print
_('woops')
download error
download error
Downloading a local file doesn't produce a temporary file but simply returns
Downloading a local file doesn't produce a temporary file but simply returns
...
@@ -102,7 +102,7 @@ Finally, we can download the file to a specified place in the file system:
...
@@ -102,7 +102,7 @@ Finally, we can download the file to a specified place in the file system:
>>> target_dir = tmpdir('download-target')
>>> target_dir = tmpdir('download-target')
>>> path, is_temp = download(server_url+'foo.txt',
>>> path, is_temp = download(server_url+'foo.txt',
... path=join(target_dir, 'downloaded.txt'))
... path=join(target_dir, 'downloaded.txt'))
>>> print
path
>>> print
_(path)
/download-target/downloaded.txt
/download-target/downloaded.txt
>>> cat(path)
>>> cat(path)
This is a foo text.
This is a foo text.
...
@@ -136,7 +136,7 @@ attribute upon instantiation:
...
@@ -136,7 +136,7 @@ attribute upon instantiation:
>>> cache = tmpdir('download-cache')
>>> cache = tmpdir('download-cache')
>>> download = Download(cache=cache)
>>> download = Download(cache=cache)
>>> print
download.cache_dir
>>> print
_(download.cache_dir)
/download-cache/
/download-cache/
Simple usage
Simple usage
...
@@ -148,7 +148,7 @@ to the cached copy:
...
@@ -148,7 +148,7 @@ to the cached copy:
>>> ls(cache)
>>> ls(cache)
>>> path, is_temp = download(server_url+'foo.txt')
>>> path, is_temp = download(server_url+'foo.txt')
>>> print
path
>>> print
_(path)
/download-cache/foo.txt
/download-cache/foo.txt
>>> cat(path)
>>> cat(path)
This is a foo text.
This is a foo text.
...
@@ -160,7 +160,7 @@ the file on the server to see this:
...
@@ -160,7 +160,7 @@ the file on the server to see this:
>>> write(server_data, 'foo.txt', 'The wrong text.')
>>> write(server_data, 'foo.txt', 'The wrong text.')
>>> path, is_temp = download(server_url+'foo.txt')
>>> path, is_temp = download(server_url+'foo.txt')
>>> print
path
>>> print
_(path)
/download-cache/foo.txt
/download-cache/foo.txt
>>> cat(path)
>>> cat(path)
This is a foo text.
This is a foo text.
...
@@ -179,7 +179,7 @@ will result in the cached copy being used:
...
@@ -179,7 +179,7 @@ will result in the cached copy being used:
>>> mkdir(server_data, 'other')
>>> mkdir(server_data, 'other')
>>> write(server_data, 'other', 'foo.txt', 'The wrong text.')
>>> write(server_data, 'other', 'foo.txt', 'The wrong text.')
>>> path, is_temp = download(server_url+'other/foo.txt')
>>> path, is_temp = download(server_url+'other/foo.txt')
>>> print
path
>>> print
_(path)
/download-cache/foo.txt
/download-cache/foo.txt
>>> cat(path)
>>> cat(path)
This is a foo text.
This is a foo text.
...
@@ -194,7 +194,7 @@ cached copy:
...
@@ -194,7 +194,7 @@ cached copy:
>>> path, is_temp = download(server_url+'foo.txt',
>>> path, is_temp = download(server_url+'foo.txt',
... path=join(target_dir, 'downloaded.txt'))
... path=join(target_dir, 'downloaded.txt'))
>>> print
path
>>> print
_(path)
/download-target/downloaded.txt
/download-target/downloaded.txt
>>> cat(path)
>>> cat(path)
This is a foo text.
This is a foo text.
...
@@ -208,7 +208,7 @@ False
...
@@ -208,7 +208,7 @@ False
>>> path, is_temp = download(server_url+'foo.txt',
>>> path, is_temp = download(server_url+'foo.txt',
... path=join(target_dir, 'downloaded.txt'))
... path=join(target_dir, 'downloaded.txt'))
>>> print
path
>>> print
_(path)
/download-target/downloaded.txt
/download-target/downloaded.txt
>>> cat(path)
>>> cat(path)
This is a foo text.
This is a foo text.
...
@@ -281,7 +281,7 @@ namespaces to use, so the download utility stored files directly inside the
...
@@ -281,7 +281,7 @@ namespaces to use, so the download utility stored files directly inside the
download cache. Let's use a namespace "test" instead:
download cache. Let's use a namespace "test" instead:
>>> download = Download(cache=cache, namespace='test')
>>> download = Download(cache=cache, namespace='test')
>>> print
download.cache_dir
>>> print
_(download.cache_dir)
/download-cache/test
/download-cache/test
The namespace sub-directory hasn't been created yet:
The namespace sub-directory hasn't been created yet:
...
@@ -292,7 +292,7 @@ Downloading a file now creates the namespace sub-directory and places a copy
...
@@ -292,7 +292,7 @@ Downloading a file now creates the namespace sub-directory and places a copy
of the file inside it:
of the file inside it:
>>> path, is_temp = download(server_url+'foo.txt')
>>> path, is_temp = download(server_url+'foo.txt')
>>> print
path
>>> print
_(path)
/download-cache/test/foo.txt
/download-cache/test/foo.txt
>>> ls(cache)
>>> ls(cache)
d test
d test
...
@@ -311,7 +311,7 @@ different content both on the server and in the cache's root directory:
...
@@ -311,7 +311,7 @@ different content both on the server and in the cache's root directory:
>>> write(cache, 'foo.txt', 'The wrong text.')
>>> write(cache, 'foo.txt', 'The wrong text.')
>>> path, is_temp = download(server_url+'foo.txt')
>>> path, is_temp = download(server_url+'foo.txt')
>>> print
path
>>> print
_(path)
/download-cache/test/foo.txt
/download-cache/test/foo.txt
>>> cat(path)
>>> cat(path)
This is a foo text.
This is a foo text.
...
@@ -332,7 +332,7 @@ be used as the filename in the cache:
...
@@ -332,7 +332,7 @@ be used as the filename in the cache:
>>> download = Download(cache=cache, hash_name=True)
>>> download = Download(cache=cache, hash_name=True)
>>> path, is_temp = download(server_url+'foo.txt')
>>> path, is_temp = download(server_url+'foo.txt')
>>> print
path
>>> print
_(path)
/download-cache/09f5793fcdc1716727f72d49519c688d
/download-cache/09f5793fcdc1716727f72d49519c688d
>>> cat(path)
>>> cat(path)
This is a foo text.
This is a foo text.
...
@@ -362,7 +362,7 @@ file the same, the file will be downloaded again this time and put in the
...
@@ -362,7 +362,7 @@ file the same, the file will be downloaded again this time and put in the
cache under a different name:
cache under a different name:
>>> path2, is_temp = download(server_url+'other/foo.txt')
>>> path2, is_temp = download(server_url+'other/foo.txt')
>>> print
path2
>>> print
_(path2)
/download-cache/537b6d73267f8f4447586989af8c470e
/download-cache/537b6d73267f8f4447586989af8c470e
>>> path == path2
>>> path == path2
False
False
...
@@ -390,7 +390,7 @@ down or if we are in offline mode. This mode is only in effect if a download
...
@@ -390,7 +390,7 @@ down or if we are in offline mode. This mode is only in effect if a download
cache is configured in the first place:
cache is configured in the first place:
>>> download = Download(cache=cache, fallback=True)
>>> download = Download(cache=cache, fallback=True)
>>> print
download.cache_dir
>>> print
_(download.cache_dir)
/download-cache/
/download-cache/
A downloaded file will be cached:
A downloaded file will be cached:
...
@@ -408,8 +408,8 @@ If the file cannot be served, the cached copy will be used:
...
@@ -408,8 +408,8 @@ If the file cannot be served, the cached copy will be used:
>>> remove(server_data, 'foo.txt')
>>> remove(server_data, 'foo.txt')
>>> try: Download()(server_url+'foo.txt') # doctest: +ELLIPSIS
>>> try: Download()(server_url+'foo.txt') # doctest: +ELLIPSIS
... except: print
'download error'
... except: print
_('download error')
... else: print
'woops'
... else: print
_('woops')
download error
download error
>>> path, is_temp = download(server_url+'foo.txt')
>>> path, is_temp = download(server_url+'foo.txt')
>>> cat(path)
>>> cat(path)
...
@@ -426,7 +426,7 @@ using the cache:
...
@@ -426,7 +426,7 @@ using the cache:
>>> offline_download = Download(cache=cache, offline=True, fallback=True)
>>> offline_download = Download(cache=cache, offline=True, fallback=True)
>>> path, is_temp = offline_download(server_url+'foo.txt')
>>> path, is_temp = offline_download(server_url+'foo.txt')
>>> print
path
>>> print
_(path)
/download-cache/foo.txt
/download-cache/foo.txt
>>> cat(path)
>>> cat(path)
This is a foo text.
This is a foo text.
...
@@ -466,7 +466,7 @@ The location of the download cache is specified by the ``download-cache``
...
@@ -466,7 +466,7 @@ The location of the download cache is specified by the ``download-cache``
option:
option:
>>> download = Download({'download-cache': cache}, namespace='cmmi')
>>> download = Download({'download-cache': cache}, namespace='cmmi')
>>> print
download.cache_dir
>>> print
_(download.cache_dir)
/download-cache/cmmi
/download-cache/cmmi
If the ``download-cache`` option specifies a relative path, it is understood
If the ``download-cache`` option specifies a relative path, it is understood
...
@@ -474,18 +474,18 @@ relative to the current working directory, or to the buildout directory if
...
@@ -474,18 +474,18 @@ relative to the current working directory, or to the buildout directory if
that is given:
that is given:
>>> download = Download({'download-cache': 'relative-cache'})
>>> download = Download({'download-cache': 'relative-cache'})
>>> print
download.cache_dir
>>> print
_(download.cache_dir)
/sample-buildout/relative-cache/
/sample-buildout/relative-cache/
>>> download = Download({'directory': join(sample_buildout, 'root'),
>>> download = Download({'directory': join(sample_buildout, 'root'),
... 'download-cache': 'relative-cache'})
... 'download-cache': 'relative-cache'})
>>> print
download.cache_dir
>>> print
_(download.cache_dir)
/sample-buildout/root/relative-cache/
/sample-buildout/root/relative-cache/
Keyword parameters take precedence over the corresponding options:
Keyword parameters take precedence over the corresponding options:
>>> download = Download({'download-cache': cache}, cache=None)
>>> download = Download({'download-cache': cache}, cache=None)
>>> print
download.cache_dir
>>> print
_(download.cache_dir)
None
None
Whether to assume offline mode can be inferred from either the ``offline`` or
Whether to assume offline mode can be inferred from either the ``offline`` or
...
...
src/zc/buildout/downloadcache.txt
View file @
83d53da5
...
@@ -31,7 +31,7 @@ And set up a buildout that downloads some eggs:
...
@@ -31,7 +31,7 @@ And set up a buildout that downloads some eggs:
We specified a link server that has some distributions available for
We specified a link server that has some distributions available for
download:
download:
>>> print
get(link_server),
>>> print
_(get(link_server), end='')
<html><body>
<html><body>
<a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
<a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
<a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
<a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
...
@@ -59,7 +59,7 @@ We also specified a download cache.
...
@@ -59,7 +59,7 @@ We also specified a download cache.
If we run the buildout, we'll see the eggs installed from the link
If we run the buildout, we'll see the eggs installed from the link
server as usual:
server as usual:
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
GET 200 /
GET 200 /
GET 200 /demo-0.2-py2.4.egg
GET 200 /demo-0.2-py2.4.egg
GET 200 /demoneeded-1.2c1.zip
GET 200 /demoneeded-1.2c1.zip
...
@@ -89,7 +89,7 @@ If we remove the installed eggs from eggs directory and re-run the buildout:
...
@@ -89,7 +89,7 @@ If we remove the installed eggs from eggs directory and re-run the buildout:
... if f.startswith('demo'):
... if f.startswith('demo'):
... remove('eggs', f)
... remove('eggs', f)
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
GET 200 /
GET 200 /
Updating eggs.
Updating eggs.
Getting distribution for 'demo==0.2'.
Getting distribution for 'demo==0.2'.
...
@@ -132,7 +132,7 @@ install-from-cache option set to true:
...
@@ -132,7 +132,7 @@ install-from-cache option set to true:
... eggs = demo
... eggs = demo
... ''' % globals())
... ''' % globals())
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Uninstalling eggs.
Uninstalling eggs.
Installing eggs.
Installing eggs.
Getting distribution for 'demo'.
Getting distribution for 'demo'.
...
...
src/zc/buildout/easy_install.py
View file @
83d53da5
...
@@ -611,8 +611,9 @@ class Installer:
...
@@ -611,8 +611,9 @@ class Installer:
while
1
:
while
1
:
try
:
try
:
ws
.
resolve
(
requirements
)
ws
.
resolve
(
requirements
)
except
pkg_resources
.
DistributionNotFound
,
err
:
except
pkg_resources
.
DistributionNotFound
:
[
requirement
]
=
err
err
=
sys
.
exc_info
()[
1
]
[
requirement
]
=
err
.
args
requirement
=
self
.
_constrain
(
requirement
)
requirement
=
self
.
_constrain
(
requirement
)
if
dest
:
if
dest
:
logger
.
debug
(
'Getting required %r'
,
str
(
requirement
))
logger
.
debug
(
'Getting required %r'
,
str
(
requirement
))
...
@@ -623,7 +624,8 @@ class Installer:
...
@@ -623,7 +624,8 @@ class Installer:
for
dist
in
self
.
_get_dist
(
requirement
,
ws
):
for
dist
in
self
.
_get_dist
(
requirement
,
ws
):
ws
.
add
(
dist
)
ws
.
add
(
dist
)
self
.
_maybe_add_distribute
(
ws
,
dist
)
self
.
_maybe_add_distribute
(
ws
,
dist
)
except
pkg_resources
.
VersionConflict
,
err
:
except
pkg_resources
.
VersionConflict
:
err
=
sys
.
exc_info
()[
1
]
raise
VersionConflict
(
err
,
ws
)
raise
VersionConflict
(
err
,
ws
)
else
:
else
:
break
break
...
@@ -813,12 +815,12 @@ def develop(setup, dest,
...
@@ -813,12 +815,12 @@ def develop(setup, dest,
undo
.
append
(
lambda
:
os
.
remove
(
tsetup
))
undo
.
append
(
lambda
:
os
.
remove
(
tsetup
))
undo
.
append
(
lambda
:
os
.
close
(
fd
))
undo
.
append
(
lambda
:
os
.
close
(
fd
))
os
.
write
(
fd
,
runsetup_template
%
dict
(
os
.
write
(
fd
,
(
runsetup_template
%
dict
(
distribute
=
distribute_loc
,
distribute
=
distribute_loc
,
setupdir
=
directory
,
setupdir
=
directory
,
setup
=
setup
,
setup
=
setup
,
__file__
=
setup
,
__file__
=
setup
,
))
))
.
encode
())
tmp3
=
tempfile
.
mkdtemp
(
'build'
,
dir
=
dest
)
tmp3
=
tempfile
.
mkdtemp
(
'build'
,
dir
=
dest
)
undo
.
append
(
lambda
:
shutil
.
rmtree
(
tmp3
))
undo
.
append
(
lambda
:
shutil
.
rmtree
(
tmp3
))
...
@@ -871,7 +873,7 @@ def scripts(reqs, working_set, executable, dest=None,
...
@@ -871,7 +873,7 @@ def scripts(reqs, working_set, executable, dest=None,
for
p
in
path
:
for
p
in
path
:
if
p
not
in
unique_path
:
if
p
not
in
unique_path
:
unique_path
.
append
(
p
)
unique_path
.
append
(
p
)
path
=
map
(
realpath
,
unique_path
)
path
=
list
(
map
(
realpath
,
unique_path
)
)
generated
=
[]
generated
=
[]
...
@@ -1073,7 +1075,7 @@ def _create_script(contents, dest):
...
@@ -1073,7 +1075,7 @@ def _create_script(contents, dest):
logger
.
info
(
"Generated script %r."
,
script
)
logger
.
info
(
"Generated script %r."
,
script
)
try
:
try
:
os
.
chmod
(
dest
,
0755
)
os
.
chmod
(
dest
,
0
o
755
)
except
(
AttributeError
,
os
.
error
):
except
(
AttributeError
,
os
.
error
):
pass
pass
...
@@ -1110,8 +1112,7 @@ sys.path[0:0] = [
...
@@ -1110,8 +1112,7 @@ sys.path[0:0] = [
]
]
%(initialization)s
%(initialization)s
%(original_content)s
%(original_content)s'''
'''
def
_pyscript
(
path
,
dest
,
rsetup
):
def
_pyscript
(
path
,
dest
,
rsetup
):
...
@@ -1142,7 +1143,7 @@ def _pyscript(path, dest, rsetup):
...
@@ -1142,7 +1143,7 @@ def _pyscript(path, dest, rsetup):
if
changed
:
if
changed
:
open
(
dest
,
'w'
).
write
(
contents
)
open
(
dest
,
'w'
).
write
(
contents
)
try
:
try
:
os
.
chmod
(
dest
,
0755
)
os
.
chmod
(
dest
,
0
o
755
)
except
(
AttributeError
,
os
.
error
):
except
(
AttributeError
,
os
.
error
):
pass
pass
logger
.
info
(
"Generated interpreter %r."
,
script
)
logger
.
info
(
"Generated interpreter %r."
,
script
)
...
@@ -1167,7 +1168,7 @@ if len(sys.argv) > 1:
...
@@ -1167,7 +1168,7 @@ if len(sys.argv) > 1:
if _opt == '-i':
if _opt == '-i':
_interactive = True
_interactive = True
elif _opt == '-c':
elif _opt == '-c':
exec
_val
exec
(_val)
elif _opt == '-m':
elif _opt == '-m':
sys.argv[1:] = _args
sys.argv[1:] = _args
_args = []
_args = []
...
@@ -1178,7 +1179,9 @@ if len(sys.argv) > 1:
...
@@ -1178,7 +1179,9 @@ if len(sys.argv) > 1:
sys.argv[:] = _args
sys.argv[:] = _args
__file__ = _args[0]
__file__ = _args[0]
del _options, _args
del _options, _args
execfile(__file__)
__file__f = open(__file__)
exec(compile(__file__f.read(), __file__, "exec"))
__file__f.close(); del __file__f
if _interactive:
if _interactive:
del _interactive
del _interactive
...
@@ -1195,7 +1198,8 @@ __file__ = %(__file__)r
...
@@ -1195,7 +1198,8 @@ __file__ = %(__file__)r
os.chdir(%(setupdir)r)
os.chdir(%(setupdir)r)
sys.argv[0] = %(setup)r
sys.argv[0] = %(setup)r
execfile(%(setup)r)
exec(compile(open(%(setup)r).read(), %(setup)r, 'exec'))
"""
"""
...
...
src/zc/buildout/easy_install.txt
View file @
83d53da5
...
@@ -91,7 +91,7 @@ needed to meet the given requirements.
...
@@ -91,7 +91,7 @@ needed to meet the given requirements.
We have a link server that has a number of eggs:
We have a link server that has a number of eggs:
>>> print
get(link_server),
>>> print
_(get(link_server), end='')
<html><body>
<html><body>
<a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
<a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
<a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
<a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
...
@@ -107,7 +107,7 @@ We have a link server that has a number of eggs:
...
@@ -107,7 +107,7 @@ We have a link server that has a number of eggs:
<a href="other-1.0-py2.4.egg">other-1.0-py2.4.egg</a><br>
<a href="other-1.0-py2.4.egg">other-1.0-py2.4.egg</a><br>
</body></html>
</body></html>
Let's make a directory and install the demo egg to it, using the demo:
Let's make a directory and install the demo egg to it, using the demo:
>>> dest = tmpdir('sample-install')
>>> dest = tmpdir('sample-install')
>>> import zc.buildout.easy_install
>>> import zc.buildout.easy_install
...
@@ -115,28 +115,28 @@ Let's make a directory and install the demo egg to it, using the demo:
...
@@ -115,28 +115,28 @@ Let's make a directory and install the demo egg to it, using the demo:
... ['demo==0.2'], dest,
... ['demo==0.2'], dest,
... links=[link_server], index=link_server+'index/')
... links=[link_server], index=link_server+'index/')
We requested version 0.2 of the demo distribution to be installed into
We requested version 0.2 of the demo distribution to be installed into
the destination server. We specified that we should search for links
the destination server. We specified that we should search for links
on the link server and that we should use the (empty) link server
on the link server and that we should use the (empty) link server
index directory as a package index.
index directory as a package index.
The working set contains the distributions we retrieved.
The working set contains the distributions we retrieved.
>>> for dist in ws:
>>> for dist in ws:
... print dist
... print_(dist)
demo 0.2
demo 0.2
demoneeded 1.1
demoneeded 1.1
We got demoneeded because it was a dependency of demo.
We got demoneeded because it was a dependency of demo.
And the actual eggs were added to the eggs directory.
And the actual eggs were added to the eggs directory.
>>> ls(dest)
>>> ls(dest)
d demo-0.2-py2.4.egg
d demo-0.2-py2.4.egg
d demoneeded-1.1-py2.4.egg
d demoneeded-1.1-py2.4.egg
If we remove the version restriction on demo, but specify a false
If we remove the version restriction on demo, but specify a false
value for newest, no new distributions will be installed:
value for newest, no new distributions will be installed:
>>> ws = zc.buildout.easy_install.install(
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], index=link_server+'index/',
... ['demo'], dest, links=[link_server], index=link_server+'index/',
...
@@ -145,7 +145,7 @@ value for newest, no new distributions will be installed:
...
@@ -145,7 +145,7 @@ value for newest, no new distributions will be installed:
d demo-0.2-py2.4.egg
d demo-0.2-py2.4.egg
d demoneeded-1.1-py2.4.egg
d demoneeded-1.1-py2.4.egg
If we leave off the newest option, we'll get an update for demo:
If we leave off the newest option, we'll get an update for demo:
>>> ws = zc.buildout.easy_install.install(
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], index=link_server+'index/')
... ['demo'], dest, links=[link_server], index=link_server+'index/')
...
@@ -154,20 +154,20 @@ If we leave off the newest option, we'll get an update for demo:
...
@@ -154,20 +154,20 @@ If we leave off the newest option, we'll get an update for demo:
d demo-0.3-py2.4.egg
d demo-0.3-py2.4.egg
d demoneeded-1.1-py2.4.egg
d demoneeded-1.1-py2.4.egg
Note that we didn't get the newest versions available. There were
Note that we didn't get the newest versions available. There were
release candidates for newer versions of both packages. By default,
release candidates for newer versions of both packages. By default,
final releases are preferred. We can change this behavior using the
final releases are preferred. We can change this behavior using the
prefer_final function:
prefer_final function:
>>> zc.buildout.easy_install.prefer_final(False)
>>> zc.buildout.easy_install.prefer_final(False)
True
True
The old setting is returned.
The old setting is returned.
>>> ws = zc.buildout.easy_install.install(
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], index=link_server+'index/')
... ['demo'], dest, links=[link_server], index=link_server+'index/')
>>> for dist in ws:
>>> for dist in ws:
... print dist
... print_(dist)
demo 0.4c1
demo 0.4c1
demoneeded 1.2c1
demoneeded 1.2c1
...
@@ -178,21 +178,21 @@ The old setting is returned.
...
@@ -178,21 +178,21 @@ The old setting is returned.
d demoneeded-1.1-py2.4.egg
d demoneeded-1.1-py2.4.egg
d demoneeded-1.2c1-py2.4.egg
d demoneeded-1.2c1-py2.4.egg
Let's put the setting back to the default.
Let's put the setting back to the default.
>>> zc.buildout.easy_install.prefer_final(True)
>>> zc.buildout.easy_install.prefer_final(True)
False
False
We can supply additional distributions. We can also supply
We can supply additional distributions. We can also supply
specifications for distributions that would normally be found via
specifications for distributions that would normally be found via
dependencies. We might do this to specify a specific version.
dependencies. We might do this to specify a specific version.
>>> ws = zc.buildout.easy_install.install(
>>> ws = zc.buildout.easy_install.install(
... ['demo', 'other', 'demoneeded==1.0'], dest,
... ['demo', 'other', 'demoneeded==1.0'], dest,
... links=[link_server], index=link_server+'index/')
... links=[link_server], index=link_server+'index/')
>>> for dist in ws:
>>> for dist in ws:
... print dist
... print_(dist)
demo 0.3
demo 0.3
other 1.0
other 1.0
demoneeded 1.0
demoneeded 1.0
...
@@ -208,15 +208,15 @@ dependencies. We might do this to specify a specific version.
...
@@ -208,15 +208,15 @@ dependencies. We might do this to specify a specific version.
>>> rmdir(dest)
>>> rmdir(dest)
Specifying version information independent of requirements
Specifying version information independent of requirements
----------------------------------------------------------
----------------------------------------------------------
Sometimes it's useful to specify version information independent of
Sometimes it's useful to specify version information independent of
normal requirements specifications. For example, a buildout may need
normal requirements specifications. For example, a buildout may need
to lock down a set of versions, without having to put put version
to lock down a set of versions, without having to put put version
numbers in setup files or part definitions. If a dictionary is passed
numbers in setup files or part definitions. If a dictionary is passed
to the install function, mapping project names to version numbers,
to the install function, mapping project names to version numbers,
then the versions numbers will be used.
then the versions numbers will be used.
>>> ws = zc.buildout.easy_install.install(
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], index=link_server+'index/',
... ['demo'], dest, links=[link_server], index=link_server+'index/',
...
@@ -224,12 +224,12 @@ then the versions numbers will be used.
...
@@ -224,12 +224,12 @@ then the versions numbers will be used.
>>> [d.version for d in ws]
>>> [d.version for d in ws]
['0.2', '1.0']
['0.2', '1.0']
In this example, we specified a version for demoneeded, even though we
In this example, we specified a version for demoneeded, even though we
didn't define a requirement for it. The versions specified apply to
didn't define a requirement for it. The versions specified apply to
dependencies as well as the specified requirements.
dependencies as well as the specified requirements.
If we specify a version that's incompatible with a requirement, then
If we specify a version that's incompatible with a requirement, then
we'll get an error:
we'll get an error:
>>> from zope.testing.loggingsupport import InstalledHandler
>>> from zope.testing.loggingsupport import InstalledHandler
>>> handler = InstalledHandler('zc.buildout.easy_install')
>>> handler = InstalledHandler('zc.buildout.easy_install')
...
@@ -244,7 +244,7 @@ we'll get an error:
...
@@ -244,7 +244,7 @@ we'll get an error:
...
...
IncompatibleVersionError: Bad version 0.2
IncompatibleVersionError: Bad version 0.2
>>> print handler
>>> print_(handler)
zc.buildout.easy_install DEBUG
zc.buildout.easy_install DEBUG
Installing 'demo >0.2'.
Installing 'demo >0.2'.
zc.buildout.easy_install ERROR
zc.buildout.easy_install ERROR
...
@@ -252,14 +252,14 @@ we'll get an error:
...
@@ -252,14 +252,14 @@ we'll get an error:
>>> handler.clear()
>>> handler.clear()
If no versions are specified, a debugging message will be output
If no versions are specified, a debugging message will be output
reporting that a version was picked automatically:
reporting that a version was picked automatically:
>>> ws = zc.buildout.easy_install.install(
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], index=link_server+'index/',
... ['demo'], dest, links=[link_server], index=link_server+'index/',
... )
... )
>>> print handler
# doctest: +ELLIPSIS
>>> print_(handler)
# doctest: +ELLIPSIS
zc.buildout.easy_install DEBUG
zc.buildout.easy_install DEBUG
Installing 'demo'.
Installing 'demo'.
zc.buildout.easy_install INFO
zc.buildout.easy_install INFO
...
@@ -300,12 +300,12 @@ reporting that a version was picked automatically:
...
@@ -300,12 +300,12 @@ reporting that a version was picked automatically:
>>> handler.uninstall()
>>> handler.uninstall()
>>> logging.getLogger('zc.buildout.easy_install').propagate = True
>>> logging.getLogger('zc.buildout.easy_install').propagate = True
We can request that we get an error if versions are picked:
We can request that we get an error if versions are picked:
>>> zc.buildout.easy_install.allow_picked_versions(False)
>>> zc.buildout.easy_install.allow_picked_versions(False)
True
True
(The old setting is returned.)
(The old setting is returned.)
>>> ws = zc.buildout.easy_install.install(
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], index=link_server+'index/',
... ['demo'], dest, links=[link_server], index=link_server+'index/',
...
@@ -317,23 +317,23 @@ We can request that we get an error if versions are picked:
...
@@ -317,23 +317,23 @@ We can request that we get an error if versions are picked:
>>> zc.buildout.easy_install.allow_picked_versions(True)
>>> zc.buildout.easy_install.allow_picked_versions(True)
False
False
The function default_versions can be used to get and set default
The function default_versions can be used to get and set default
version information to be used when no version information is passes.
version information to be used when no version information is passes.
If called with an argument, it sets the default versions:
If called with an argument, it sets the default versions:
>>> zc.buildout.easy_install.default_versions(dict(demoneeded='1'))
>>> zc.buildout.easy_install.default_versions(dict(demoneeded='1'))
... # doctest: +ELLIPSIS
... # doctest: +ELLIPSIS
{...}
{...}
It always returns the previous default versions. If called without an
It always returns the previous default versions. If called without an
argument, it simply returns the default versions without changing
argument, it simply returns the default versions without changing
them:
them:
>>> zc.buildout.easy_install.default_versions()
>>> zc.buildout.easy_install.default_versions()
{'demoneeded': '1'}
{'demoneeded': '1'}
So with the default versions set, we'll get the requested version even
So with the default versions set, we'll get the requested version even
if the versions option isn't used:
if the versions option isn't used:
>>> ws = zc.buildout.easy_install.install(
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], index=link_server+'index/',
... ['demo'], dest, links=[link_server], index=link_server+'index/',
...
@@ -342,8 +342,8 @@ if the versions option isn't used:
...
@@ -342,8 +342,8 @@ if the versions option isn't used:
>>> [d.version for d in ws]
>>> [d.version for d in ws]
['0.3', '1.0']
['0.3', '1.0']
Of course, we can unset the default versions by passing an empty
Of course, we can unset the default versions by passing an empty
dictionary:
dictionary:
>>> zc.buildout.easy_install.default_versions({})
>>> zc.buildout.easy_install.default_versions({})
{'demoneeded': '1'}
{'demoneeded': '1'}
...
@@ -355,44 +355,44 @@ dictionary:
...
@@ -355,44 +355,44 @@ dictionary:
>>> [d.version for d in ws]
>>> [d.version for d in ws]
['0.3', '1.1']
['0.3', '1.1']
Dependency links
Dependency links
----------------
----------------
Setuptools allows metadata that describes where to search for package
Setuptools allows metadata that describes where to search for package
dependencies. This option is called dependency_links. Buildout has its
dependencies. This option is called dependency_links. Buildout has its
own notion of where to look for dependencies, but it also uses the
own notion of where to look for dependencies, but it also uses the
setup tools dependency_links information if it's available.
setup tools dependency_links information if it's available.
Let's demo this by creating an egg that specifies dependency_links.
Let's demo this by creating an egg that specifies dependency_links.
To begin, let's create a new egg repository. This repository hold a
To begin, let's create a new egg repository. This repository hold a
newer version of the 'demoneeded' egg than the sample repository does.
newer version of the 'demoneeded' egg than the sample repository does.
>>> repoloc = tmpdir('repo')
>>> repoloc = tmpdir('repo')
>>> from zc.buildout.tests import create_egg
>>> from zc.buildout.tests import create_egg
>>> create_egg('demoneeded', '1.2', repoloc)
>>> create_egg('demoneeded', '1.2', repoloc)
>>> link_server2 = start_server(repoloc)
>>> link_server2 = start_server(repoloc)
Turn on logging on this server so that we can see when eggs are pulled
Turn on logging on this server so that we can see when eggs are pulled
from it.
from it.
>>> get(link_server2 + 'enable_server_logging')
>>> get(link_server2 + 'enable_server_logging')
GET 200 /enable_server_logging
GET 200 /enable_server_logging
''
''
Now we can create an egg that specifies that its dependencies are
Now we can create an egg that specifies that its dependencies are
found on this server.
found on this server.
>>> repoloc = tmpdir('repo2')
>>> repoloc = tmpdir('repo2')
>>> create_egg('hasdeps', '1.0', repoloc,
>>> create_egg('hasdeps', '1.0', repoloc,
... install_requires = "'demoneeded'",
... install_requires = "'demoneeded'",
... dependency_links = [link_server2])
... dependency_links = [link_server2])
Let's add the egg to another repository.
Let's add the egg to another repository.
>>> link_server3 = start_server(repoloc)
>>> link_server3 = start_server(repoloc)
Now let's install the egg.
Now let's install the egg.
>>> example_dest = tmpdir('example-install')
>>> example_dest = tmpdir('example-install')
>>> workingset = zc.buildout.easy_install.install(
>>> workingset = zc.buildout.easy_install.install(
...
@@ -401,11 +401,11 @@ Now let's install the egg.
...
@@ -401,11 +401,11 @@ Now let's install the egg.
GET 200 /
GET 200 /
GET 200 /demoneeded-1.2-pyN.N.egg
GET 200 /demoneeded-1.2-pyN.N.egg
The server logs show that the dependency was retrieved from the server
The server logs show that the dependency was retrieved from the server
specified in the dependency_links.
specified in the dependency_links.
Now let's see what happens if we provide two different ways to retrieve
Now let's see what happens if we provide two different ways to retrieve
the dependencies.
the dependencies.
>>> rmdir(example_dest)
>>> rmdir(example_dest)
>>> example_dest = tmpdir('example-install')
>>> example_dest = tmpdir('example-install')
...
@@ -415,14 +415,14 @@ the dependencies.
...
@@ -415,14 +415,14 @@ the dependencies.
GET 200 /
GET 200 /
GET 200 /demoneeded-1.2-pyN.N.egg
GET 200 /demoneeded-1.2-pyN.N.egg
Once again the dependency is fetched from the logging server even
Once again the dependency is fetched from the logging server even
though it is also available from the non-logging server. This is
though it is also available from the non-logging server. This is
because the version on the logging server is newer and buildout
because the version on the logging server is newer and buildout
normally chooses the newest egg available.
normally chooses the newest egg available.
If you wish to control where dependencies come from regardless of
If you wish to control where dependencies come from regardless of
dependency_links setup metadata use the 'use_dependency_links' option
dependency_links setup metadata use the 'use_dependency_links' option
to zc.buildout.easy_install.install().
to zc.buildout.easy_install.install().
>>> rmdir(example_dest)
>>> rmdir(example_dest)
>>> example_dest = tmpdir('example-install')
>>> example_dest = tmpdir('example-install')
...
@@ -431,19 +431,19 @@ to zc.buildout.easy_install.install().
...
@@ -431,19 +431,19 @@ to zc.buildout.easy_install.install().
... links=[link_server, link_server3],
... links=[link_server, link_server3],
... use_dependency_links=False)
... use_dependency_links=False)
Notice that this time the dependency egg is not fetched from the
Notice that this time the dependency egg is not fetched from the
logging server. When you specify not to use dependency_links, eggs
logging server. When you specify not to use dependency_links, eggs
will only be searched for using the links you explicitly provide.
will only be searched for using the links you explicitly provide.
Another way to control this option is with the
Another way to control this option is with the
zc.buildout.easy_install.use_dependency_links() function. This
zc.buildout.easy_install.use_dependency_links() function. This
function sets the default behavior for the zc.buildout.easy_install()
function sets the default behavior for the zc.buildout.easy_install()
function.
function.
>>> zc.buildout.easy_install.use_dependency_links(False)
>>> zc.buildout.easy_install.use_dependency_links(False)
True
True
The function returns its previous setting.
The function returns its previous setting.
>>> rmdir(example_dest)
>>> rmdir(example_dest)
>>> example_dest = tmpdir('example-install')
>>> example_dest = tmpdir('example-install')
...
@@ -451,8 +451,8 @@ The function returns its previous setting.
...
@@ -451,8 +451,8 @@ The function returns its previous setting.
... ['hasdeps'], example_dest, index=link_server+'index/',
... ['hasdeps'], example_dest, index=link_server+'index/',
... links=[link_server, link_server3])
... links=[link_server, link_server3])
It can be overridden by passing a keyword argument to the install
It can be overridden by passing a keyword argument to the install
function.
function.
>>> rmdir(example_dest)
>>> rmdir(example_dest)
>>> example_dest = tmpdir('example-install')
>>> example_dest = tmpdir('example-install')
...
@@ -462,7 +462,7 @@ function.
...
@@ -462,7 +462,7 @@ function.
... use_dependency_links=True)
... use_dependency_links=True)
GET 200 /demoneeded-1.2-pyN.N.egg
GET 200 /demoneeded-1.2-pyN.N.egg
To return the dependency_links behavior to normal call the function again.
To return the dependency_links behavior to normal call the function again.
>>> zc.buildout.easy_install.use_dependency_links(True)
>>> zc.buildout.easy_install.use_dependency_links(True)
False
False
...
@@ -474,50 +474,50 @@ To return the dependency_links behavior to normal call the function again.
...
@@ -474,50 +474,50 @@ To return the dependency_links behavior to normal call the function again.
GET 200 /demoneeded-1.2-pyN.N.egg
GET 200 /demoneeded-1.2-pyN.N.egg
Script generation
Script generation
-----------------
-----------------
The easy_install module provides support for creating scripts from
The easy_install module provides support for creating scripts from
eggs. It provides a function similar to setuptools except that it
eggs. It provides a function similar to setuptools except that it
provides facilities for baking a script's path into the script. This
provides facilities for baking a script's path into the script. This
has two advantages:
has two advantages:
- The eggs to be used by a script are not chosen at run time, making
- The eggs to be used by a script are not chosen at run time, making
startup faster and, more importantly, deterministic.
startup faster and, more importantly, deterministic.
- The script doesn't have to import pkg_resources because the logic
- The script doesn't have to import pkg_resources because the logic
that pkg_resources would execute at run time is executed at
that pkg_resources would execute at run time is executed at
script-creation time.
script-creation time.
The scripts method can be used to generate scripts. Let's create a
The scripts method can be used to generate scripts. Let's create a
destination directory for it to place them in:
destination directory for it to place them in:
>>> import tempfile
>>> import tempfile
>>> bin = tmpdir('bin')
>>> bin = tmpdir('bin')
Now, we'll use the scripts method to generate scripts in this directory
Now, we'll use the scripts method to generate scripts in this directory
from the demo egg:
from the demo egg:
>>> import sys
>>> import sys
>>> scripts = zc.buildout.easy_install.scripts(
>>> scripts = zc.buildout.easy_install.scripts(
... ['demo'], ws, sys.executable, bin)
... ['demo'], ws, sys.executable, bin)
the three arguments we passed were:
the three arguments we passed were:
1. A sequence of distribution requirements. These are of the same
1. A sequence of distribution requirements. These are of the same
form as setuptools requirements. Here we passed a single
form as setuptools requirements. Here we passed a single
requirement, for the version 0.1 demo distribution.
requirement, for the version 0.1 demo distribution.
2. A working set,
2. A working set,
3. The destination directory.
3. The destination directory.
The bin directory now contains a generated script:
The bin directory now contains a generated script:
>>> ls(bin)
>>> ls(bin)
- demo
- demo
The return value is a list of the scripts generated:
The return value is a list of the scripts generated:
>>> import os, sys
>>> import os, sys
>>> if sys.platform == 'win32':
>>> if sys.platform == 'win32':
...
@@ -527,12 +527,12 @@ The return value is a list of the scripts generated:
...
@@ -527,12 +527,12 @@ The return value is a list of the scripts generated:
... scripts == [os.path.join(bin, 'demo')]
... scripts == [os.path.join(bin, 'demo')]
True
True
Note that in Windows, 2 files are generated for each script. A script
Note that in Windows, 2 files are generated for each script. A script
file, ending in '-script.py', and an exe file that allows the script
file, ending in '-script.py', and an exe file that allows the script
to be invoked directly without having to specify the Python
to be invoked directly without having to specify the Python
interpreter and without having to provide a '.py' suffix.
interpreter and without having to provide a '.py' suffix.
The demo script run the entry point defined in the demo egg:
The demo script run the entry point defined in the demo egg:
>>> cat(bin, 'demo') # doctest: +NORMALIZE_WHITESPACE
>>> cat(bin, 'demo') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.7
#!/usr/local/bin/python2.7
...
@@ -548,15 +548,15 @@ The demo script run the entry point defined in the demo egg:
...
@@ -548,15 +548,15 @@ The demo script run the entry point defined in the demo egg:
if __name__ == '__main__':
if __name__ == '__main__':
sys.exit(eggrecipedemo.main())
sys.exit(eggrecipedemo.main())
Some things to note:
Some things to note:
- The demo and demoneeded eggs are added to the beginning of sys.path.
- The demo and demoneeded eggs are added to the beginning of sys.path.
- The module for the script entry point is imported and the entry
- The module for the script entry point is imported and the entry
point, in this case, 'main', is run.
point, in this case, 'main', is run.
Rather than requirement strings, you can pass tuples containing 3
Rather than requirement strings, you can pass tuples containing 3
strings:
strings:
- A script name,
- A script name,
...
@@ -564,8 +564,8 @@ strings:
...
@@ -564,8 +564,8 @@ strings:
- An attribute expression for an entry point within the module.
- An attribute expression for an entry point within the module.
For example, we could have passed entry point information directly
For example, we could have passed entry point information directly
rather than passing a requirement:
rather than passing a requirement:
>>> scripts = zc.buildout.easy_install.scripts(
>>> scripts = zc.buildout.easy_install.scripts(
... [('demo', 'eggrecipedemo', 'main')], ws,
... [('demo', 'eggrecipedemo', 'main')], ws,
...
@@ -585,14 +585,14 @@ rather than passing a requirement:
...
@@ -585,14 +585,14 @@ rather than passing a requirement:
if __name__ == '__main__':
if __name__ == '__main__':
sys.exit(eggrecipedemo.main())
sys.exit(eggrecipedemo.main())
Passing entry-point information directly is handy when using eggs (or
Passing entry-point information directly is handy when using eggs (or
distributions) that don't declare their entry points, such as
distributions) that don't declare their entry points, such as
distributions that aren't based on setuptools.
distributions that aren't based on setuptools.
The interpreter keyword argument can be used to generate a script that can
The interpreter keyword argument can be used to generate a script that can
be used to invoke the Python interactive interpreter with the path set
be used to invoke the Python interactive interpreter with the path set
based on the working set. This generated script can also be used to
based on the working set. This generated script can also be used to
run other scripts with the path set on the working set:
run other scripts with the path set on the working set:
>>> scripts = zc.buildout.easy_install.scripts(
>>> scripts = zc.buildout.easy_install.scripts(
... ['demo'], ws, sys.executable, bin, interpreter='py')
... ['demo'], ws, sys.executable, bin, interpreter='py')
...
@@ -612,8 +612,8 @@ run other scripts with the path set on the working set:
...
@@ -612,8 +612,8 @@ run other scripts with the path set on the working set:
... os.path.join(bin, 'py')]
... os.path.join(bin, 'py')]
True
True
The py script simply runs the Python interactive interpreter with
The py script simply runs the Python interactive interpreter with
the path set:
the path set:
>>> cat(bin, 'py') # doctest: +NORMALIZE_WHITESPACE
>>> cat(bin, 'py') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.7
#!/usr/local/bin/python2.7
...
@@ -633,7 +633,7 @@ the path set:
...
@@ -633,7 +633,7 @@ the path set:
if _opt == '-i':
if _opt == '-i':
_interactive = True
_interactive = True
elif _opt == '-c':
elif _opt == '-c':
exec _val
exec(_val)
elif _opt == '-m':
elif _opt == '-m':
sys.argv[1:] = _args
sys.argv[1:] = _args
_args = []
_args = []
...
@@ -644,35 +644,39 @@ the path set:
...
@@ -644,35 +644,39 @@ the path set:
sys.argv[:] = _args
sys.argv[:] = _args
__file__ = _args[0]
__file__ = _args[0]
del _options, _args
del _options, _args
execfile(__file__)
__file__f = open(__file__)
exec(compile(__file__f.read(), __file__, "exec"))
__file__f.close(); del __file__f
<BLANKLINE>
<BLANKLINE>
if _interactive:
if _interactive:
del _interactive
del _interactive
__import__("code").interact(banner="", local=globals())
__import__("code").interact(banner="", local=globals())
If invoked with a script name and arguments, it will run that script, instead.
If invoked with a script name and arguments, it will run that script, instead.
>>> write('ascript',
'''
>>> write('ascript', r
'''
... "demo doc"
... "demo doc"
... print sys.argv
... import sys
... print (__name__, __file__, __doc__)
... print_ = lambda *a: sys.stdout.write(' '.join(map(str, a))+'\n')
... print_(sys.argv)
... print_((__name__, __file__, __doc__))
... ''')
... ''')
>>> print system(join(bin, 'py')+' ascript a b c'),
>>> print_(system(join(bin, 'py')+' ascript a b c'), end='')
['ascript', 'a', 'b', 'c']
['ascript', 'a', 'b', 'c']
('__main__', 'ascript', 'demo doc')
('__main__', 'ascript', 'demo doc')
For Python 2.5 and higher, you can also use the -m option to run a
For Python 2.5 and higher, you can also use the -m option to run a
module:
module:
>>> print system(join(bin, 'py')+' -m pdb'),
>>> print_(system(join(bin, 'py')+' -m pdb'), end='') # doctest: +ELLIPSIS
usage: pdb.py scriptfile [arg]
...
usage: pdb.py
...
>>> print system(join(bin, 'py')+' -m pdb what'),
>>> print_(system(join(bin, 'py')+' -m pdb what'), end='')
Error: what does not exist
Error: what does not exist
An additional argument can be passed to define which scripts to install
An additional argument can be passed to define which scripts to install
and to provide script names. The argument is a dictionary mapping
and to provide script names. The argument is a dictionary mapping
original script names to new script names.
original script names to new script names.
>>> bin = tmpdir('bin2')
>>> bin = tmpdir('bin2')
>>> scripts = zc.buildout.easy_install.scripts(
>>> scripts = zc.buildout.easy_install.scripts(
...
@@ -687,14 +691,14 @@ original script names to new script names.
...
@@ -687,14 +691,14 @@ original script names to new script names.
>>> ls(bin)
>>> ls(bin)
- run
- run
>>> print system(os.path.join(bin, 'run')),
>>> print_(system(os.path.join(bin, 'run')), end='')
3 1
3 1
Including extra paths in scripts
Including extra paths in scripts
--------------------------------
--------------------------------
We can pass a keyword argument, extra paths, to cause additional paths
We can pass a keyword argument, extra paths, to cause additional paths
to be included in the a generated script:
to be included in the a generated script:
>>> foo = tmpdir('foo')
>>> foo = tmpdir('foo')
>>> scripts = zc.buildout.easy_install.scripts(
>>> scripts = zc.buildout.easy_install.scripts(
...
@@ -716,12 +720,12 @@ to be included in the a generated script:
...
@@ -716,12 +720,12 @@ to be included in the a generated script:
if __name__ == '__main__':
if __name__ == '__main__':
sys.exit(eggrecipedemo.main())
sys.exit(eggrecipedemo.main())
Providing script arguments
Providing script arguments
--------------------------
--------------------------
An "argument" keyword argument can be used to pass arguments to an
An "argument" keyword argument can be used to pass arguments to an
entry point. The value passed is a source string to be placed between the
entry point. The value passed is a source string to be placed between the
parentheses in the call:
parentheses in the call:
>>> scripts = zc.buildout.easy_install.scripts(
>>> scripts = zc.buildout.easy_install.scripts(
... ['demo'], ws, sys.executable, bin, dict(demo='run'),
... ['demo'], ws, sys.executable, bin, dict(demo='run'),
...
@@ -740,10 +744,10 @@ parentheses in the call:
...
@@ -740,10 +744,10 @@ parentheses in the call:
if __name__ == '__main__':
if __name__ == '__main__':
sys.exit(eggrecipedemo.main(1, 2))
sys.exit(eggrecipedemo.main(1, 2))
Passing initialization code
Passing initialization code
---------------------------
---------------------------
You can also pass script initialization code:
You can also pass script initialization code:
>>> scripts = zc.buildout.easy_install.scripts(
>>> scripts = zc.buildout.easy_install.scripts(
... ['demo'], ws, sys.executable, bin, dict(demo='run'),
... ['demo'], ws, sys.executable, bin, dict(demo='run'),
...
@@ -766,13 +770,13 @@ You can also pass script initialization code:
...
@@ -766,13 +770,13 @@ You can also pass script initialization code:
if __name__ == '__main__':
if __name__ == '__main__':
sys.exit(eggrecipedemo.main(1, 2))
sys.exit(eggrecipedemo.main(1, 2))
Relative paths
Relative paths
--------------
--------------
Sometimes, you want to be able to move a buildout directory around and
Sometimes, you want to be able to move a buildout directory around and
have scripts still work without having to rebuild them. We can
have scripts still work without having to rebuild them. We can
control this using the relative_paths option to install. You need
control this using the relative_paths option to install. You need
to pass a common base directory of the scripts and eggs:
to pass a common base directory of the scripts and eggs:
>>> bo = tmpdir('bo')
>>> bo = tmpdir('bo')
>>> ba = tmpdir('ba')
>>> ba = tmpdir('ba')
...
@@ -812,15 +816,15 @@ to pass a common base directory of the scripts and eggs:
...
@@ -812,15 +816,15 @@ to pass a common base directory of the scripts and eggs:
if __name__ == '__main__':
if __name__ == '__main__':
sys.exit(eggrecipedemo.main())
sys.exit(eggrecipedemo.main())
Note that the extra path we specified that was outside the directory
Note that the extra path we specified that was outside the directory
passed as relative_paths wasn't converted to a relative path.
passed as relative_paths wasn't converted to a relative path.
Of course, running the script works:
Of course, running the script works:
>>> print system(join(bo, 'bin', 'run')),
>>> print_(system(join(bo, 'bin', 'run')), end='')
3 1
3 1
We specified an interpreter and its paths are adjusted too:
We specified an interpreter and its paths are adjusted too:
>>> cat(bo, 'bin', 'py')
>>> cat(bo, 'bin', 'py')
#!/usr/local/bin/python2.7
#!/usr/local/bin/python2.7
...
@@ -848,7 +852,7 @@ We specified an interpreter and its paths are adjusted too:
...
@@ -848,7 +852,7 @@ We specified an interpreter and its paths are adjusted too:
if _opt == '-i':
if _opt == '-i':
_interactive = True
_interactive = True
elif _opt == '-c':
elif _opt == '-c':
exec _val
exec(_val)
elif _opt == '-m':
elif _opt == '-m':
sys.argv[1:] = _args
sys.argv[1:] = _args
_args = []
_args = []
...
@@ -859,19 +863,21 @@ We specified an interpreter and its paths are adjusted too:
...
@@ -859,19 +863,21 @@ We specified an interpreter and its paths are adjusted too:
sys.argv[:] = _args
sys.argv[:] = _args
__file__ = _args[0]
__file__ = _args[0]
del _options, _args
del _options, _args
execfile(__file__)
__file__f = open(__file__)
exec(compile(__file__f.read(), __file__, "exec"))
__file__f.close(); del __file__f
<BLANKLINE>
<BLANKLINE>
if _interactive:
if _interactive:
del _interactive
del _interactive
__import__("code").interact(banner="", local=globals())
__import__("code").interact(banner="", local=globals())
Installing distutils-style scripts
Installing distutils-style scripts
----------------------------------
----------------------------------
Most python libraries use the console_scripts entry point nowadays. But
Most python libraries use the console_scripts entry point nowadays. But
several still have a ``scripts=['bin/something']`` in their setup() call.
several still have a ``scripts=['bin/something']`` in their setup() call.
Buildout also installs those:
Buildout also installs those:
>>> distdir = tmpdir('distutilsscriptdir')
>>> distdir = tmpdir('distutilsscriptdir')
>>> distbin = tmpdir('distutilsscriptbin')
>>> distbin = tmpdir('distutilsscriptbin')
...
@@ -883,7 +889,7 @@ Buildout also installs those:
...
@@ -883,7 +889,7 @@ Buildout also installs those:
>>> ls(distbin)
>>> ls(distbin)
- distutilsscript
- distutilsscript
It also works for zipped eggs:
It also works for zipped eggs:
>>> distdir2 = tmpdir('distutilsscriptdir2')
>>> distdir2 = tmpdir('distutilsscriptdir2')
>>> distbin2 = tmpdir('distutilsscriptbin2')
>>> distbin2 = tmpdir('distutilsscriptbin2')
...
@@ -895,10 +901,10 @@ It also works for zipped eggs:
...
@@ -895,10 +901,10 @@ It also works for zipped eggs:
>>> ls(distbin2)
>>> ls(distbin2)
- distutilsscript
- distutilsscript
Distutils copies the script files verbatim, apart from a line at the top that
Distutils copies the script files verbatim, apart from a line at the top that
looks like ``#!/usr/bin/python``, which gets replaced by the actual python
looks like ``#!/usr/bin/python``, which gets replaced by the actual python
interpreter. Buildout does the same, but additionally also adds the sys.path
interpreter. Buildout does the same, but additionally also adds the sys.path
like for the console_scripts:
like for the console_scripts:
>>> cat(distbin, 'distutilsscript')
>>> cat(distbin, 'distutilsscript')
#!/usr/local/bin/python2.7
#!/usr/local/bin/python2.7
...
@@ -909,39 +915,39 @@ like for the console_scripts:
...
@@ -909,39 +915,39 @@ like for the console_scripts:
]
]
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
<BLANKLINE>
print "distutils!"
import sys; sys.stdout.write("distutils!\n")
Due to the nature of distutils scripts, buildout cannot pass arguments as
Due to the nature of distutils scripts, buildout cannot pass arguments as
there's no specific method to pass them to.
there's no specific method to pass them to.
Handling custom build options for extensions provided in source distributions
Handling custom build options for extensions provided in source distributions
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
Sometimes, we need to control how extension modules are built. The
Sometimes, we need to control how extension modules are built. The
build function provides this level of control. It takes a single
build function provides this level of control. It takes a single
package specification, downloads a source distribution, and builds it
package specification, downloads a source distribution, and builds it
with specified custom build options.
with specified custom build options.
The build function takes 3 positional arguments:
The build function takes 3 positional arguments:
spec
spec
A package specification for a source distribution
A package specification for a source distribution
dest
dest
A destination directory
A destination directory
build_ext
build_ext
A dictionary of options to be passed to the distutils build_ext
A dictionary of options to be passed to the distutils build_ext
command when building extensions.
command when building extensions.
It supports a number of optional keyword arguments:
It supports a number of optional keyword arguments:
links
links
a sequence of URLs, file names, or directories to look for
a sequence of URLs, file names, or directories to look for
links to distributions,
links to distributions,
index
index
The URL of an index server, or almost any other valid URL. :)
The URL of an index server, or almost any other valid URL. :)
If not specified, the Python Package Index,
If not specified, the Python Package Index,
...
@@ -952,25 +958,25 @@ index
...
@@ -952,25 +958,25 @@ index
we'll just point to an empty directory on our link server. This
we'll just point to an empty directory on our link server. This
will make our examples run a little bit faster.
will make our examples run a little bit faster.
path
path
A list of additional directories to search for locally-installed
A list of additional directories to search for locally-installed
distributions.
distributions.
newest
newest
A boolean value indicating whether to search for new distributions
A boolean value indicating whether to search for new distributions
when already-installed distributions meet the requirement. When
when already-installed distributions meet the requirement. When
this is true, the default, and when the destination directory is
this is true, the default, and when the destination directory is
not None, then the install function will search for the newest
not None, then the install function will search for the newest
distributions that satisfy the requirements.
distributions that satisfy the requirements.
versions
versions
A dictionary mapping project names to version numbers to be used
A dictionary mapping project names to version numbers to be used
when selecting distributions. This can be used to specify a set of
when selecting distributions. This can be used to specify a set of
distribution versions independent of other requirements.
distribution versions independent of other requirements.
Our link server included a source distribution that includes a simple
Our link server included a source distribution that includes a simple
extension, extdemo.c::
extension, extdemo.c::
#include <Python.h>
#include <Python.h>
#include <extdemo.h>
#include <extdemo.h>
...
@@ -989,11 +995,11 @@ extension, extdemo.c::
...
@@ -989,11 +995,11 @@ extension, extdemo.c::
#endif
#endif
}
}
The extension depends on a system-dependent include file, extdemo.h,
The extension depends on a system-dependent include file, extdemo.h,
that defines a constant, EXTDEMO, that is exposed by the extension.
that defines a constant, EXTDEMO, that is exposed by the extension.
We'll add an include directory to our sample buildout and add the
We'll add an include directory to our sample buildout and add the
needed include file to it:
needed include file to it:
>>> mkdir('include')
>>> mkdir('include')
>>> write('include', 'extdemo.h',
>>> write('include', 'extdemo.h',
...
@@ -1001,8 +1007,8 @@ needed include file to it:
...
@@ -1001,8 +1007,8 @@ needed include file to it:
... #define EXTDEMO 42
... #define EXTDEMO 42
... """)
... """)
Now, we can use the build function to create an egg from the source
Now, we can use the build function to create an egg from the source
distribution:
distribution:
>>> zc.buildout.easy_install.build(
>>> zc.buildout.easy_install.build(
... 'extdemo', dest,
... 'extdemo', dest,
...
@@ -1010,9 +1016,9 @@ distribution:
...
@@ -1010,9 +1016,9 @@ distribution:
... links=[link_server], index=link_server+'index/')
... links=[link_server], index=link_server+'index/')
['/sample-install/extdemo-1.4-py2.4-unix-i686.egg']
['/sample-install/extdemo-1.4-py2.4-unix-i686.egg']
The function returns the list of eggs
The function returns the list of eggs
Now if we look in our destination directory, we see we have an extdemo egg:
Now if we look in our destination directory, we see we have an extdemo egg:
>>> ls(dest)
>>> ls(dest)
d demo-0.2-py2.4.egg
d demo-0.2-py2.4.egg
...
@@ -1021,10 +1027,10 @@ Now if we look in our destination directory, we see we have an extdemo egg:
...
@@ -1021,10 +1027,10 @@ Now if we look in our destination directory, we see we have an extdemo egg:
d demoneeded-1.1-py2.4.egg
d demoneeded-1.1-py2.4.egg
d extdemo-1.4-py2.4-unix-i686.egg
d extdemo-1.4-py2.4-unix-i686.egg
Let's update our link server with a new version of extdemo:
Let's update our link server with a new version of extdemo:
>>> update_extdemo()
>>> update_extdemo()
>>> print get(link_server),
>>> print_(get(link_server), end='')
<html><body>
<html><body>
<a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
<a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
<a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
<a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
...
@@ -1041,13 +1047,13 @@ Let's update our link server with a new version of extdemo:
...
@@ -1041,13 +1047,13 @@ Let's update our link server with a new version of extdemo:
<a href="other-1.0-py2.4.egg">other-1.0-py2.4.egg</a><br>
<a href="other-1.0-py2.4.egg">other-1.0-py2.4.egg</a><br>
</body></html>
</body></html>
The easy_install caches information about servers to reduce network
The easy_install caches information about servers to reduce network
access. To see the update, we have to call the clear_index_cache
access. To see the update, we have to call the clear_index_cache
function to clear the index cache:
function to clear the index cache:
>>> zc.buildout.easy_install.clear_index_cache()
>>> zc.buildout.easy_install.clear_index_cache()
If we run build with newest set to False, we won't get an update:
If we run build with newest set to False, we won't get an update:
>>> zc.buildout.easy_install.build(
>>> zc.buildout.easy_install.build(
... 'extdemo', dest,
... 'extdemo', dest,
...
@@ -1063,8 +1069,8 @@ If we run build with newest set to False, we won't get an update:
...
@@ -1063,8 +1069,8 @@ If we run build with newest set to False, we won't get an update:
d demoneeded-1.1-py2.4.egg
d demoneeded-1.1-py2.4.egg
d extdemo-1.4-py2.4-unix-i686.egg
d extdemo-1.4-py2.4-unix-i686.egg
But if we run it with the default True setting for newest, then we'll
But if we run it with the default True setting for newest, then we'll
get an updated egg:
get an updated egg:
>>> zc.buildout.easy_install.build(
>>> zc.buildout.easy_install.build(
... 'extdemo', dest,
... 'extdemo', dest,
...
@@ -1080,10 +1086,10 @@ get an updated egg:
...
@@ -1080,10 +1086,10 @@ get an updated egg:
d extdemo-1.4-py2.4-unix-i686.egg
d extdemo-1.4-py2.4-unix-i686.egg
d extdemo-1.5-py2.4-unix-i686.egg
d extdemo-1.5-py2.4-unix-i686.egg
The versions option also influences the versions used. For example,
The versions option also influences the versions used. For example,
if we specify a version for extdemo, then that will be used, even
if we specify a version for extdemo, then that will be used, even
though it isn't the newest. Let's clean out the destination directory
though it isn't the newest. Let's clean out the destination directory
first:
first:
>>> import os
>>> import os
>>> for name in os.listdir(dest):
>>> for name in os.listdir(dest):
...
@@ -1099,29 +1105,29 @@ first:
...
@@ -1099,29 +1105,29 @@ first:
>>> ls(dest)
>>> ls(dest)
d extdemo-1.4-py2.4-unix-i686.egg
d extdemo-1.4-py2.4-unix-i686.egg
Handling custom build options for extensions in develop eggs
Handling custom build options for extensions in develop eggs
------------------------------------------------------------
------------------------------------------------------------
The develop function is similar to the build function, except that,
The develop function is similar to the build function, except that,
rather than building an egg from a source directory containing a
rather than building an egg from a source directory containing a
setup.py script.
setup.py script.
The develop function takes 2 positional arguments:
The develop function takes 2 positional arguments:
setup
setup
The path to a setup script, typically named "setup.py", or a
The path to a setup script, typically named "setup.py", or a
directory containing a setup.py script.
directory containing a setup.py script.
dest
dest
The directory to install the egg link to
The directory to install the egg link to
It supports some optional keyword argument:
It supports some optional keyword argument:
build_ext
build_ext
A dictionary of options to be passed to the distutils build_ext
A dictionary of options to be passed to the distutils build_ext
command when building extensions.
command when building extensions.
We have a local directory containing the extdemo source:
We have a local directory containing the extdemo source:
>>> ls(extdemo)
>>> ls(extdemo)
- MANIFEST
- MANIFEST
...
@@ -1130,24 +1136,24 @@ We have a local directory containing the extdemo source:
...
@@ -1130,24 +1136,24 @@ We have a local directory containing the extdemo source:
- extdemo.c
- extdemo.c
- setup.py
- setup.py
Now, we can use the develop function to create a develop egg from the source
Now, we can use the develop function to create a develop egg from the source
distribution:
distribution:
>>> zc.buildout.easy_install.develop(
>>> zc.buildout.easy_install.develop(
... extdemo, dest,
... extdemo, dest,
... {'include-dirs': os.path.join(sample_buildout, 'include')})
... {'include-dirs': os.path.join(sample_buildout, 'include')})
'/sample-install/extdemo.egg-link'
'/sample-install/extdemo.egg-link'
The name of the egg link created is returned.
The name of the egg link created is returned.
Now if we look in our destination directory, we see we have an extdemo
Now if we look in our destination directory, we see we have an extdemo
egg link:
egg link:
>>> ls(dest)
>>> ls(dest)
d extdemo-1.4-py2.4-unix-i686.egg
d extdemo-1.4-py2.4-unix-i686.egg
- extdemo.egg-link
- extdemo.egg-link
And that the source directory contains the compiled extension:
And that the source directory contains the compiled extension:
>>> ls(extdemo)
>>> ls(extdemo)
- MANIFEST
- MANIFEST
...
@@ -1159,40 +1165,40 @@ And that the source directory contains the compiled extension:
...
@@ -1159,40 +1165,40 @@ And that the source directory contains the compiled extension:
- extdemo.so
- extdemo.so
- setup.py
- setup.py
Download cache
Download cache
--------------
--------------
Normally, when distributions are installed, if any processing is
Normally, when distributions are installed, if any processing is
needed, they are downloaded from the internet to a temporary directory
needed, they are downloaded from the internet to a temporary directory
and then installed from there. A download cache can be used to avoid
and then installed from there. A download cache can be used to avoid
the download step. This can be useful to reduce network access and to
the download step. This can be useful to reduce network access and to
create source distributions of an entire buildout.
create source distributions of an entire buildout.
A download cache is specified by calling the download_cache
A download cache is specified by calling the download_cache
function. The function always returns the previous setting. If no
function. The function always returns the previous setting. If no
argument is passed, then the setting is unchanged. If an argument is
argument is passed, then the setting is unchanged. If an argument is
passed, the download cache is set to the given path, which must point
passed, the download cache is set to the given path, which must point
to an existing directory. Passing None clears the cache setting.
to an existing directory. Passing None clears the cache setting.
To see this work, we'll create a directory and set it as the cache
To see this work, we'll create a directory and set it as the cache
directory:
directory:
>>> cache = tmpdir('cache')
>>> cache = tmpdir('cache')
>>> zc.buildout.easy_install.download_cache(cache)
>>> zc.buildout.easy_install.download_cache(cache)
We'll recreate our destination directory:
We'll recreate our destination directory:
>>> remove(dest)
>>> remove(dest)
>>> dest = tmpdir('sample-install')
>>> dest = tmpdir('sample-install')
We'd like to see what is being fetched from the server, so we'll
We'd like to see what is being fetched from the server, so we'll
enable server logging:
enable server logging:
>>> get(link_server+'enable_server_logging')
>>> get(link_server+'enable_server_logging')
GET 200 /enable_server_logging
GET 200 /enable_server_logging
''
''
Now, if we install demo, and extdemo:
Now, if we install demo, and extdemo:
>>> ws = zc.buildout.easy_install.install(
>>> ws = zc.buildout.easy_install.install(
... ['demo==0.2'], dest,
... ['demo==0.2'], dest,
...
@@ -1212,30 +1218,30 @@ Now, if we install demo, and extdemo:
...
@@ -1212,30 +1218,30 @@ Now, if we install demo, and extdemo:
GET 200 /extdemo-1.5.zip
GET 200 /extdemo-1.5.zip
['/sample-install/extdemo-1.5-py2.4-linux-i686.egg']
['/sample-install/extdemo-1.5-py2.4-linux-i686.egg']
Not only will we get eggs in our destination directory:
Not only will we get eggs in our destination directory:
>>> ls(dest)
>>> ls(dest)
d demo-0.2-py2.4.egg
d demo-0.2-py2.4.egg
d demoneeded-1.1-py2.4.egg
d demoneeded-1.1-py2.4.egg
d extdemo-1.5-py2.4-linux-i686.egg
d extdemo-1.5-py2.4-linux-i686.egg
But we'll get distributions in the cache directory:
But we'll get distributions in the cache directory:
>>> ls(cache)
>>> ls(cache)
- demo-0.2-py2.4.egg
- demo-0.2-py2.4.egg
- demoneeded-1.1.zip
- demoneeded-1.1.zip
- extdemo-1.5.zip
- extdemo-1.5.zip
The cache directory contains uninstalled distributions, such as zipped
The cache directory contains uninstalled distributions, such as zipped
eggs or source distributions.
eggs or source distributions.
Let's recreate our destination directory and clear the index cache:
Let's recreate our destination directory and clear the index cache:
>>> remove(dest)
>>> remove(dest)
>>> dest = tmpdir('sample-install')
>>> dest = tmpdir('sample-install')
>>> zc.buildout.easy_install.clear_index_cache()
>>> zc.buildout.easy_install.clear_index_cache()
Now when we install the distributions:
Now when we install the distributions:
>>> ws = zc.buildout.easy_install.install(
>>> ws = zc.buildout.easy_install.install(
... ['demo==0.2'], dest,
... ['demo==0.2'], dest,
...
@@ -1257,43 +1263,43 @@ Now when we install the distributions:
...
@@ -1257,43 +1263,43 @@ Now when we install the distributions:
d demoneeded-1.1-py2.4.egg
d demoneeded-1.1-py2.4.egg
d extdemo-1.5-py2.4-linux-i686.egg
d extdemo-1.5-py2.4-linux-i686.egg
Note that we didn't download the distributions from the link server.
Note that we didn't download the distributions from the link server.
If we remove the restriction on demo, we'll download a newer version
If we remove the restriction on demo, we'll download a newer version
from the link server:
from the link server:
>>> ws = zc.buildout.easy_install.install(
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest,
... ['demo'], dest,
... links=[link_server], index=link_server+'index/')
... links=[link_server], index=link_server+'index/')
GET 200 /demo-0.3-py2.4.egg
GET 200 /demo-0.3-py2.4.egg
Normally, the download cache is the preferred source of downloads, but
Normally, the download cache is the preferred source of downloads, but
not the only one.
not the only one.
Installing solely from a download cache
Installing solely from a download cache
---------------------------------------
---------------------------------------
A download cache can be used as the basis of application source
A download cache can be used as the basis of application source
releases. In an application source release, we want to distribute an
releases. In an application source release, we want to distribute an
application that can be built without making any network accesses. In
application that can be built without making any network accesses. In
this case, we distribute a download cache and tell the easy_install
this case, we distribute a download cache and tell the easy_install
module to install from the download cache only, without making network
module to install from the download cache only, without making network
accesses. The install_from_cache function can be used to signal that
accesses. The install_from_cache function can be used to signal that
packages should be installed only from the download cache. The
packages should be installed only from the download cache. The
function always returns the previous setting. Calling it with no
function always returns the previous setting. Calling it with no
arguments returns the current setting without changing it:
arguments returns the current setting without changing it:
>>> zc.buildout.easy_install.install_from_cache()
>>> zc.buildout.easy_install.install_from_cache()
False
False
Calling it with a boolean value changes the setting and returns the
Calling it with a boolean value changes the setting and returns the
previous setting:
previous setting:
>>> zc.buildout.easy_install.install_from_cache(True)
>>> zc.buildout.easy_install.install_from_cache(True)
False
False
Let's remove demo-0.3-py2.4.egg from the cache, clear the index cache,
Let's remove demo-0.3-py2.4.egg from the cache, clear the index cache,
recreate the destination directory, and reinstall demo:
recreate the destination directory, and reinstall demo:
>>> for f in os.listdir(cache):
>>> for f in os.listdir(cache):
... if f.startswith('demo-0.3-'):
... if f.startswith('demo-0.3-'):
...
@@ -1311,9 +1317,9 @@ recreate the destination directory, and reinstall demo:
...
@@ -1311,9 +1317,9 @@ recreate the destination directory, and reinstall demo:
d demo-0.2-py2.4.egg
d demo-0.2-py2.4.egg
d demoneeded-1.1-py2.4.egg
d demoneeded-1.1-py2.4.egg
This time, we didn't download from or even query the link server.
This time, we didn't download from or even query the link server.
.. Disable the download cache:
.. Disable the download cache:
>>> zc.buildout.easy_install.download_cache(None)
>>> zc.buildout.easy_install.download_cache(None)
'/cache'
'/cache'
...
...
src/zc/buildout/extends-cache.txt
View file @
83d53da5
...
@@ -41,20 +41,20 @@ buildout:
...
@@ -41,20 +41,20 @@ buildout:
When trying to run this buildout offline, we'll find that we cannot read all
When trying to run this buildout offline, we'll find that we cannot read all
of the required configuration:
of the required configuration:
>>> print
system(buildout + ' -o'
)
>>> print
_(system(buildout + ' -o')
)
While:
While:
Initializing.
Initializing.
Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
Trying the same online, we can:
Trying the same online, we can:
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
Unused options for buildout: 'foo'.
Unused options for buildout: 'foo'.
As long as we haven't said anything about caching downloaded configuration,
As long as we haven't said anything about caching downloaded configuration,
nothing gets cached. Offline mode will still cause the buildout to fail:
nothing gets cached. Offline mode will still cause the buildout to fail:
>>> print
system(buildout + ' -o'
)
>>> print
_(system(buildout + ' -o')
)
While:
While:
Initializing.
Initializing.
Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
...
@@ -73,7 +73,7 @@ being a hash of the complete URL):
...
@@ -73,7 +73,7 @@ being a hash of the complete URL):
... extends-cache = cache
... extends-cache = cache
... """ % server_url)
... """ % server_url)
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
Unused options for buildout: 'foo'.
Unused options for buildout: 'foo'.
>>> cache = join(sample_buildout, 'cache')
>>> cache = join(sample_buildout, 'cache')
...
@@ -88,7 +88,7 @@ foo = bar
...
@@ -88,7 +88,7 @@ foo = bar
We can now run buildout offline as it will read base.cfg from the cache:
We can now run buildout offline as it will read base.cfg from the cache:
>>> print
system(buildout + ' -o'
)
>>> print
_(system(buildout + ' -o')
)
Unused options for buildout: 'foo'.
Unused options for buildout: 'foo'.
The cache is being used purely as a fall-back in case we are offline or don't
The cache is being used purely as a fall-back in case we are offline or don't
...
@@ -104,18 +104,18 @@ base.cfg from the cache:
...
@@ -104,18 +104,18 @@ base.cfg from the cache:
... bar = baz
... bar = baz
... """)
... """)
>>> print
system(buildout + ' -o'
)
>>> print
_(system(buildout + ' -o')
)
Unused options for buildout: 'foo'.
Unused options for buildout: 'foo'.
In online mode, buildout will download and use the modified version:
In online mode, buildout will download and use the modified version:
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
Unused options for buildout: 'bar'.
Unused options for buildout: 'bar'.
Trying offline mode again, the new version will be used as it has been put in
Trying offline mode again, the new version will be used as it has been put in
the cache now:
the cache now:
>>> print
system(buildout + ' -o'
)
>>> print
_(system(buildout + ' -o')
)
Unused options for buildout: 'bar'.
Unused options for buildout: 'bar'.
Clean up:
Clean up:
...
@@ -203,7 +203,7 @@ bases, using different caches:
...
@@ -203,7 +203,7 @@ bases, using different caches:
Buildout will now assemble its configuration from all of these 6 files,
Buildout will now assemble its configuration from all of these 6 files,
defaults first. The online resources end up in the respective extends caches:
defaults first. The online resources end up in the respective extends caches:
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
Unused options for buildout: 'foo'.
Unused options for buildout: 'foo'.
>>> ls('user-cache')
>>> ls('user-cache')
...
@@ -249,7 +249,7 @@ Let's rewrite the config files, clean out the caches and re-run buildout:
...
@@ -249,7 +249,7 @@ Let's rewrite the config files, clean out the caches and re-run buildout:
>>> remove('user-cache', os.listdir('user-cache')[0])
>>> remove('user-cache', os.listdir('user-cache')[0])
>>> remove('cache', os.listdir('cache')[0])
>>> remove('cache', os.listdir('cache')[0])
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
Unused options for buildout: 'foo'.
Unused options for buildout: 'foo'.
>>> ls('user-cache')
>>> ls('user-cache')
...
@@ -272,7 +272,7 @@ Offline mode and installation from cache
...
@@ -272,7 +272,7 @@ Offline mode and installation from cache
If we run buildout in offline mode now, it will fail because it cannot get at
If we run buildout in offline mode now, it will fail because it cannot get at
the remote configuration file needed by the user's defaults:
the remote configuration file needed by the user's defaults:
>>> print
system(buildout + ' -o'
)
>>> print
_(system(buildout + ' -o')
)
While:
While:
Initializing.
Initializing.
Error: Couldn't download 'http://localhost/base_default.cfg' in offline mode.
Error: Couldn't download 'http://localhost/base_default.cfg' in offline mode.
...
@@ -285,7 +285,7 @@ configuration and see when buildout applies this setting in each case:
...
@@ -285,7 +285,7 @@ configuration and see when buildout applies this setting in each case:
... extends = fancy_default.cfg
... extends = fancy_default.cfg
... offline = true
... offline = true
... """)
... """)
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
While:
While:
Initializing.
Initializing.
Error: Couldn't download 'http://localhost/base_default.cfg' in offline mode.
Error: Couldn't download 'http://localhost/base_default.cfg' in offline mode.
...
@@ -299,7 +299,7 @@ Error: Couldn't download 'http://localhost/base_default.cfg' in offline mode.
...
@@ -299,7 +299,7 @@ Error: Couldn't download 'http://localhost/base_default.cfg' in offline mode.
... extends = %sbase_default.cfg
... extends = %sbase_default.cfg
... offline = true
... offline = true
... """ % server_url)
... """ % server_url)
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
While:
While:
Initializing.
Initializing.
Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
...
@@ -313,7 +313,7 @@ Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
...
@@ -313,7 +313,7 @@ Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
... extends = fancy.cfg
... extends = fancy.cfg
... offline = true
... offline = true
... """)
... """)
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
While:
While:
Initializing.
Initializing.
Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
...
@@ -327,7 +327,7 @@ Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
...
@@ -327,7 +327,7 @@ Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
... extends = %sbase.cfg
... extends = %sbase.cfg
... offline = true
... offline = true
... """ % server_url)
... """ % server_url)
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
Unused options for buildout: 'foo'.
Unused options for buildout: 'foo'.
The ``install-from-cache`` option is treated accordingly:
The ``install-from-cache`` option is treated accordingly:
...
@@ -337,7 +337,7 @@ The ``install-from-cache`` option is treated accordingly:
...
@@ -337,7 +337,7 @@ The ``install-from-cache`` option is treated accordingly:
... extends = fancy_default.cfg
... extends = fancy_default.cfg
... install-from-cache = true
... install-from-cache = true
... """)
... """)
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
While:
While:
Initializing.
Initializing.
Error: Couldn't download 'http://localhost/base_default.cfg' in offline mode.
Error: Couldn't download 'http://localhost/base_default.cfg' in offline mode.
...
@@ -351,7 +351,7 @@ Error: Couldn't download 'http://localhost/base_default.cfg' in offline mode.
...
@@ -351,7 +351,7 @@ Error: Couldn't download 'http://localhost/base_default.cfg' in offline mode.
... extends = %sbase_default.cfg
... extends = %sbase_default.cfg
... install-from-cache = true
... install-from-cache = true
... """ % server_url)
... """ % server_url)
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
While:
While:
Initializing.
Initializing.
Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
...
@@ -365,7 +365,7 @@ Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
...
@@ -365,7 +365,7 @@ Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
... extends = fancy.cfg
... extends = fancy.cfg
... install-from-cache = true
... install-from-cache = true
... """)
... """)
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
While:
While:
Initializing.
Initializing.
Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
...
@@ -379,7 +379,7 @@ Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
...
@@ -379,7 +379,7 @@ Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
... extends = %sbase.cfg
... extends = %sbase.cfg
... install-from-cache = true
... install-from-cache = true
... """ % server_url)
... """ % server_url)
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
While:
While:
Installing.
Installing.
Checking for upgrades.
Checking for upgrades.
...
@@ -406,7 +406,7 @@ is already present locally. If we run buildout in newest mode
...
@@ -406,7 +406,7 @@ is already present locally. If we run buildout in newest mode
... extends-cache = cache
... extends-cache = cache
... extends = %sbase.cfg
... extends = %sbase.cfg
... """ % server_url)
... """ % server_url)
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
>>> ls('cache')
>>> ls('cache')
- 5aedc98d7e769290a29d654a591a3a45
- 5aedc98d7e769290a29d654a591a3a45
>>> cat('cache', os.listdir(cache)[0])
>>> cat('cache', os.listdir(cache)[0])
...
@@ -420,7 +420,7 @@ A change to ``base.cfg`` is picked up on the next buildout run:
...
@@ -420,7 +420,7 @@ A change to ``base.cfg`` is picked up on the next buildout run:
... parts =
... parts =
... foo = bar
... foo = bar
... """)
... """)
>>> print
system(buildout + " -n"
)
>>> print
_(system(buildout + " -n")
)
Unused options for buildout: 'foo'.
Unused options for buildout: 'foo'.
>>> cat('cache', os.listdir(cache)[0])
>>> cat('cache', os.listdir(cache)[0])
[buildout]
[buildout]
...
@@ -434,7 +434,7 @@ already present in the extends cache will not be updated:
...
@@ -434,7 +434,7 @@ already present in the extends cache will not be updated:
... [buildout]
... [buildout]
... parts =
... parts =
... """)
... """)
>>> print
system(buildout + " -N"
)
>>> print
_(system(buildout + " -N")
)
Unused options for buildout: 'foo'.
Unused options for buildout: 'foo'.
>>> cat('cache', os.listdir(cache)[0])
>>> cat('cache', os.listdir(cache)[0])
[buildout]
[buildout]
...
@@ -463,7 +463,7 @@ used:
...
@@ -463,7 +463,7 @@ used:
... newest = true
... newest = true
... extends = %sbaseA.cfg %sbaseB.cfg
... extends = %sbaseA.cfg %sbaseB.cfg
... """ % (server_url, server_url))
... """ % (server_url, server_url))
>>> print
system(buildout + " -n"
)
>>> print
_(system(buildout + " -n")
)
Unused options for buildout: 'bar' 'foo'.
Unused options for buildout: 'bar' 'foo'.
(XXX We patch download utility's API to produce readable output for the test;
(XXX We patch download utility's API to produce readable output for the test;
...
@@ -472,7 +472,7 @@ a better solution would utilise the logging already done by the utility.)
...
@@ -472,7 +472,7 @@ a better solution would utilise the logging already done by the utility.)
>>> import zc.buildout
>>> import zc.buildout
>>> old_download = zc.buildout.download.Download.download
>>> old_download = zc.buildout.download.Download.download
>>> def wrapper_download(self, url, md5sum=None, path=None):
>>> def wrapper_download(self, url, md5sum=None, path=None):
... print
"The URL %s was downloaded." % url
... print
_("The URL %s was downloaded." % url)
... return old_download(url, md5sum, path)
... return old_download(url, md5sum, path)
>>> zc.buildout.download.Download.download = wrapper_download
>>> zc.buildout.download.Download.download = wrapper_download
...
@@ -499,7 +499,7 @@ UserError is raised if that option is encountered now:
...
@@ -499,7 +499,7 @@ UserError is raised if that option is encountered now:
... parts =
... parts =
... extended-by = foo.cfg
... extended-by = foo.cfg
... """)
... """)
>>> print
system(buildout
)
>>> print
_(system(buildout)
)
While:
While:
Initializing.
Initializing.
Error: No-longer supported "extended-by" option found in http://localhost/base.cfg.
Error: No-longer supported "extended-by" option found in http://localhost/base.cfg.
...
...
src/zc/buildout/isolation.txt
View file @
83d53da5
...
@@ -38,7 +38,8 @@ This document tests the 3rd option.
...
@@ -38,7 +38,8 @@ This document tests the 3rd option.
>>> sample_buildout = tmpdir('sample')
>>> sample_buildout = tmpdir('sample')
>>> cd(sample_buildout)
>>> cd(sample_buildout)
>>> import sys
>>> import sys
>>> print system("%s -S %s init demo" % (sys.executable, bootstrap_py)),
>>> print_(system("%s -S %s init demo" % (sys.executable, bootstrap_py)),
... end='')
... # doctest: +ELLIPSIS
... # doctest: +ELLIPSIS
Downloading http://pypi.python.org/packages/source/d/distribute/...
Downloading http://pypi.python.org/packages/source/d/distribute/...
Creating '/sample/buildout.cfg'.
Creating '/sample/buildout.cfg'.
...
@@ -78,10 +79,10 @@ The -S option is also used when invoking setup scripts.
...
@@ -78,10 +79,10 @@ The -S option is also used when invoking setup scripts.
>>> write('proj', 'setup.py', """
>>> write('proj', 'setup.py', """
... from distutils.core import setup
... from distutils.core import setup
... import sys
... import sys
... print
'site:', 'site' in sys.modules
... print
_('site:', 'site' in sys.modules)
... setup(name='hassite')
... setup(name='hassite')
... """)
... """)
>>> print
system(join('bin', 'buildout')+' setup proj sdist'
)
>>> print
_(system(join('bin', 'buildout')+' setup proj sdist')
)
... # doctest: +ELLIPSIS
... # doctest: +ELLIPSIS
Running setup script 'proj/setup.py'.
Running setup script 'proj/setup.py'.
site: True
site: True
...
@@ -95,7 +96,7 @@ The -S option is also used when invoking setup scripts.
...
@@ -95,7 +96,7 @@ The -S option is also used when invoking setup scripts.
... recipe = zc.recipe.egg
... recipe = zc.recipe.egg
... eggs = hassite
... eggs = hassite
... """ % join('proj', 'dist'))
... """ % join('proj', 'dist'))
>>> print
system(join('bin', 'buildout'
))
>>> print
_(system(join('bin', 'buildout')
))
... # doctest: +ELLIPSIS
... # doctest: +ELLIPSIS
Uninstalling py.
Uninstalling py.
Installing egg.
Installing egg.
...
@@ -110,7 +111,7 @@ The -S option is also used when invoking setup scripts.
...
@@ -110,7 +111,7 @@ The -S option is also used when invoking setup scripts.
... parts =
... parts =
... develop = %s
... develop = %s
... """ % join('proj'))
... """ % join('proj'))
>>> print
system(join('bin', 'buildout'
))
>>> print
_(system(join('bin', 'buildout')
))
... # doctest: +ELLIPSIS
... # doctest: +ELLIPSIS
Develop: '/sample/proj'
Develop: '/sample/proj'
site: True
site: True
...
...
src/zc/buildout/repeatable.txt
View file @
83d53da5
...
@@ -21,10 +21,12 @@ To see how this works, we'll create two versions of a recipe egg:
...
@@ -21,10 +21,12 @@ To see how this works, we'll create two versions of a recipe egg:
>>> mkdir('recipe')
>>> mkdir('recipe')
>>> write('recipe', 'recipe.py',
>>> write('recipe', 'recipe.py',
... '''
... '''
... import sys
... print_ = lambda *a: sys.stdout.write(' '.join(map(str, a))+'\n')
... class Recipe:
... class Recipe:
... def __init__(*a): pass
... def __init__(*a): pass
... def install(self):
... def install(self):
... print
'recipe v1'
... print
_('recipe v1')
... return ()
... return ()
... update = install
... update = install
... ''')
... ''')
...
@@ -39,7 +41,7 @@ To see how this works, we'll create two versions of a recipe egg:
...
@@ -39,7 +41,7 @@ To see how this works, we'll create two versions of a recipe egg:
>>> write('recipe', 'README', '')
>>> write('recipe', 'README', '')
>>> print
system(buildout+' setup recipe bdist_egg'),
# doctest: +ELLIPSIS
>>> print
_(system(buildout+' setup recipe bdist_egg'))
# doctest: +ELLIPSIS
Running setup script 'recipe/setup.py'.
Running setup script 'recipe/setup.py'.
...
...
...
@@ -47,10 +49,12 @@ To see how this works, we'll create two versions of a recipe egg:
...
@@ -47,10 +49,12 @@ To see how this works, we'll create two versions of a recipe egg:
>>> write('recipe', 'recipe.py',
>>> write('recipe', 'recipe.py',
... '''
... '''
... import sys
... print_ = lambda *a: sys.stdout.write(' '.join(map(str, a))+'\n')
... class Recipe:
... class Recipe:
... def __init__(*a): pass
... def __init__(*a): pass
... def install(self):
... def install(self):
... print
'recipe v2'
... print
_('recipe v2')
... return ()
... return ()
... update = install
... update = install
... ''')
... ''')
...
@@ -64,7 +68,7 @@ To see how this works, we'll create two versions of a recipe egg:
...
@@ -64,7 +68,7 @@ To see how this works, we'll create two versions of a recipe egg:
... ''')
... ''')
>>> print
system(buildout+' setup recipe bdist_egg'),
# doctest: +ELLIPSIS
>>> print
_(system(buildout+' setup recipe bdist_egg'))
# doctest: +ELLIPSIS
Running setup script 'recipe/setup.py'.
Running setup script 'recipe/setup.py'.
...
...
...
@@ -82,7 +86,7 @@ and we'll configure a buildout to use it:
...
@@ -82,7 +86,7 @@ and we'll configure a buildout to use it:
If we run the buildout, it will use version 2:
If we run the buildout, it will use version 2:
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Getting distribution for 'spam'.
Getting distribution for 'spam'.
Got spam 2.
Got spam 2.
Installing foo.
Installing foo.
...
@@ -112,7 +116,7 @@ as in the versions option.
...
@@ -112,7 +116,7 @@ as in the versions option.
Now, if we run the buildout, we'll use version 1 of the spam recipe:
Now, if we run the buildout, we'll use version 1 of the spam recipe:
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Getting distribution for 'spam==1'.
Getting distribution for 'spam==1'.
Got spam 1.
Got spam 1.
Uninstalling foo.
Uninstalling foo.
...
@@ -123,7 +127,7 @@ Running the buildout in verbose mode will help us get information
...
@@ -123,7 +127,7 @@ Running the buildout in verbose mode will help us get information
about versions used. If we run the buildout in verbose mode without
about versions used. If we run the buildout in verbose mode without
specifying a versions section:
specifying a versions section:
>>> print
system(buildout+' buildout:versions= -v'), # doctest: +ELLIPSIS
>>> print
_(system(buildout+' buildout:versions= -v'), end='')
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout', 'distribute'.
We have a develop egg: zc.buildout 1.0.0.
We have a develop egg: zc.buildout 1.0.0.
We have the best distribution that satisfies 'distribute'.
We have the best distribution that satisfies 'distribute'.
...
@@ -145,7 +149,7 @@ that we can fix them in a versions section.
...
@@ -145,7 +149,7 @@ that we can fix them in a versions section.
If we run the buildout with the versions section:
If we run the buildout with the versions section:
>>> print
system(buildout+' -v'), # doctest: +ELLIPSIS
>>> print
_(system(buildout+' -v'), end='')
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout', 'distribute'.
We have a develop egg: zc.buildout 1.0.0.
We have a develop egg: zc.buildout 1.0.0.
We have the best distribution that satisfies 'distribute'.
We have the best distribution that satisfies 'distribute'.
...
...
src/zc/buildout/rmtree.py
View file @
83d53da5
...
@@ -42,7 +42,7 @@ def rmtree (path):
...
@@ -42,7 +42,7 @@ def rmtree (path):
and make it unwriteable
and make it unwriteable
>>> os.chmod (foo, 0400)
>>> os.chmod (foo, 0
o
400)
rmtree should be able to remove it:
rmtree should be able to remove it:
...
@@ -54,7 +54,7 @@ def rmtree (path):
...
@@ -54,7 +54,7 @@ def rmtree (path):
0
0
"""
"""
def
retry_writeable
(
func
,
path
,
exc
):
def
retry_writeable
(
func
,
path
,
exc
):
os
.
chmod
(
path
,
0600
)
os
.
chmod
(
path
,
0
o
600
)
func
(
path
)
func
(
path
)
shutil
.
rmtree
(
path
,
onerror
=
retry_writeable
)
shutil
.
rmtree
(
path
,
onerror
=
retry_writeable
)
...
@@ -64,3 +64,4 @@ def test_suite():
...
@@ -64,3 +64,4 @@ def test_suite():
if
"__main__"
==
__name__
:
if
"__main__"
==
__name__
:
doctest
.
testmod
()
doctest
.
testmod
()
src/zc/buildout/runsetup.txt
View file @
83d53da5
...
@@ -17,7 +17,8 @@ commands, like bdist_egg even with packages that don't use setuptools.
...
@@ -17,7 +17,8 @@ commands, like bdist_egg even with packages that don't use setuptools.
To illustrate this, we'll create a package in a sample buildout:
To illustrate this, we'll create a package in a sample buildout:
>>> mkdir('hello')
>>> mkdir('hello')
>>> write('hello', 'hello.py', 'print "Hello World!"')
>>> write('hello', 'hello.py',
... 'import sys; sys.stdout.write("Hello World!\n")\n')
>>> write('hello', 'README', 'This is hello')
>>> write('hello', 'README', 'This is hello')
>>> write('hello', 'setup.py',
>>> write('hello', 'setup.py',
... """
... """
...
@@ -32,7 +33,7 @@ To illustrate this, we'll create a package in a sample buildout:
...
@@ -32,7 +33,7 @@ To illustrate this, we'll create a package in a sample buildout:
We can use the buildout command to generate the hello egg:
We can use the buildout command to generate the hello egg:
>>> print
system(buildout +' setup hello -q bdist_egg'),
>>> print
_(system(buildout +' setup hello -q bdist_egg'), end='')
Running setup script 'hello/setup.py'.
Running setup script 'hello/setup.py'.
zip_safe flag not set; analyzing archive contents...
zip_safe flag not set; analyzing archive contents...
...
...
src/zc/buildout/setup.txt
View file @
83d53da5
...
@@ -28,14 +28,14 @@ We've created a super simple (stupid) setup script. Note that it
...
@@ -28,14 +28,14 @@ We've created a super simple (stupid) setup script. Note that it
doesn't import setuptools. Let's try running it to create an egg.
doesn't import setuptools. Let's try running it to create an egg.
We'll use the buildout script from our sample buildout:
We'll use the buildout script from our sample buildout:
>>> print
system(buildout+' setup'),
>>> print
_(system(buildout+' setup'), end='')
... # doctest: +NORMALIZE_WHITESPACE
... # doctest: +NORMALIZE_WHITESPACE
Error: The setup command requires the path to a setup script or
Error: The setup command requires the path to a setup script or
directory containing a setup script, and its arguments.
directory containing a setup script, and its arguments.
Oops, we forgot to give the name of the setup script:
Oops, we forgot to give the name of the setup script:
>>> print
system(buildout+' setup setup.py bdist_egg'),
>>> print
_(system(buildout+' setup setup.py bdist_egg'))
... # doctest: +ELLIPSIS
... # doctest: +ELLIPSIS
Running setup script 'setup.py'.
Running setup script 'setup.py'.
...
...
...
@@ -46,6 +46,6 @@ Oops, we forgot to give the name of the setup script:
...
@@ -46,6 +46,6 @@ Oops, we forgot to give the name of the setup script:
Note that we can specify a directory name. This is often shorter and
Note that we can specify a directory name. This is often shorter and
preferred by the lazy :)
preferred by the lazy :)
>>> print
system(buildout+' setup . bdist_egg'),
# doctest: +ELLIPSIS
>>> print
_(system(buildout+' setup . bdist_egg'))
# doctest: +ELLIPSIS
Running setup script './setup.py'.
Running setup script './setup.py'.
...
...
src/zc/buildout/testing.py
View file @
83d53da5
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
"""Various test-support utility functions
"""Various test-support utility functions
"""
"""
import
BaseHTTPS
erver
import
http.s
erver
import
errno
import
errno
import
logging
import
logging
import
os
import
os
...
@@ -28,12 +28,14 @@ import sys
...
@@ -28,12 +28,14 @@ import sys
import
tempfile
import
tempfile
import
threading
import
threading
import
time
import
time
import
urllib
2
import
urllib
.request
,
urllib
.
error
,
urllib
.
parse
import
zc.buildout.buildout
import
zc.buildout.buildout
import
zc.buildout.easy_install
import
zc.buildout.easy_install
from
zc.buildout.rmtree
import
rmtree
from
zc.buildout.rmtree
import
rmtree
print_
=
zc
.
buildout
.
buildout
.
print_
fsync
=
getattr
(
os
,
'fsync'
,
lambda
fileno
:
None
)
fsync
=
getattr
(
os
,
'fsync'
,
lambda
fileno
:
None
)
is_win32
=
sys
.
platform
==
'win32'
is_win32
=
sys
.
platform
==
'win32'
...
@@ -47,7 +49,7 @@ def cat(dir, *names):
...
@@ -47,7 +49,7 @@ def cat(dir, *names):
and
os
.
path
.
exists
(
path
+
'-script.py'
)
and
os
.
path
.
exists
(
path
+
'-script.py'
)
):
):
path
=
path
+
'-script.py'
path
=
path
+
'-script.py'
print
open
(
path
).
read
(),
print
_
(
open
(
path
).
read
(),
end
=
''
)
def
ls
(
dir
,
*
subs
):
def
ls
(
dir
,
*
subs
):
if
subs
:
if
subs
:
...
@@ -56,12 +58,12 @@ def ls(dir, *subs):
...
@@ -56,12 +58,12 @@ def ls(dir, *subs):
names
.
sort
()
names
.
sort
()
for
name
in
names
:
for
name
in
names
:
if
os
.
path
.
isdir
(
os
.
path
.
join
(
dir
,
name
)):
if
os
.
path
.
isdir
(
os
.
path
.
join
(
dir
,
name
)):
print
'd '
,
print
_
(
'd '
,
end
=
' '
)
elif
os
.
path
.
islink
(
os
.
path
.
join
(
dir
,
name
)):
elif
os
.
path
.
islink
(
os
.
path
.
join
(
dir
,
name
)):
print
'l '
,
print
_
(
'l '
,
end
=
' '
)
else
:
else
:
print
'- '
,
print
_
(
'- '
,
end
=
' '
)
print
name
print
_
(
name
)
def
mkdir
(
*
path
):
def
mkdir
(
*
path
):
os
.
mkdir
(
os
.
path
.
join
(
*
path
))
os
.
mkdir
(
os
.
path
.
join
(
*
path
))
...
@@ -96,15 +98,15 @@ def system(command, input=''):
...
@@ -96,15 +98,15 @@ def system(command, input=''):
close_fds
=
MUST_CLOSE_FDS
)
close_fds
=
MUST_CLOSE_FDS
)
i
,
o
,
e
=
(
p
.
stdin
,
p
.
stdout
,
p
.
stderr
)
i
,
o
,
e
=
(
p
.
stdin
,
p
.
stdout
,
p
.
stderr
)
if
input
:
if
input
:
i
.
write
(
input
)
i
.
write
(
input
.
encode
()
)
i
.
close
()
i
.
close
()
result
=
o
.
read
()
+
e
.
read
()
result
=
o
.
read
()
+
e
.
read
()
o
.
close
()
o
.
close
()
e
.
close
()
e
.
close
()
return
result
return
result
.
decode
()
def
get
(
url
):
def
get
(
url
):
return
urllib
2
.
urlopen
(
url
).
read
()
return
urllib
.
request
.
urlopen
(
url
).
read
().
decode
()
def
_runsetup
(
setup
,
*
args
):
def
_runsetup
(
setup
,
*
args
):
if
os
.
path
.
isdir
(
setup
):
if
os
.
path
.
isdir
(
setup
):
...
@@ -254,6 +256,7 @@ def buildoutSetUp(test):
...
@@ -254,6 +256,7 @@ def buildoutSetUp(test):
start_server
=
start_server
,
start_server
=
start_server
,
buildout
=
os
.
path
.
join
(
sample
,
'bin'
,
'buildout'
),
buildout
=
os
.
path
.
join
(
sample
,
'bin'
,
'buildout'
),
wait_until
=
wait_until
,
wait_until
=
wait_until
,
print_
=
print_
,
))
))
zc
.
buildout
.
easy_install
.
prefer_final
(
prefer_final
)
zc
.
buildout
.
easy_install
.
prefer_final
(
prefer_final
)
...
@@ -262,10 +265,10 @@ def buildoutTearDown(test):
...
@@ -262,10 +265,10 @@ def buildoutTearDown(test):
for
f
in
test
.
globs
[
'__tear_downs'
]:
for
f
in
test
.
globs
[
'__tear_downs'
]:
f
()
f
()
class
Server
(
BaseHTTPS
erver
.
HTTPServer
):
class
Server
(
http
.
s
erver
.
HTTPServer
):
def
__init__
(
self
,
tree
,
*
args
):
def
__init__
(
self
,
tree
,
*
args
):
BaseHTTPS
erver
.
HTTPServer
.
__init__
(
self
,
*
args
)
http
.
s
erver
.
HTTPServer
.
__init__
(
self
,
*
args
)
self
.
tree
=
os
.
path
.
abspath
(
tree
)
self
.
tree
=
os
.
path
.
abspath
(
tree
)
__run
=
True
__run
=
True
...
@@ -276,14 +279,14 @@ class Server(BaseHTTPServer.HTTPServer):
...
@@ -276,14 +279,14 @@ class Server(BaseHTTPServer.HTTPServer):
def
handle_error
(
self
,
*
_
):
def
handle_error
(
self
,
*
_
):
self
.
__run
=
False
self
.
__run
=
False
class
Handler
(
BaseHTTPS
erver
.
BaseHTTPRequestHandler
):
class
Handler
(
http
.
s
erver
.
BaseHTTPRequestHandler
):
Server
.
__log
=
False
Server
.
__log
=
False
def
__init__
(
self
,
request
,
address
,
server
):
def
__init__
(
self
,
request
,
address
,
server
):
self
.
__server
=
server
self
.
__server
=
server
self
.
tree
=
server
.
tree
self
.
tree
=
server
.
tree
BaseHTTPS
erver
.
BaseHTTPRequestHandler
.
__init__
(
http
.
s
erver
.
BaseHTTPRequestHandler
.
__init__
(
self
,
request
,
address
,
server
)
self
,
request
,
address
,
server
)
def
do_GET
(
self
):
def
do_GET
(
self
):
...
@@ -308,7 +311,7 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
...
@@ -308,7 +311,7 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
):
):
self
.
send_response
(
404
,
'Not Found'
)
self
.
send_response
(
404
,
'Not Found'
)
#self.send_response(200)
#self.send_response(200)
out
=
'<html><body>Not Found</body></html>'
out
=
'<html><body>Not Found</body></html>'
.
encode
()
#out = '\n'.join(self.tree, self.path, path)
#out = '\n'.join(self.tree, self.path, path)
self
.
send_header
(
'Content-Length'
,
str
(
len
(
out
)))
self
.
send_header
(
'Content-Length'
,
str
(
len
(
out
)))
self
.
send_header
(
'Content-Type'
,
'text/html'
)
self
.
send_header
(
'Content-Type'
,
'text/html'
)
...
@@ -326,7 +329,7 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
...
@@ -326,7 +329,7 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
name
+=
'/'
name
+=
'/'
out
.
append
(
'<a href="%s">%s</a><br>
\
n
'
%
(
name
,
name
))
out
.
append
(
'<a href="%s">%s</a><br>
\
n
'
%
(
name
,
name
))
out
.
append
(
'</body></html>
\
n
'
)
out
.
append
(
'</body></html>
\
n
'
)
out
=
''
.
join
(
out
)
out
=
''
.
join
(
out
)
.
encode
()
self
.
send_header
(
'Content-Length'
,
str
(
len
(
out
)))
self
.
send_header
(
'Content-Length'
,
str
(
len
(
out
)))
self
.
send_header
(
'Content-Type'
,
'text/html'
)
self
.
send_header
(
'Content-Type'
,
'text/html'
)
else
:
else
:
...
@@ -346,7 +349,7 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
...
@@ -346,7 +349,7 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
def
log_request
(
self
,
code
):
def
log_request
(
self
,
code
):
if
self
.
__server
.
__log
:
if
self
.
__server
.
__log
:
print
'%s %s %s'
%
(
self
.
command
,
code
,
self
.
path
)
print
_
(
'%s %s %s'
%
(
self
.
command
,
code
,
self
.
path
)
)
def
_run
(
tree
,
port
):
def
_run
(
tree
,
port
):
server_address
=
(
'localhost'
,
port
)
server_address
=
(
'localhost'
,
port
)
...
@@ -364,7 +367,7 @@ def get_port():
...
@@ -364,7 +367,7 @@ def get_port():
return
port
return
port
finally
:
finally
:
s
.
close
()
s
.
close
()
raise
RuntimeError
,
"Can't find port"
raise
RuntimeError
(
"Can't find port"
)
def
_start_server
(
tree
,
name
=
''
):
def
_start_server
(
tree
,
name
=
''
):
port
=
get_port
()
port
=
get_port
()
...
@@ -379,7 +382,7 @@ def start_server(tree):
...
@@ -379,7 +382,7 @@ def start_server(tree):
def
stop_server
(
url
,
thread
=
None
):
def
stop_server
(
url
,
thread
=
None
):
try
:
try
:
urllib
2
.
urlopen
(
url
+
'__stop__'
)
urllib
.
request
.
urlopen
(
url
+
'__stop__'
)
except
Exception
:
except
Exception
:
pass
pass
if
thread
is
not
None
:
if
thread
is
not
None
:
...
@@ -395,7 +398,7 @@ def wait(port, up):
...
@@ -395,7 +398,7 @@ def wait(port, up):
s
.
close
()
s
.
close
()
if
up
:
if
up
:
break
break
except
socket
.
error
,
e
:
except
socket
.
error
as
e
:
if
e
[
0
]
not
in
(
errno
.
ECONNREFUSED
,
errno
.
ECONNRESET
):
if
e
[
0
]
not
in
(
errno
.
ECONNREFUSED
,
errno
.
ECONNRESET
):
raise
raise
s
.
close
()
s
.
close
()
...
@@ -408,7 +411,7 @@ def wait(port, up):
...
@@ -408,7 +411,7 @@ def wait(port, up):
raise
SystemError
(
"Couln't stop server"
)
raise
SystemError
(
"Couln't stop server"
)
def
install
(
project
,
destination
):
def
install
(
project
,
destination
):
if
not
isinstance
(
destination
,
basestring
):
if
not
isinstance
(
destination
,
str
):
destination
=
os
.
path
.
join
(
destination
.
globs
[
'sample_buildout'
],
destination
=
os
.
path
.
join
(
destination
.
globs
[
'sample_buildout'
],
'eggs'
)
'eggs'
)
...
@@ -428,7 +431,7 @@ def install(project, destination):
...
@@ -428,7 +431,7 @@ def install(project, destination):
).
write
(
dist
.
location
)
).
write
(
dist
.
location
)
def
install_develop
(
project
,
destination
):
def
install_develop
(
project
,
destination
):
if
not
isinstance
(
destination
,
basestring
):
if
not
isinstance
(
destination
,
str
):
destination
=
os
.
path
.
join
(
destination
.
globs
[
'sample_buildout'
],
destination
=
os
.
path
.
join
(
destination
.
globs
[
'sample_buildout'
],
'develop-eggs'
)
'develop-eggs'
)
...
@@ -462,3 +465,7 @@ normalize_egg_py = (
...
@@ -462,3 +465,7 @@ normalize_egg_py = (
re
.
compile
(
'-py
\
d[.]
\
d(-
\
S+)?.egg
'
),
re
.
compile
(
'-py
\
d[.]
\
d(-
\
S+)?.egg
'
),
'
-
pyN
.
N
.
egg
',
'
-
pyN
.
N
.
egg
',
)
)
normalize_exception_type_for_python_2_and_3 = (
re.compile(r'
^
(
\
w
+
\
.)
*
([
A
-
Z
][
A
-
Za
-
z0
-
9
]
+
Error
:
)
'),
'
\
2
')
src/zc/buildout/testrecipes.py
View file @
83d53da5
from
zc.buildout.buildout
import
print_
class
Debug
:
class
Debug
:
...
@@ -7,10 +8,10 @@ class Debug:
...
@@ -7,10 +8,10 @@ class Debug:
self
.
options
=
options
self
.
options
=
options
def
install
(
self
):
def
install
(
self
):
items
=
self
.
options
.
items
(
)
items
=
list
(
self
.
options
.
items
()
)
items
.
sort
()
items
.
sort
()
for
option
,
value
in
items
:
for
option
,
value
in
items
:
print
" %s=%r"
%
(
option
,
value
)
print
_
(
" %s=%r"
%
(
option
,
value
)
)
return
()
return
()
update
=
install
update
=
install
src/zc/buildout/tests.py
View file @
83d53da5
...
@@ -11,7 +11,9 @@
...
@@ -11,7 +11,9 @@
# FOR A PARTICULAR PURPOSE.
# FOR A PARTICULAR PURPOSE.
#
#
##############################################################################
##############################################################################
from
zc.buildout.buildout
import
print_
from
zope.testing
import
renormalizing
from
zope.testing
import
renormalizing
import
doctest
import
doctest
import
os
import
os
import
pkg_resources
import
pkg_resources
...
@@ -47,7 +49,7 @@ We should be able to deal with setup scripts that aren't setuptools based.
...
@@ -47,7 +49,7 @@ We should be able to deal with setup scripts that aren't setuptools based.
... parts =
... parts =
... ''')
... ''')
>>> print
system(join('bin', 'buildout')),
>>> print
_(system(join('bin', 'buildout')), end=' ')
Develop: '/sample-buildout/foo'
Develop: '/sample-buildout/foo'
>>> ls('develop-eggs')
>>> ls('develop-eggs')
...
@@ -74,7 +76,8 @@ We should be able to deal with setup scripts that aren't setuptools based.
...
@@ -74,7 +76,8 @@ We should be able to deal with setup scripts that aren't setuptools based.
... parts =
... parts =
... ''')
... ''')
>>> print system(join('bin', 'buildout')+' -vv'), # doctest: +ELLIPSIS
>>> print_(system(join('bin', 'buildout')+' -vv'), end=' ')
... # doctest: +ELLIPSIS
Installing...
Installing...
Develop: '/sample-buildout/foo'
Develop: '/sample-buildout/foo'
...
...
...
@@ -85,7 +88,8 @@ We should be able to deal with setup scripts that aren't setuptools based.
...
@@ -85,7 +88,8 @@ We should be able to deal with setup scripts that aren't setuptools based.
- foo.egg-link
- foo.egg-link
- zc.recipe.egg.egg-link
- zc.recipe.egg.egg-link
>>> print system(join('bin', 'buildout')+' -vvv'), # doctest: +ELLIPSIS
>>> print_(system(join('bin', 'buildout')+' -vvv'), end=' ')
... # doctest: +ELLIPSIS
Installing...
Installing...
Develop: '/sample-buildout/foo'
Develop: '/sample-buildout/foo'
in: '/sample-buildout/foo'
in: '/sample-buildout/foo'
...
@@ -126,7 +130,8 @@ It is an error to create a variable-reference cycle:
...
@@ -126,7 +130,8 @@ It is an error to create a variable-reference cycle:
... z = ${buildout:x}
... z = ${buildout:x}
... ''')
... ''')
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
>>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout')),
... end=' ')
... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
While:
While:
Initializing.
Initializing.
...
@@ -148,7 +153,8 @@ It is an error to use funny characters in variable refereces:
...
@@ -148,7 +153,8 @@ It is an error to use funny characters in variable refereces:
... x = ${bui$ldout:y}
... x = ${bui$ldout:y}
... ''')
... ''')
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
>>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout')),
... end=' ')
While:
While:
Initializing.
Initializing.
Getting section buildout.
Getting section buildout.
...
@@ -165,7 +171,8 @@ It is an error to use funny characters in variable refereces:
...
@@ -165,7 +171,8 @@ It is an error to use funny characters in variable refereces:
... x = ${buildout:y{z}
... x = ${buildout:y{z}
... ''')
... ''')
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
>>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout')),
... end=' ')
While:
While:
Initializing.
Initializing.
Getting section buildout.
Getting section buildout.
...
@@ -184,7 +191,8 @@ and too have too many or too few colons:
...
@@ -184,7 +191,8 @@ and too have too many or too few colons:
... x = ${parts}
... x = ${parts}
... ''')
... ''')
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
>>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout')),
... end=' ')
While:
While:
Initializing.
Initializing.
Getting section buildout.
Getting section buildout.
...
@@ -201,7 +209,8 @@ and too have too many or too few colons:
...
@@ -201,7 +209,8 @@ and too have too many or too few colons:
... x = ${buildout:y:z}
... x = ${buildout:y:z}
... ''')
... ''')
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
>>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout')),
... end=' ')
While:
While:
Initializing.
Initializing.
Getting section buildout.
Getting section buildout.
...
@@ -218,7 +227,8 @@ Al parts have to have a section:
...
@@ -218,7 +227,8 @@ Al parts have to have a section:
... parts = x
... parts = x
... ''')
... ''')
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
>>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout')),
... end=' ')
While:
While:
Installing.
Installing.
Getting section x.
Getting section x.
...
@@ -236,7 +246,8 @@ and all parts have to have a specified recipe:
...
@@ -236,7 +246,8 @@ and all parts have to have a specified recipe:
... foo = 1
... foo = 1
... ''')
... ''')
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
>>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout')),
... end=' ')
While:
While:
Installing.
Installing.
Error: Missing option: x:recipe
Error: Missing option: x:recipe
...
@@ -285,7 +296,7 @@ Now, let's create a buildout that requires y and z:
...
@@ -285,7 +296,7 @@ Now, let's create a buildout that requires y and z:
... samplez
... samplez
... ''' % globals())
... ''' % globals())
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/sampley'
Develop: '/sample-buildout/sampley'
Develop: '/sample-buildout/samplez'
Develop: '/sample-buildout/samplez'
Installing eggs.
Installing eggs.
...
@@ -318,7 +329,7 @@ if we hadn't required sampley ourselves:
...
@@ -318,7 +329,7 @@ if we hadn't required sampley ourselves:
If we use the verbose switch, we can see where requirements are coming from:
If we use the verbose switch, we can see where requirements are coming from:
>>> print
system(buildout+' -v'),
# doctest: +ELLIPSIS
>>> print
_(system(buildout+' -v'), end=' ')
# doctest: +ELLIPSIS
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout', 'distribute'.
We have a develop egg: zc.buildout 1.0.0
We have a develop egg: zc.buildout 1.0.0
We have the best distribution that satisfies 'distribute'.
We have the best distribution that satisfies 'distribute'.
...
@@ -369,7 +380,7 @@ buildout will tell us who's asking for something that we can't find.
...
@@ -369,7 +380,7 @@ buildout will tell us who's asking for something that we can't find.
... eggs = samplea
... eggs = samplea
... ''')
... ''')
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/sampley'
Develop: '/sample-buildout/sampley'
Develop: '/sample-buildout/samplea'
Develop: '/sample-buildout/samplea'
Develop: '/sample-buildout/sampleb'
Develop: '/sample-buildout/sampleb'
...
@@ -446,14 +457,14 @@ the comparison with the saved value works correctly.
...
@@ -446,14 +457,14 @@ the comparison with the saved value works correctly.
>>> os.chdir(sample_buildout)
>>> os.chdir(sample_buildout)
>>> buildout = os.path.join(sample_buildout, 'bin', 'buildout')
>>> buildout = os.path.join(sample_buildout, 'bin', 'buildout')
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing debug.
Installing debug.
If we run the buildout again, we shoudn't get a message about
If we run the buildout again, we shoudn't get a message about
uninstalling anything because the configuration hasn't changed.
uninstalling anything because the configuration hasn't changed.
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Updating debug.
Updating debug.
"""
"""
...
@@ -507,7 +518,8 @@ def create_sections_on_command_line():
...
@@ -507,7 +518,8 @@ def create_sections_on_command_line():
... x = ${foo:bar}
... x = ${foo:bar}
... ''')
... ''')
>>> print system(buildout + ' foo:bar=1 -vv'), # doctest: +ELLIPSIS
>>> print_(system(buildout + ' foo:bar=1 -vv'), end=' ')
... # doctest: +ELLIPSIS
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout', 'distribute'.
...
...
[foo]
[foo]
...
@@ -518,7 +530,7 @@ def create_sections_on_command_line():
...
@@ -518,7 +530,7 @@ def create_sections_on_command_line():
def
test_help
():
def
test_help
():
"""
"""
>>> print
system(os.path.join(sample_buildout, 'bin', 'buildout')+' -h'),
>>> print
_(system(os.path.join(sample_buildout, 'bin', 'buildout')+' -h'))
... # doctest: +ELLIPSIS
... # doctest: +ELLIPSIS
Usage: buildout [options] [assignments] [command [command arguments]]
Usage: buildout [options] [assignments] [command [command arguments]]
<BLANKLINE>
<BLANKLINE>
...
@@ -527,8 +539,8 @@ def test_help():
...
@@ -527,8 +539,8 @@ def test_help():
-h, --help
-h, --help
...
...
>>> print
system(os.path.join(sample_buildout, 'bin', 'buildout')
>>> print
_(
system(os.path.join(sample_buildout, 'bin', 'buildout')
... +' --help')
,
... +' --help')
)
... # doctest: +ELLIPSIS
... # doctest: +ELLIPSIS
Usage: buildout [options] [assignments] [command [command arguments]]
Usage: buildout [options] [assignments] [command [command arguments]]
<BLANKLINE>
<BLANKLINE>
...
@@ -554,8 +566,8 @@ bootstrapping.
...
@@ -554,8 +566,8 @@ bootstrapping.
... ''')
... ''')
>>> os.chdir(d)
>>> os.chdir(d)
>>> print
system(os.path.join(sample_buildout, 'bin', 'buildout')
>>> print
_(
system(os.path.join(sample_buildout, 'bin', 'buildout')
... + ' bootstrap'),
... + ' bootstrap'),
end=' ')
Creating directory '/sample-bootstrap/bin'.
Creating directory '/sample-bootstrap/bin'.
Creating directory '/sample-bootstrap/parts'.
Creating directory '/sample-bootstrap/parts'.
Creating directory '/sample-bootstrap/eggs'.
Creating directory '/sample-bootstrap/eggs'.
...
@@ -581,15 +593,15 @@ def bug_92891_bootstrap_crashes_with_egg_recipe_in_buildout_section():
...
@@ -581,15 +593,15 @@ def bug_92891_bootstrap_crashes_with_egg_recipe_in_buildout_section():
... ''')
... ''')
>>> os.chdir(d)
>>> os.chdir(d)
>>> print
system(os.path.join(sample_buildout, 'bin', 'buildout')
>>> print
_(
system(os.path.join(sample_buildout, 'bin', 'buildout')
... + ' bootstrap'),
... + ' bootstrap'),
end=' ')
Creating directory '/sample-bootstrap/bin'.
Creating directory '/sample-bootstrap/bin'.
Creating directory '/sample-bootstrap/parts'.
Creating directory '/sample-bootstrap/parts'.
Creating directory '/sample-bootstrap/eggs'.
Creating directory '/sample-bootstrap/eggs'.
Creating directory '/sample-bootstrap/develop-eggs'.
Creating directory '/sample-bootstrap/develop-eggs'.
Generated script '/sample-bootstrap/bin/buildout'.
Generated script '/sample-bootstrap/bin/buildout'.
>>> print
system(os.path.join('bin', 'buildout')),
>>> print
_(system(os.path.join('bin', 'buildout')), end=' ')
Unused options for buildout: 'scripts' 'eggs'.
Unused options for buildout: 'scripts' 'eggs'.
"""
"""
...
@@ -613,7 +625,7 @@ Create a develop egg:
...
@@ -613,7 +625,7 @@ Create a develop egg:
... parts =
... parts =
... """)
... """)
>>> print
system(join('bin', 'buildout')),
>>> print
_(system(join('bin', 'buildout')), end=' ')
Develop: '/sample-buildout/foo'
Develop: '/sample-buildout/foo'
>>> ls('develop-eggs')
>>> ls('develop-eggs')
...
@@ -635,7 +647,7 @@ Create another:
...
@@ -635,7 +647,7 @@ Create another:
... parts =
... parts =
... """)
... """)
>>> print
system(join('bin', 'buildout')),
>>> print
_(system(join('bin', 'buildout')), end=' ')
Develop: '/sample-buildout/foo'
Develop: '/sample-buildout/foo'
Develop: '/sample-buildout/bar'
Develop: '/sample-buildout/bar'
...
@@ -652,7 +664,7 @@ Remove one:
...
@@ -652,7 +664,7 @@ Remove one:
... develop = bar
... develop = bar
... parts =
... parts =
... """)
... """)
>>> print
system(join('bin', 'buildout')),
>>> print
_(system(join('bin', 'buildout')), end=' ')
Develop: '/sample-buildout/bar'
Develop: '/sample-buildout/bar'
It is gone
It is gone
...
@@ -668,7 +680,7 @@ Remove the other:
...
@@ -668,7 +680,7 @@ Remove the other:
... [buildout]
... [buildout]
... parts =
... parts =
... """)
... """)
>>> print
system(join('bin', 'buildout')),
>>> print
_(system(join('bin', 'buildout')), end=' ')
All gone
All gone
...
@@ -713,7 +725,7 @@ a devlop egg, we will also generate a warning.
...
@@ -713,7 +725,7 @@ a devlop egg, we will also generate a warning.
... parts =
... parts =
... """)
... """)
>>> print
system(join('bin', 'buildout')),
>>> print
_(system(join('bin', 'buildout')), end=' ')
Develop: '/sample-buildout/foo'
Develop: '/sample-buildout/foo'
Now, if we generate a working set using the egg link, we will get a warning
Now, if we generate a working set using the egg link, we will get a warning
...
@@ -732,7 +744,7 @@ and we will get distribute included in the working set.
...
@@ -732,7 +744,7 @@ and we will get distribute included in the working set.
... ])]
... ])]
['foox', 'distribute']
['foox', 'distribute']
>>> print
handler
>>> print
_(handler)
zc.buildout.easy_install WARNING
zc.buildout.easy_install WARNING
Develop distribution: foox 0.0.0
Develop distribution: foox 0.0.0
uses namespace packages but the distribution does not require distribute.
uses namespace packages but the distribution does not require distribute.
...
@@ -764,7 +776,7 @@ We do not get a warning, but we do get distribute included in the working set:
...
@@ -764,7 +776,7 @@ We do not get a warning, but we do get distribute included in the working set:
... ])]
... ])]
['foox', 'distribute']
['foox', 'distribute']
>>> print
handler,
>>> print
_(handler, end=' ')
We get the same behavior if the it is a depedency that uses a
We get the same behavior if the it is a depedency that uses a
namespace package.
namespace package.
...
@@ -785,7 +797,7 @@ namespace package.
...
@@ -785,7 +797,7 @@ namespace package.
... parts =
... parts =
... """)
... """)
>>> print
system(join('bin', 'buildout')),
>>> print
_(system(join('bin', 'buildout')), end=' ')
Develop: '/sample-buildout/foo'
Develop: '/sample-buildout/foo'
Develop: '/sample-buildout/bar'
Develop: '/sample-buildout/bar'
...
@@ -797,7 +809,7 @@ namespace package.
...
@@ -797,7 +809,7 @@ namespace package.
... ])]
... ])]
['bar', 'foox', 'distribute']
['bar', 'foox', 'distribute']
>>> print
handler,
>>> print
_(handler, end=' ')
zc.buildout.easy_install WARNING
zc.buildout.easy_install WARNING
Develop distribution: foox 0.0.0
Develop distribution: foox 0.0.0
uses namespace packages but the distribution does not require distribute.
uses namespace packages but the distribution does not require distribute.
...
@@ -854,7 +866,7 @@ existing setup.cfg:
...
@@ -854,7 +866,7 @@ existing setup.cfg:
"""
"""
def
uninstall_recipes_used_for_removal
():
def
uninstall_recipes_used_for_removal
():
"""
r
"""
Uninstall recipes need to be called when a part is removed too:
Uninstall recipes need to be called when a part is removed too:
>>> mkdir("recipes")
>>> mkdir("recipes")
...
@@ -869,13 +881,15 @@ Uninstall recipes need to be called when a part is removed too:
...
@@ -869,13 +881,15 @@ Uninstall recipes need to be called when a part is removed too:
... ''')
... ''')
>>> write("recipes", "demo.py",
>>> write("recipes", "demo.py",
... '''
... r'''
... import sys
... class Install:
... class Install:
... def __init__(*args): pass
... def __init__(*args): pass
... def install(self):
... def install(self):
...
print 'installing'
...
sys.stdout.write('installing\n')
... return ()
... return ()
... def uninstall(name, options): print 'uninstalling'
... def uninstall(name, options):
... sys.stdout.write('uninstalling\n')
... ''')
... ''')
>>> write('buildout.cfg', '''
>>> write('buildout.cfg', '''
...
@@ -886,7 +900,7 @@ Uninstall recipes need to be called when a part is removed too:
...
@@ -886,7 +900,7 @@ Uninstall recipes need to be called when a part is removed too:
... recipe = recipes:demo
... recipe = recipes:demo
... ''')
... ''')
>>> print
system(join('bin', 'buildout')),
>>> print
_(system(join('bin', 'buildout')), end=' ')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing demo.
Installing demo.
installing
installing
...
@@ -901,7 +915,7 @@ Uninstall recipes need to be called when a part is removed too:
...
@@ -901,7 +915,7 @@ Uninstall recipes need to be called when a part is removed too:
... x = 1
... x = 1
... ''')
... ''')
>>> print
system(join('bin', 'buildout')),
>>> print
_(system(join('bin', 'buildout')), end=' ')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling demo.
Uninstalling demo.
Running uninstall recipe.
Running uninstall recipe.
...
@@ -916,7 +930,7 @@ Uninstall recipes need to be called when a part is removed too:
...
@@ -916,7 +930,7 @@ Uninstall recipes need to be called when a part is removed too:
... parts =
... parts =
... ''')
... ''')
>>> print
system(join('bin', 'buildout')),
>>> print
_(system(join('bin', 'buildout')), end=' ')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling demo.
Uninstalling demo.
Running uninstall recipe.
Running uninstall recipe.
...
@@ -931,7 +945,7 @@ def extensions_installed_as_eggs_work_in_offline_mode():
...
@@ -931,7 +945,7 @@ def extensions_installed_as_eggs_work_in_offline_mode():
>>> write('demo', 'demo.py',
>>> write('demo', 'demo.py',
... """
... """
... def ext(buildout):
... def ext(buildout):
... print
'ext', list(buildout
)
... print
_('ext', list(buildout)
)
... """)
... """)
>>> write('demo', 'setup.py',
>>> write('demo', 'setup.py',
...
@@ -956,7 +970,7 @@ def extensions_installed_as_eggs_work_in_offline_mode():
...
@@ -956,7 +970,7 @@ def extensions_installed_as_eggs_work_in_offline_mode():
... offline = true
... offline = true
... """)
... """)
>>> print
system(join(sample_buildout, 'bin', 'buildout')),
>>> print
_(system(join(sample_buildout, 'bin', 'buildout')), end=' ')
ext ['buildout']
ext ['buildout']
...
@@ -994,20 +1008,20 @@ changes in .svn or CVS directories.
...
@@ -994,20 +1008,20 @@ changes in .svn or CVS directories.
... ''')
... ''')
>>> print
system(join(sample_buildout, 'bin', 'buildout')),
>>> print
_(system(join(sample_buildout, 'bin', 'buildout')), end=' ')
Develop: '/sample-buildout/recipe'
Develop: '/sample-buildout/recipe'
Installing foo.
Installing foo.
>>> mkdir('recipe', '.svn')
>>> mkdir('recipe', '.svn')
>>> mkdir('recipe', 'CVS')
>>> mkdir('recipe', 'CVS')
>>> print
system(join(sample_buildout, 'bin', 'buildout')),
>>> print
_(system(join(sample_buildout, 'bin', 'buildout')), end=' ')
Develop: '/sample-buildout/recipe'
Develop: '/sample-buildout/recipe'
Updating foo.
Updating foo.
>>> write('recipe', '.svn', 'x', '1')
>>> write('recipe', '.svn', 'x', '1')
>>> write('recipe', 'CVS', 'x', '1')
>>> write('recipe', 'CVS', 'x', '1')
>>> print
system(join(sample_buildout, 'bin', 'buildout')),
>>> print
_(system(join(sample_buildout, 'bin', 'buildout')), end=' ')
Develop: '/sample-buildout/recipe'
Develop: '/sample-buildout/recipe'
Updating foo.
Updating foo.
...
@@ -1046,7 +1060,7 @@ because of the missing target file.
...
@@ -1046,7 +1060,7 @@ because of the missing target file.
... ''')
... ''')
>>> print
system(join(sample_buildout, 'bin', 'buildout')),
>>> print
_(system(join(sample_buildout, 'bin', 'buildout')), end=' ')
Develop: '/sample-buildout/recipe'
Develop: '/sample-buildout/recipe'
Installing foo.
Installing foo.
...
@@ -1063,7 +1077,7 @@ because of the missing target file.
...
@@ -1063,7 +1077,7 @@ because of the missing target file.
>>> remove('recipe', 'some-file')
>>> remove('recipe', 'some-file')
>>> print
system(join(sample_buildout, 'bin', 'buildout')),
>>> print
_(system(join(sample_buildout, 'bin', 'buildout')), end=' ')
Develop: '/sample-buildout/recipe'
Develop: '/sample-buildout/recipe'
Updating foo.
Updating foo.
...
@@ -1071,7 +1085,7 @@ because of the missing target file.
...
@@ -1071,7 +1085,7 @@ because of the missing target file.
def
o_option_sets_offline
():
def
o_option_sets_offline
():
"""
"""
>>> print
system(join(sample_buildout, 'bin', 'buildout')+' -vvo'),
>>> print
_(system(join(sample_buildout, 'bin', 'buildout')+' -vvo'), end=' ')
... # doctest: +ELLIPSIS
... # doctest: +ELLIPSIS
<BLANKLINE>
<BLANKLINE>
...
...
...
@@ -1080,7 +1094,7 @@ def o_option_sets_offline():
...
@@ -1080,7 +1094,7 @@ def o_option_sets_offline():
"""
"""
def
recipe_upgrade
():
def
recipe_upgrade
():
"""
r
"""
The buildout will upgrade recipes in newest (and non-offline) mode.
The buildout will upgrade recipes in newest (and non-offline) mode.
...
@@ -1088,11 +1102,12 @@ Let's create a recipe egg
...
@@ -1088,11 +1102,12 @@ Let's create a recipe egg
>>> mkdir('recipe')
>>> mkdir('recipe')
>>> write('recipe', 'recipe.py',
>>> write('recipe', 'recipe.py',
... '''
... r'''
... import sys
... class Recipe:
... class Recipe:
... def __init__(*a): pass
... def __init__(*a): pass
... def install(self):
... def install(self):
...
print 'recipe v1'
...
sys.stdout.write('recipe v1\n')
... return ()
... return ()
... update = install
... update = install
... ''')
... ''')
...
@@ -1107,7 +1122,7 @@ Let's create a recipe egg
...
@@ -1107,7 +1122,7 @@ Let's create a recipe egg
>>> write('recipe', 'README', '')
>>> write('recipe', 'README', '')
>>> print
system(buildout+' setup recipe bdist_egg'),
# doctest: +ELLIPSIS
>>> print
_(system(buildout+' setup recipe bdist_egg'))
# doctest: +ELLIPSIS
Running setup script 'recipe/setup.py'.
Running setup script 'recipe/setup.py'.
...
...
...
@@ -1125,7 +1140,7 @@ And update our buildout to use it.
...
@@ -1125,7 +1140,7 @@ And update our buildout to use it.
... recipe = recipe
... recipe = recipe
... ''' % join('recipe', 'dist'))
... ''' % join('recipe', 'dist'))
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Getting distribution for 'recipe'.
Getting distribution for 'recipe'.
Got recipe 1.
Got recipe 1.
Installing foo.
Installing foo.
...
@@ -1134,11 +1149,12 @@ And update our buildout to use it.
...
@@ -1134,11 +1149,12 @@ And update our buildout to use it.
Now, if we update the recipe egg:
Now, if we update the recipe egg:
>>> write('recipe', 'recipe.py',
>>> write('recipe', 'recipe.py',
... '''
... r'''
... import sys
... class Recipe:
... class Recipe:
... def __init__(*a): pass
... def __init__(*a): pass
... def install(self):
... def install(self):
...
print 'recipe v2'
...
sys.stdout.write('recipe v2\n')
... return ()
... return ()
... update = install
... update = install
... ''')
... ''')
...
@@ -1152,25 +1168,25 @@ Now, if we update the recipe egg:
...
@@ -1152,25 +1168,25 @@ Now, if we update the recipe egg:
... ''')
... ''')
>>> print
system(buildout+' setup recipe bdist_egg'),
# doctest: +ELLIPSIS
>>> print
_(system(buildout+' setup recipe bdist_egg'))
# doctest: +ELLIPSIS
Running setup script 'recipe/setup.py'.
Running setup script 'recipe/setup.py'.
...
...
We won't get the update if we specify -N:
We won't get the update if we specify -N:
>>> print
system(buildout+' -N'),
>>> print
_(system(buildout+' -N'), end=' ')
Updating foo.
Updating foo.
recipe v1
recipe v1
or if we use -o:
or if we use -o:
>>> print
system(buildout+' -o'),
>>> print
_(system(buildout+' -o'), end=' ')
Updating foo.
Updating foo.
recipe v1
recipe v1
But we will if we use neither of these:
But we will if we use neither of these:
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Getting distribution for 'recipe'.
Getting distribution for 'recipe'.
Got recipe 2.
Got recipe 2.
Uninstalling foo.
Uninstalling foo.
...
@@ -1189,7 +1205,7 @@ We can also select a particular recipe version:
...
@@ -1189,7 +1205,7 @@ We can also select a particular recipe version:
... recipe = recipe ==1
... recipe = recipe ==1
... ''' % join('recipe', 'dist'))
... ''' % join('recipe', 'dist'))
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Uninstalling foo.
Uninstalling foo.
Installing foo.
Installing foo.
recipe v1
recipe v1
...
@@ -1238,11 +1254,11 @@ uninstall
...
@@ -1238,11 +1254,11 @@ uninstall
... recipe = recipe
... recipe = recipe
... ''')
... ''')
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/recipe'
Develop: '/sample-buildout/recipe'
Installing foo.
Installing foo.
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/recipe'
Develop: '/sample-buildout/recipe'
Updating foo.
Updating foo.
...
@@ -1274,7 +1290,7 @@ def log_when_there_are_not_local_distros():
...
@@ -1274,7 +1290,7 @@ def log_when_there_are_not_local_distros():
... ['demo==0.2'], dest,
... ['demo==0.2'], dest,
... links=[link_server], index=link_server+'index/')
... links=[link_server], index=link_server+'index/')
>>> print
handler
# doctest: +ELLIPSIS
>>> print
_(handler)
# doctest: +ELLIPSIS
zc.buildout.easy_install DEBUG
zc.buildout.easy_install DEBUG
Installing 'demo==0.2'.
Installing 'demo==0.2'.
zc.buildout.easy_install DEBUG
zc.buildout.easy_install DEBUG
...
@@ -1320,7 +1336,7 @@ def internal_errors():
...
@@ -1320,7 +1336,7 @@ def internal_errors():
... recipe = recipes:mkdir
... recipe = recipes:mkdir
... ''')
... ''')
>>> print
system(buildout),
# doctest: +ELLIPSIS
>>> print
_(system(buildout), end=' ')
# doctest: +ELLIPSIS
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
While:
While:
Installing.
Installing.
...
@@ -1372,7 +1388,7 @@ def whine_about_unused_options():
...
@@ -1372,7 +1388,7 @@ def whine_about_unused_options():
... z = 1
... z = 1
... """)
... """)
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/.'
Develop: '/sample-buildout/.'
Unused options for buildout: 'a'.
Unused options for buildout: 'a'.
Installing foo.
Installing foo.
...
@@ -1440,19 +1456,19 @@ Now let's look at 3 cases:
...
@@ -1440,19 +1456,19 @@ Now let's look at 3 cases:
... recipe = recipes:clean
... recipe = recipes:clean
... ''')
... ''')
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing p1.
Installing p1.
Installing p2.
Installing p2.
Installing p3.
Installing p3.
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Updating p1.
Updating p1.
Updating p2.
Updating p2.
Installing p3.
Installing p3.
>>> print
system(buildout+' buildout:parts='),
>>> print
_(system(buildout+' buildout:parts='), end=' ')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling p2.
Uninstalling p2.
Uninstalling p1.
Uninstalling p1.
...
@@ -1478,20 +1494,20 @@ Now let's look at 3 cases:
...
@@ -1478,20 +1494,20 @@ Now let's look at 3 cases:
... recipe = recipes:clean
... recipe = recipes:clean
... ''')
... ''')
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing p1.
Installing p1.
Installing p2.
Installing p2.
Installing p3.
Installing p3.
Installing p4.
Installing p4.
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Updating p1.
Updating p1.
Updating p2.
Updating p2.
Updating p3.
Updating p3.
>>> print
system(buildout+' buildout:parts='),
>>> print
_(system(buildout+' buildout:parts='), end=' ')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling p2.
Uninstalling p2.
Uninstalling p1.
Uninstalling p1.
...
@@ -1519,7 +1535,7 @@ Now let's look at 3 cases:
...
@@ -1519,7 +1535,7 @@ Now let's look at 3 cases:
... recipe = recipes:clean
... recipe = recipes:clean
... ''')
... ''')
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Installing p1.
Installing p1.
Installing p2.
Installing p2.
...
@@ -1546,7 +1562,7 @@ Now let's look at 3 cases:
...
@@ -1546,7 +1562,7 @@ Now let's look at 3 cases:
... x = 1
... x = 1
... ''')
... ''')
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling p4.
Uninstalling p4.
Updating p1.
Updating p1.
...
@@ -1570,7 +1586,7 @@ Now let's look at 3 cases:
...
@@ -1570,7 +1586,7 @@ Now let's look at 3 cases:
... recipe = recipes:clean
... recipe = recipes:clean
... ''')
... ''')
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/recipes'
Develop: '/sample-buildout/recipes'
Uninstalling p1.
Uninstalling p1.
Installing p1.
Installing p1.
...
@@ -1581,7 +1597,7 @@ Now let's look at 3 cases:
...
@@ -1581,7 +1597,7 @@ Now let's look at 3 cases:
"""
"""
def
install_source_dist_with_bad_py
():
def
install_source_dist_with_bad_py
():
"""
r
"""
>>> mkdir('badegg')
>>> mkdir('badegg')
>>> mkdir('badegg', 'badegg')
>>> mkdir('badegg', 'badegg')
...
@@ -1603,7 +1619,7 @@ def install_source_dist_with_bad_py():
...
@@ -1603,7 +1619,7 @@ def install_source_dist_with_bad_py():
... zip_safe=False)
... zip_safe=False)
... ''')
... ''')
>>> print
system(buildout+' setup badegg sdist'),
# doctest: +ELLIPSIS
>>> print
_(system(buildout+' setup badegg sdist'), end=' ')
# doctest: +ELLIPSIS
Running setup script 'badegg/setup.py'.
Running setup script 'badegg/setup.py'.
...
...
...
@@ -1625,7 +1641,7 @@ def install_source_dist_with_bad_py():
...
@@ -1625,7 +1641,7 @@ def install_source_dist_with_bad_py():
... scripts = buildout=bo
... scripts = buildout=bo
... ''' % globals())
... ''' % globals())
>>> print
system(buildout);print 'X'
# doctest: +ELLIPSIS
>>> print
_(system(buildout));print_('X')
# doctest: +ELLIPSIS
Installing eggs.
Installing eggs.
Getting distribution for 'badegg'.
Getting distribution for 'badegg'.
Got badegg 1.
Got badegg 1.
...
@@ -1687,7 +1703,7 @@ def bug_105081_Specific_egg_versions_are_ignored_when_newer_eggs_are_around():
...
@@ -1687,7 +1703,7 @@ def bug_105081_Specific_egg_versions_are_ignored_when_newer_eggs_are_around():
... eggs = demo
... eggs = demo
... ''' % globals())
... ''' % globals())
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Installing x.
Installing x.
Getting distribution for 'demo'.
Getting distribution for 'demo'.
Got demo 0.4c1.
Got demo 0.4c1.
...
@@ -1695,7 +1711,7 @@ def bug_105081_Specific_egg_versions_are_ignored_when_newer_eggs_are_around():
...
@@ -1695,7 +1711,7 @@ def bug_105081_Specific_egg_versions_are_ignored_when_newer_eggs_are_around():
Got demoneeded 1.2c1.
Got demoneeded 1.2c1.
Generated script '/sample-buildout/bin/demo'.
Generated script '/sample-buildout/bin/demo'.
>>> print
system(join('bin', 'demo')),
>>> print
_(system(join('bin', 'demo')), end=' ')
4 2
4 2
>>> write('buildout.cfg',
>>> write('buildout.cfg',
...
@@ -1709,14 +1725,14 @@ def bug_105081_Specific_egg_versions_are_ignored_when_newer_eggs_are_around():
...
@@ -1709,14 +1725,14 @@ def bug_105081_Specific_egg_versions_are_ignored_when_newer_eggs_are_around():
... eggs = demo ==0.1
... eggs = demo ==0.1
... ''' % globals())
... ''' % globals())
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Uninstalling x.
Uninstalling x.
Installing x.
Installing x.
Getting distribution for 'demo==0.1'.
Getting distribution for 'demo==0.1'.
Got demo 0.1.
Got demo 0.1.
Generated script '/sample-buildout/bin/demo'.
Generated script '/sample-buildout/bin/demo'.
>>> print
system(join('bin', 'demo')),
>>> print
_(system(join('bin', 'demo')), end=' ')
1 2
1 2
"""
"""
...
@@ -1728,8 +1744,8 @@ if sys.version_info > (2, 4):
...
@@ -1728,8 +1744,8 @@ if sys.version_info > (2, 4):
... p = subprocess.Popen(s, stdin=subprocess.PIPE,
... p = subprocess.Popen(s, stdin=subprocess.PIPE,
... stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
... stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
... p.stdin.close()
... p.stdin.close()
... print
p.stdout.read(
)
... print
_(p.stdout.read().decode()
)
... print
'Exit:', bool(p.wait(
))
... print
_('Exit:', bool(p.wait()
))
>>> call(buildout)
>>> call(buildout)
<BLANKLINE>
<BLANKLINE>
...
@@ -1791,20 +1807,20 @@ if sys.version_info > (2, 4):
...
@@ -1791,20 +1807,20 @@ if sys.version_info > (2, 4):
"""
"""
def
bug_59270_recipes_always_start_in_buildout_dir
():
def
bug_59270_recipes_always_start_in_buildout_dir
():
"""
r
"""
Recipes can rely on running from buildout directory
Recipes can rely on running from buildout directory
>>> mkdir('bad_start')
>>> mkdir('bad_start')
>>> write('bad_recipe.py',
>>> write('bad_recipe.py',
... '''
...
r
'''
... import os
... import os
, sys
... class Bad:
... class Bad:
... def __init__(self, *_):
... def __init__(self, *_):
... print os.getcwd()
... print os.getcwd()
... def install(self):
... def install(self):
...
print os.getcwd(
)
...
sys.stdout.write(os.getcwd()+'\n'
)
... os.chdir('bad_start')
... os.chdir('bad_start')
...
print os.getcwd(
)
...
sys.stdout.write(os.getcwd()+'\n'
)
... return ()
... return ()
... ''')
... ''')
...
@@ -1827,8 +1843,8 @@ def bug_59270_recipes_always_start_in_buildout_dir():
...
@@ -1827,8 +1843,8 @@ def bug_59270_recipes_always_start_in_buildout_dir():
... ''')
... ''')
>>> os.chdir('bad_start')
>>> os.chdir('bad_start')
>>> print
system(join(sample_buildout, 'bin', 'buildout')
>>> print
_(
system(join(sample_buildout, 'bin', 'buildout')
... +' -c '+join(sample_buildout, 'buildout.cfg')),
... +' -c '+join(sample_buildout, 'buildout.cfg')),
end=' ')
Develop: '/sample-buildout/.'
Develop: '/sample-buildout/.'
/sample-buildout
/sample-buildout
/sample-buildout
/sample-buildout
...
@@ -1857,7 +1873,7 @@ def bug_61890_file_urls_dont_seem_to_work_in_find_dash_links():
...
@@ -1857,7 +1873,7 @@ def bug_61890_file_urls_dont_seem_to_work_in_find_dash_links():
>>> for dist in ws:
>>> for dist in ws:
... print
dist
... print
_(dist)
demo 0.2
demo 0.2
demoneeded 1.1
demoneeded 1.1
...
@@ -1870,7 +1886,7 @@ def bug_61890_file_urls_dont_seem_to_work_in_find_dash_links():
...
@@ -1870,7 +1886,7 @@ def bug_61890_file_urls_dont_seem_to_work_in_find_dash_links():
def
bug_75607_buildout_should_not_run_if_it_creates_an_empty_buildout_cfg
():
def
bug_75607_buildout_should_not_run_if_it_creates_an_empty_buildout_cfg
():
"""
"""
>>> remove('buildout.cfg')
>>> remove('buildout.cfg')
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
While:
While:
Initializing.
Initializing.
Error: Couldn't open /sample-buildout/buildout.cfg
Error: Couldn't open /sample-buildout/buildout.cfg
...
@@ -1911,7 +1927,7 @@ def dealing_with_extremely_insane_dependencies():
...
@@ -1911,7 +1927,7 @@ def dealing_with_extremely_insane_dependencies():
... eggs = pack0
... eggs = pack0
... ''')
... ''')
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/pack0'
Develop: '/sample-buildout/pack0'
Develop: '/sample-buildout/pack1'
Develop: '/sample-buildout/pack1'
Develop: '/sample-buildout/pack2'
Develop: '/sample-buildout/pack2'
...
@@ -1927,7 +1943,7 @@ def dealing_with_extremely_insane_dependencies():
...
@@ -1927,7 +1943,7 @@ def dealing_with_extremely_insane_dependencies():
However, if we run in verbose mode, we can see why packages were included:
However, if we run in verbose mode, we can see why packages were included:
>>> print
system(buildout+' -v'),
# doctest: +ELLIPSIS
>>> print
_(system(buildout+' -v'), end=' ')
# doctest: +ELLIPSIS
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout', 'distribute'.
We have a develop egg: zc.buildout 1.0.0
We have a develop egg: zc.buildout 1.0.0
We have the best distribution that satisfies 'distribute'.
We have the best distribution that satisfies 'distribute'.
...
@@ -1992,7 +2008,7 @@ We'll create a wacky buildout extension that is just another name for http:
...
@@ -1992,7 +2008,7 @@ We'll create a wacky buildout extension that is just another name for http:
... },
... },
... )
... )
... ''')
... ''')
>>> print
system(buildout+' setup '+src+' bdist_egg'),
>>> print
_(system(buildout+' setup '+src+' bdist_egg'), end=' ')
... # doctest: +ELLIPSIS
... # doctest: +ELLIPSIS
Running setup ...
Running setup ...
creating 'dist/wackyextension-1-...
creating 'dist/wackyextension-1-...
...
@@ -2016,7 +2032,7 @@ Now we'll create a buildout that uses this extension to load other packages:
...
@@ -2016,7 +2032,7 @@ Now we'll create a buildout that uses this extension to load other packages:
When we run the buildout. it will load the extension from the dist
When we run the buildout. it will load the extension from the dist
directory and then use the wacky extension to load the demo package
directory and then use the wacky extension to load the demo package
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Getting distribution for 'wackyextension'.
Getting distribution for 'wackyextension'.
Got wackyextension 1.
Got wackyextension 1.
Installing demo.
Installing demo.
...
@@ -2038,7 +2054,7 @@ need to make it to the download cache.
...
@@ -2038,7 +2054,7 @@ need to make it to the download cache.
... setup(name='foo')
... setup(name='foo')
... ''')
... ''')
>>> print
system(buildout+' setup test bdist_egg'),
# doctest: +ELLIPSIS
>>> print
_(system(buildout+' setup test bdist_egg'))
# doctest: +ELLIPSIS
Running setup script 'test/setup.py'.
Running setup script 'test/setup.py'.
...
...
...
@@ -2098,9 +2114,9 @@ def prefer_final_permutation(existing, available):
...
@@ -2098,9 +2114,9 @@ def prefer_final_permutation(existing, available):
)
)
if
dist
.
extras
:
if
dist
.
extras
:
print
'downloaded'
,
dist
.
version
print
_
(
'downloaded'
,
dist
.
version
)
else
:
else
:
print
'had'
,
dist
.
version
print
_
(
'had'
,
dist
.
version
)
sys
.
path_importer_cache
.
clear
()
sys
.
path_importer_cache
.
clear
()
def
prefer_final
():
def
prefer_final
():
...
@@ -2217,7 +2233,7 @@ The default is prefer-final = false:
...
@@ -2217,7 +2233,7 @@ The default is prefer-final = false:
... eggs = demo
... eggs = demo
... ''' % globals())
... ''' % globals())
>>> print
system(buildout+' -v'),
# doctest: +ELLIPSIS
>>> print
_(system(buildout+' -v'), end=' ')
# doctest: +ELLIPSIS
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout', 'distribute'.
...
...
Picked: demo = 0.4c1
Picked: demo = 0.4c1
...
@@ -2239,7 +2255,7 @@ We get the same behavior if we add prefer-final = false
...
@@ -2239,7 +2255,7 @@ We get the same behavior if we add prefer-final = false
... eggs = demo
... eggs = demo
... ''' % globals())
... ''' % globals())
>>> print
system(buildout+' -v'),
# doctest: +ELLIPSIS
>>> print
_(system(buildout+' -v'), end=' ')
# doctest: +ELLIPSIS
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout', 'distribute'.
...
...
Picked: demo = 0.4c1
Picked: demo = 0.4c1
...
@@ -2261,7 +2277,7 @@ distributions:
...
@@ -2261,7 +2277,7 @@ distributions:
... eggs = demo
... eggs = demo
... ''' % globals())
... ''' % globals())
>>> print
system(buildout+' -v'),
# doctest: +ELLIPSIS
>>> print
_(system(buildout+' -v'), end=' ')
# doctest: +ELLIPSIS
Installing 'zc.buildout', 'distribute'.
Installing 'zc.buildout', 'distribute'.
...
...
Picked: demo = 0.3
Picked: demo = 0.3
...
@@ -2282,7 +2298,7 @@ We get an error if we specify anything but true or false:
...
@@ -2282,7 +2298,7 @@ We get an error if we specify anything but true or false:
... eggs = demo
... eggs = demo
... ''' % globals())
... ''' % globals())
>>> print
system(buildout+' -v'),
# doctest: +ELLIPSIS
>>> print
_(system(buildout+' -v'), end=' ')
# doctest: +ELLIPSIS
While:
While:
Initializing.
Initializing.
Error: Invalid value for prefer-final option: no
Error: Invalid value for prefer-final option: no
...
@@ -2312,7 +2328,7 @@ Distribution setup scripts can import modules in the distribution directory:
...
@@ -2312,7 +2328,7 @@ Distribution setup scripts can import modules in the distribution directory:
... parts =
... parts =
... ''')
... ''')
>>> print
system(join('bin', 'buildout')),
>>> print
_(system(join('bin', 'buildout')), end=' ')
Develop: '/sample-buildout/foo'
Develop: '/sample-buildout/foo'
>>> ls('develop-eggs')
>>> ls('develop-eggs')
...
@@ -2353,7 +2369,7 @@ honoring our version specification.
...
@@ -2353,7 +2369,7 @@ honoring our version specification.
... ''' % pkg_resources.working_set.find(
... ''' % pkg_resources.working_set.find(
... pkg_resources.Requirement.parse('distribute')).version)
... pkg_resources.Requirement.parse('distribute')).version)
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Installing foo.
Installing foo.
Getting distribution for 'foo==1'.
Getting distribution for 'foo==1'.
Got foo 1.
Got foo 1.
...
@@ -2378,13 +2394,13 @@ def pyc_and_pyo_files_have_correct_paths():
...
@@ -2378,13 +2394,13 @@ def pyc_and_pyo_files_have_correct_paths():
>>> _ = system(buildout)
>>> _ = system(buildout)
>>> write('t.py',
>>> write('t.py',
... '''
...
r
'''
... import eggrecipedemo, eggrecipedemoneeded
... import eggrecipedemo, eggrecipedemoneeded
, sys
...
print eggrecipedemo.main.func_code.co_filename
...
sys.stdout.write(eggrecipedemo.main.func_code.co_filename+'\n')
...
print eggrecipedemoneeded.f.func_code.co_filename
...
sys.stdout.write(eggrecipedemoneeded.f.func_code.co_filename+'\n')
... ''')
... ''')
>>> print
system(join('bin', 'py')+ ' t.py'),
>>> print
_(system(join('bin', 'py')+ ' t.py'), end=' ')
/sample-buildout/eggs/demo-0.4c1-py2.4.egg/eggrecipedemo.py
/sample-buildout/eggs/demo-0.4c1-py2.4.egg/eggrecipedemo.py
/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg/eggrecipedemoneeded.py
/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg/eggrecipedemoneeded.py
...
@@ -2407,7 +2423,7 @@ def dont_mess_with_standard_dirs_with_variable_refs():
...
@@ -2407,7 +2423,7 @@ def dont_mess_with_standard_dirs_with_variable_refs():
... eggs-directory = ${buildout:directory}/develop-eggs
... eggs-directory = ${buildout:directory}/develop-eggs
... parts =
... parts =
... ''' % globals())
... ''' % globals())
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
"""
"""
...
@@ -2438,7 +2454,7 @@ def expand_shell_patterns_in_develop_paths():
...
@@ -2438,7 +2454,7 @@ def expand_shell_patterns_in_develop_paths():
We can see that both eggs were found:
We can see that both eggs were found:
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/sampley'
Develop: '/sample-buildout/sampley'
Develop: '/sample-buildout/samplez'
Develop: '/sample-buildout/samplez'
Installing eggs.
Installing eggs.
...
@@ -2470,7 +2486,7 @@ def warn_users_when_expanding_shell_patterns_yields_no_results():
...
@@ -2470,7 +2486,7 @@ def warn_users_when_expanding_shell_patterns_yields_no_results():
We should get one of the eggs, and a warning for the pattern that
We should get one of the eggs, and a warning for the pattern that
did not match anything.
did not match anything.
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Develop: '/sample-buildout/samplea'
Develop: '/sample-buildout/samplea'
Couldn't develop '/sample-buildout/grumble*' (not found)
Couldn't develop '/sample-buildout/grumble*' (not found)
Installing eggs.
Installing eggs.
...
@@ -2525,7 +2541,7 @@ def increment_buildout_options():
...
@@ -2525,7 +2541,7 @@ def increment_buildout_options():
... <= p1
... <= p1
... ''')
... ''')
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Installing p1.
Installing p1.
foo='1\n2 b'
foo='1\n2 b'
recipe='zc.buildout:debug'
recipe='zc.buildout:debug'
...
@@ -2565,7 +2581,7 @@ def increment_buildout_with_multiple_extended_files_421022():
...
@@ -2565,7 +2581,7 @@ def increment_buildout_with_multiple_extended_files_421022():
... x = ${buildout:bar-option} ${buildout:foo-option}
... x = ${buildout:bar-option} ${buildout:foo-option}
... ''')
... ''')
>>> print
system(buildout),
>>> print
_(system(buildout), end=' ')
Installing p.
Installing p.
recipe='zc.buildout:debug'
recipe='zc.buildout:debug'
x='bar\nbaz foo\nham'
x='bar\nbaz foo\nham'
...
@@ -2592,7 +2608,7 @@ def increment_on_command_line():
...
@@ -2592,7 +2608,7 @@ def increment_on_command_line():
... <= p1
... <= p1
... ''')
... ''')
>>> print
system(buildout+' buildout:parts+=p2 p1:foo+=bar'),
>>> print
_(system(buildout+' buildout:parts+=p2 p1:foo+=bar'), end=' ')
Installing p1.
Installing p1.
foo='1 a\nb\nbar'
foo='1 a\nb\nbar'
recipe='zc.buildout:debug'
recipe='zc.buildout:debug'
...
@@ -2624,7 +2640,11 @@ def create_sample_eggs(test, executable=sys.executable):
...
@@ -2624,7 +2640,11 @@ def create_sample_eggs(test, executable=sys.executable):
)
)
zc
.
buildout
.
testing
.
sdist
(
tmp
,
dest
)
zc
.
buildout
.
testing
.
sdist
(
tmp
,
dest
)
write
(
tmp
,
'distutilsscript'
,
'#!/usr/bin/python
\
n
print "distutils!"'
)
write
(
tmp
,
'distutilsscript'
,
'#!/usr/bin/python
\
n
'
'import sys; sys.stdout.write("distutils!
\
\
n")
\
n
'
)
write
(
write
(
tmp
,
'setup.py'
,
tmp
,
'setup.py'
,
"from setuptools import setup
\
n
"
"from setuptools import setup
\
n
"
...
@@ -2649,9 +2669,12 @@ def create_sample_eggs(test, executable=sys.executable):
...
@@ -2649,9 +2669,12 @@ def create_sample_eggs(test, executable=sys.executable):
for
i
in
(
1
,
2
,
3
,
4
):
for
i
in
(
1
,
2
,
3
,
4
):
write
(
write
(
tmp
,
'eggrecipedemo.py'
,
tmp
,
'eggrecipedemo.py'
,
'import eggrecipedemoneeded
\
n
'
'import eggrecipedemoneeded, sys
\
n
'
'def print_(*a):
\
n
'
' sys.stdout.write(" ".join(map(str, a))+"
\
\
n")
\
n
'
'x=%s
\
n
'
'x=%s
\
n
'
'def main(): print x, eggrecipedemoneeded.y
\
n
'
'def main():
\
n
'
' print_(x, eggrecipedemoneeded.y)
\
n
'
%
i
)
%
i
)
c1
=
i
==
4
and
'c1'
or
''
c1
=
i
==
4
and
'c1'
or
''
write
(
write
(
...
@@ -2679,7 +2702,7 @@ def create_sample_eggs(test, executable=sys.executable):
...
@@ -2679,7 +2702,7 @@ def create_sample_eggs(test, executable=sys.executable):
finally
:
finally
:
shutil
.
rmtree
(
tmp
)
shutil
.
rmtree
(
tmp
)
extdemo_c
=
"""
extdemo_c
2
=
"""
#include <Python.h>
#include <Python.h>
#include <extdemo.h>
#include <extdemo.h>
...
@@ -2698,12 +2721,43 @@ initextdemo(void)
...
@@ -2698,12 +2721,43 @@ initextdemo(void)
}
}
"""
"""
extdemo_setup_py
=
"""
extdemo_c3
=
"""
import os
#include <Python.h>
#include <extdemo.h>
static PyMethodDef methods[] = {{NULL}};
#define MOD_DEF(ob, name, doc, methods)
\
static struct PyModuleDef moduledef = {
\
PyModuleDef_HEAD_INIT, name, doc, -1, methods, };
\
ob = PyModule_Create(&moduledef);
#define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void)
MOD_INIT(extdemo)
{
PyObject *m;
MOD_DEF(m, "extdemo", "", methods);
#ifdef TWO
PyModule_AddObject(m, "val", PyLong_FromLong(2));
#else
PyModule_AddObject(m, "val", PyLong_FromLong(EXTDEMO));
#endif
return m;
}
"""
extdemo_c
=
sys
.
version_info
[
0
]
<
3
and
extdemo_c2
or
extdemo_c3
extdemo_setup_py
=
r"""
import os, sys
from distutils.core import setup, Extension
from distutils.core import setup, Extension
if os.environ.get('test-variable'):
if os.environ.get('test-variable'):
print
"Have environment test-variable:", os.environ['test-variable']
print
("Have environment test-variable: %%s" %% os.environ['test-variable'])
setup(name = "extdemo", version = "%s", url="http://www.zope.org",
setup(name = "extdemo", version = "%s", url="http://www.zope.org",
author="Demo", author_email="demo@demo.com",
author="Demo", author_email="demo@demo.com",
...
@@ -2712,7 +2766,6 @@ setup(name = "extdemo", version = "%s", url="http://www.zope.org",
...
@@ -2712,7 +2766,6 @@ setup(name = "extdemo", version = "%s", url="http://www.zope.org",
"""
"""
def
add_source_dist
(
test
,
version
=
1.4
):
def
add_source_dist
(
test
,
version
=
1.4
):
if
'extdemo'
not
in
test
.
globs
:
if
'extdemo'
not
in
test
.
globs
:
test
.
globs
[
'extdemo'
]
=
test
.
globs
[
'tmpdir'
](
'extdemo'
)
test
.
globs
[
'extdemo'
]
=
test
.
globs
[
'tmpdir'
](
'extdemo'
)
...
@@ -2968,6 +3021,7 @@ def test_suite():
...
@@ -2968,6 +3021,7 @@ def test_suite():
zc.buildout.testing.normalize_endings,
zc.buildout.testing.normalize_endings,
zc.buildout.testing.normalize_script,
zc.buildout.testing.normalize_script,
zc.buildout.testing.normalize_egg_py,
zc.buildout.testing.normalize_egg_py,
zc.buildout.testing.normalize_exception_type_for_python_2_and_3,
normalize_bang,
normalize_bang,
normalize_S,
normalize_S,
(re.compile('
extdemo
[.]
pyd
'), '
extdemo
.
so
'),
(re.compile('
extdemo
[.]
pyd
'), '
extdemo
.
so
'),
...
@@ -3076,3 +3130,4 @@ def test_suite():
...
@@ -3076,3 +3130,4 @@ def test_suite():
))
))
return unittest.TestSuite(test_suite)
return unittest.TestSuite(test_suite)
src/zc/buildout/update.txt
View file @
83d53da5
...
@@ -34,6 +34,8 @@ zc.buildout used:
...
@@ -34,6 +34,8 @@ zc.buildout used:
>>> write(sample_buildout, 'showversions', 'showversions.py',
>>> write(sample_buildout, 'showversions', 'showversions.py',
... """
... """
... import pkg_resources
... import pkg_resources
... import sys
... print_ = lambda *a: sys.stdout.write(' '.join(map(str, a))+'\n')
...
...
... class Recipe:
... class Recipe:
...
...
...
@@ -43,7 +45,7 @@ zc.buildout used:
...
@@ -43,7 +45,7 @@ zc.buildout used:
... def install(self):
... def install(self):
... for project in 'zc.buildout', 'distribute':
... for project in 'zc.buildout', 'distribute':
... req = pkg_resources.Requirement.parse(project)
... req = pkg_resources.Requirement.parse(project)
... print
project, pkg_resources.working_set.find(req).version
... print
_(project, pkg_resources.working_set.find(req).version)
... return ()
... return ()
... update = install
... update = install
... """)
... """)
...
@@ -63,7 +65,7 @@ zc.buildout used:
...
@@ -63,7 +65,7 @@ zc.buildout used:
Now if we run the buildout, the buildout will upgrade itself to the
Now if we run the buildout, the buildout will upgrade itself to the
new versions found in new releases:
new versions found in new releases:
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Getting distribution for 'distribute'.
Getting distribution for 'distribute'.
Got distribute 99.99.
Got distribute 99.99.
Upgraded:
Upgraded:
...
@@ -111,7 +113,7 @@ will install earlier versions of these packages:
...
@@ -111,7 +113,7 @@ will install earlier versions of these packages:
Now we can see that we actually "upgrade" to an earlier version.
Now we can see that we actually "upgrade" to an earlier version.
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Upgraded:
Upgraded:
distribute version 0.6;
distribute version 0.6;
restarting.
restarting.
...
@@ -138,7 +140,7 @@ We won't upgrade in offline mode:
...
@@ -138,7 +140,7 @@ We won't upgrade in offline mode:
... recipe = showversions
... recipe = showversions
... """ % dict(new_releases=new_releases))
... """ % dict(new_releases=new_releases))
>>> print
system(buildout+' -o'),
>>> print
_(system(buildout+' -o'), ed='')
Develop: '/sample-buildout/showversions'
Develop: '/sample-buildout/showversions'
Updating show-versions.
Updating show-versions.
zc.buildout 1.0.0
zc.buildout 1.0.0
...
@@ -146,7 +148,7 @@ We won't upgrade in offline mode:
...
@@ -146,7 +148,7 @@ We won't upgrade in offline mode:
Or in non-newest mode:
Or in non-newest mode:
>>> print
system(buildout+' -N'),
>>> print
_(system(buildout+' -N'), end='')
Develop: '/sample-buildout/showversions'
Develop: '/sample-buildout/showversions'
Updating show-versions.
Updating show-versions.
zc.buildout 1.0.0
zc.buildout 1.0.0
...
@@ -166,7 +168,7 @@ directory:
...
@@ -166,7 +168,7 @@ directory:
... """ % dict(new_releases=new_releases))
... """ % dict(new_releases=new_releases))
>>> cd(sample_buildout2)
>>> cd(sample_buildout2)
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Creating directory '/sample_buildout2/bin'.
Creating directory '/sample_buildout2/bin'.
Creating directory '/sample_buildout2/parts'.
Creating directory '/sample_buildout2/parts'.
Creating directory '/sample_buildout2/eggs'.
Creating directory '/sample_buildout2/eggs'.
...
...
src/zc/buildout/windows.txt
View file @
83d53da5
...
@@ -14,6 +14,8 @@ can't delete.
...
@@ -14,6 +14,8 @@ can't delete.
>>> write('recipe', 'recipe.py',
>>> write('recipe', 'recipe.py',
... '''
... '''
... import os
... import os
... import sys
... print_ = lambda *a: sys.stdout.write(' '.join(map(str, a))+'\n')
... class Recipe:
... class Recipe:
... def __init__(self, buildout, name, options):
... def __init__(self, buildout, name, options):
... self.location = os.path.join(
... self.location = os.path.join(
...
@@ -21,7 +23,7 @@ can't delete.
...
@@ -21,7 +23,7 @@ can't delete.
... name)
... name)
...
...
... def install(self):
... def install(self):
... print
"can't remove read only files"
... print
_("can't remove read only files")
... if not os.path.exists (self.location):
... if not os.path.exists (self.location):
... os.makedirs (self.location)
... os.makedirs (self.location)
...
...
...
@@ -43,7 +45,7 @@ can't delete.
...
@@ -43,7 +45,7 @@ can't delete.
>>> write('recipe', 'README', '')
>>> write('recipe', 'README', '')
>>> print
system(buildout+' setup recipe bdist_egg'),
# doctest: +ELLIPSIS
>>> print
_(system(buildout+' setup recipe bdist_egg'))
# doctest: +ELLIPSIS
Running setup script 'recipe/setup.py'.
Running setup script 'recipe/setup.py'.
...
...
...
@@ -59,7 +61,7 @@ and we'll configure a buildout to use it:
...
@@ -59,7 +61,7 @@ and we'll configure a buildout to use it:
... recipe = spam
... recipe = spam
... ''' % join('recipe', 'dist'))
... ''' % join('recipe', 'dist'))
>>> print
system(buildout),
>>> print
_(system(buildout), end='')
Getting distribution for 'spam'.
Getting distribution for 'spam'.
Got spam 1.
Got spam 1.
Installing foo.
Installing foo.
...
...
zc.recipe.egg_/src/zc/recipe/egg/custom.py
View file @
83d53da5
...
@@ -61,7 +61,7 @@ class Custom(Base):
...
@@ -61,7 +61,7 @@ class Custom(Base):
self
.
environment
=
buildout
[
environment_section
]
self
.
environment
=
buildout
[
environment_section
]
else
:
else
:
self
.
environment
=
{}
self
.
environment
=
{}
environment_data
=
self
.
environment
.
items
(
)
environment_data
=
list
(
self
.
environment
.
items
()
)
environment_data
.
sort
()
environment_data
.
sort
()
options
[
'_environment-data'
]
=
repr
(
environment_data
)
options
[
'_environment-data'
]
=
repr
(
environment_data
)
...
@@ -98,7 +98,7 @@ class Custom(Base):
...
@@ -98,7 +98,7 @@ class Custom(Base):
def
_set_environment
(
self
):
def
_set_environment
(
self
):
self
.
_saved_environment
=
{}
self
.
_saved_environment
=
{}
for
key
,
value
in
self
.
environment
.
items
(
):
for
key
,
value
in
list
(
self
.
environment
.
items
()
):
if
key
in
os
.
environ
:
if
key
in
os
.
environ
:
self
.
_saved_environment
[
key
]
=
os
.
environ
[
key
]
self
.
_saved_environment
[
key
]
=
os
.
environ
[
key
]
# Interpolate value with variables from environment. Maybe there
# Interpolate value with variables from environment. Maybe there
...
...
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