Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
slapos.buildout
Commits
91fa83b0
Commit
91fa83b0
authored
Sep 01, 2006
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a self-updating feature, so buildouts now update themselves.
parent
833aa8a9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
223 additions
and
3 deletions
+223
-3
setup.py
setup.py
+1
-0
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+51
-1
src/zc/buildout/buildout.txt
src/zc/buildout/buildout.txt
+4
-0
src/zc/buildout/tests.py
src/zc/buildout/tests.py
+83
-2
src/zc/buildout/update.txt
src/zc/buildout/update.txt
+84
-0
No files found.
setup.py
View file @
91fa83b0
...
@@ -23,4 +23,5 @@ setup(
...
@@ -23,4 +23,5 @@ setup(
entry_points
=
{
'console_scripts'
:
entry_points
=
{
'console_scripts'
:
[
'buildout = %s.buildout:main'
%
name
]},
[
'buildout = %s.buildout:main'
%
name
]},
dependency_links
=
[
'http://download.zope.org/distribution/'
],
dependency_links
=
[
'http://download.zope.org/distribution/'
],
zip_safe
=
False
,
)
)
src/zc/buildout/buildout.py
View file @
91fa83b0
...
@@ -25,7 +25,6 @@ import shutil
...
@@ -25,7 +25,6 @@ import shutil
import
sys
import
sys
import
ConfigParser
import
ConfigParser
import
zc.buildout.easy_install
import
pkg_resources
import
pkg_resources
import
zc.buildout.easy_install
import
zc.buildout.easy_install
...
@@ -245,6 +244,9 @@ class Buildout(dict):
...
@@ -245,6 +244,9 @@ class Buildout(dict):
# for eggs:
# for eggs:
sys
.
path
.
insert
(
0
,
self
[
'buildout'
][
'develop-eggs-directory'
])
sys
.
path
.
insert
(
0
,
self
[
'buildout'
][
'develop-eggs-directory'
])
# Check for updates. This could cause the process to be rstarted
self
.
_maybe_upgrade
()
# Build develop eggs
# Build develop eggs
self
.
_develop
()
self
.
_develop
()
...
@@ -524,6 +526,54 @@ class Buildout(dict):
...
@@ -524,6 +526,54 @@ class Buildout(dict):
_save_options
(
section
,
self
[
section
],
sys
.
stdout
)
_save_options
(
section
,
self
[
section
],
sys
.
stdout
)
print
print
def
_maybe_upgrade
(
self
):
# See if buildout or setuptools need to be upgraded.
# If they do, do the upgrade and return true.
# Otherwise, return False.
ws
=
zc
.
buildout
.
easy_install
.
install
(
[
(
spec
+
' '
+
self
[
'buildout'
].
get
(
spec
+
'-version'
,
''
)).
strip
()
for
spec
in
(
'zc.buildout'
,
'setuptools'
)
],
self
[
'buildout'
][
'eggs-directory'
],
links
=
self
[
'buildout'
].
get
(
'find-links'
,
''
).
split
(),
index
=
self
[
'buildout'
].
get
(
'index'
),
path
=
[
self
[
'buildout'
][
'develop-eggs-directory'
]],
)
upgraded
=
[]
for
project
in
'zc.buildout'
,
'setuptools'
:
req
=
pkg_resources
.
Requirement
.
parse
(
project
)
if
ws
.
find
(
req
)
!=
pkg_resources
.
working_set
.
find
(
req
):
upgraded
.
append
(
ws
.
find
(
req
))
if
not
upgraded
:
return
self
.
_logger
.
info
(
"Upgraded: %s, restarting."
,
", "
.
join
([(
"%s version %s"
%
(
dist
.
project_name
,
dist
.
version
)
)
for
dist
in
upgraded
]
),
)
# the new dist is different, so we've upgraded.
# Update the scripts and return True
zc
.
buildout
.
easy_install
.
scripts
(
[
'zc.buildout'
],
ws
,
sys
.
executable
,
self
[
'buildout'
][
'bin-directory'
],
)
# Restart
args
=
map
(
zc
.
buildout
.
easy_install
.
_safe_arg
,
sys
.
argv
)
if
not
__debug__
:
args
.
insert
(
0
,
'-O'
)
args
.
insert
(
0
,
sys
.
executable
)
sys
.
exit
(
os
.
spawnv
(
os
.
P_WAIT
,
sys
.
executable
,
args
))
_spacey_nl
=
re
.
compile
(
'[
\
t
\
r
\
f
\
v
]*
\
n
[
\
t
\
r
\
f
\
v
\
n
]*'
_spacey_nl
=
re
.
compile
(
'[
\
t
\
r
\
f
\
v
]*
\
n
[
\
t
\
r
\
f
\
v
\
n
]*'
'|'
'|'
'^[
\
t
\
r
\
f
\
v
]+'
'^[
\
t
\
r
\
f
\
v
]+'
...
...
src/zc/buildout/buildout.txt
View file @
91fa83b0
...
@@ -1103,6 +1103,10 @@ database is shown.
...
@@ -1103,6 +1103,10 @@ database is shown.
python = buildout
python = buildout
verbosity = 20
verbosity = 20
<BLANKLINE>
<BLANKLINE>
zc.buildout.easy_install: Installing ['zc.buildout', 'setuptools']
zc.buildout.easy_install: We have a develop egg for zc.buildout
zc.buildout.easy_install: We have the best distributon that satisfies
setuptools
All of these options can be overridden by configuration files or by
All of these options can be overridden by configuration files or by
command-line assignments. We've discussed most of these options
command-line assignments. We've discussed most of these options
...
...
src/zc/buildout/tests.py
View file @
91fa83b0
...
@@ -16,9 +16,10 @@
...
@@ -16,9 +16,10 @@
$Id$
$Id$
"""
"""
import
os
,
re
,
shutil
,
sys
,
unittest
import
os
,
re
,
shutil
,
sys
,
unittest
,
zipfile
from
zope.testing
import
doctest
,
renormalizing
from
zope.testing
import
doctest
,
renormalizing
import
zc.buildout.testing
import
pkg_resources
import
zc.buildout.testing
,
zc
.
buildout
.
easy_install
os_path_sep
=
os
.
path
.
sep
os_path_sep
=
os
.
path
.
sep
if
os_path_sep
==
'
\
\
'
:
if
os_path_sep
==
'
\
\
'
:
...
@@ -321,6 +322,75 @@ class PythonNormalizing(renormalizing.RENormalizing):
...
@@ -321,6 +322,75 @@ class PythonNormalizing(renormalizing.RENormalizing):
return
result
return
result
egg_parse
=
re
.
compile
(
'([0-9a-zA-Z_.]+)-([0-9a-zA-Z_.]+)-py(
\
d[.]
\
d).egg$'
).
match
def
makeNewRelease
(
project
,
ws
,
dest
):
dist
=
ws
.
find
(
pkg_resources
.
Requirement
.
parse
(
project
))
eggname
,
oldver
,
pyver
=
egg_parse
(
os
.
path
.
basename
(
dist
.
location
)
).
groups
()
dest
=
os
.
path
.
join
(
dest
,
"%s-99.99-py%s.egg"
%
(
eggname
,
pyver
))
if
os
.
path
.
isfile
(
dist
.
location
):
shutil
.
copy
(
dist
.
location
,
dest
)
zip
=
zipfile
.
ZipFile
(
dest
,
'a'
)
zip
.
writestr
(
'EGG-INFO/PKG-INFO'
,
zip
.
read
(
'EGG-INFO/PKG-INFO'
).
replace
(
"Version: %s"
%
oldver
,
"Version: 99.99"
)
)
zip
.
close
()
else
:
shutil
.
copy
(
dist
.
location
,
dest
)
info_path
=
os
.
path
.
join
(
dest
,
'EGG-INFO'
,
'PKG-INFO'
)
info
=
open
(
info_path
).
read
().
replace
(
"Version: %s"
%
oldver
,
"Version: 99.99"
)
open
(
info_path
,
'w'
).
write
(
info
)
def
updateSetup
(
test
):
zc
.
buildout
.
testing
.
buildoutSetUp
(
test
)
test
.
globs
[
'new_releases'
]
=
new_releases
=
test
.
globs
[
'mkdtemp'
]()
sample_buildout
=
test
.
globs
[
'sample_buildout'
]
eggs
=
os
.
path
.
join
(
sample_buildout
,
'eggs'
)
# If the zc.buildout dist is a develo dist, convert it to a
# regular egg in the sample buildout
req
=
pkg_resources
.
Requirement
.
parse
(
'zc.buildout'
)
dist
=
pkg_resources
.
working_set
.
find
(
req
)
if
dist
.
precedence
==
pkg_resources
.
DEVELOP_DIST
:
# We have a develop egg, create a real egg for it:
here
=
os
.
getcwd
()
os
.
chdir
(
os
.
path
.
dirname
(
dist
.
location
))
assert
os
.
spawnle
(
os
.
P_WAIT
,
sys
.
executable
,
sys
.
executable
,
os
.
path
.
join
(
os
.
path
.
dirname
(
dist
.
location
),
'setup.py'
),
'-q'
,
'bdist_egg'
,
'-d'
,
eggs
,
dict
(
os
.
environ
,
PYTHONPATH
=
pkg_resources
.
working_set
.
find
(
pkg_resources
.
Requirement
.
parse
(
'setuptools'
)
).
location
,
),
)
==
0
os
.
chdir
(
here
)
os
.
remove
(
os
.
path
.
join
(
eggs
,
'zc.buildout.egg-link'
))
# Rebuild the buildout script
ws
=
pkg_resources
.
WorkingSet
([
eggs
])
ws
.
require
(
'zc.buildout'
)
zc
.
buildout
.
easy_install
.
scripts
(
[
'zc.buildout'
],
ws
,
sys
.
executable
,
os
.
path
.
join
(
sample_buildout
,
'bin'
))
else
:
ws
=
pkg_resources
.
working_set
# now let's make the new releases
makeNewRelease
(
'zc.buildout'
,
ws
,
new_releases
)
makeNewRelease
(
'setuptools'
,
ws
,
new_releases
)
os
.
mkdir
(
os
.
path
.
join
(
new_releases
,
'zc.buildout'
))
os
.
mkdir
(
os
.
path
.
join
(
new_releases
,
'setuptools'
))
def
test_suite
():
def
test_suite
():
return
unittest
.
TestSuite
((
return
unittest
.
TestSuite
((
...
@@ -345,6 +415,17 @@ def test_suite():
...
@@ -345,6 +415,17 @@ def test_suite():
(re.compile("(
\
w)%s(
\
w)" % os_path_sep), r"
\
1
/
\
2
"),
(re.compile("(
\
w)%s(
\
w)" % os_path_sep), r"
\
1
/
\
2
"),
])
])
),
),
doctest.DocFileSuite(
'
update
.
txt
',
setUp=updateSetup,
tearDown=zc.buildout.testing.buildoutTearDown,
checker=renormalizing.RENormalizing([
(re.compile('
#!\S+python\S+'), '#!python'),
(
re
.
compile
(
'
\
S+s
a
mple-(
\
w+)
'
), r'
/
sample
-
\
1
'),
(re.compile('
-
py
\
d
[.]
\
d
.
egg
'), r'
-
py2
.
3.
egg
'),
])
),
doctest.DocFileSuite(
doctest.DocFileSuite(
'
easy_install
.
txt
',
'
easy_install
.
txt
',
...
...
src/zc/buildout/update.txt
0 → 100644
View file @
91fa83b0
Automatic Buildout Updates
==========================
When a buildout is run, one of the first steps performed is to check
for updates to either zc.buildout or setuptools. To demonstrate this,
we've creates some "new releases" of buildout and setuptools in a
new_releases folder:
>>> ls(new_releases)
d setuptools
- setuptools-99.99-py2.3.egg
d zc.buildout
- zc.buildout-99.99-py2.3.egg
Let's update the sample buildout.cfg to look in this area:
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... find-links = %(new_releases)s
... index = %(new_releases)s
... parts = show-versions
... develop = showversions
...
... [show-versions]
... recipe = showversions
... """ % dict(new_releases=new_releases))
We'll also include a recipe that echos the version sof setuptools and
zc.buildout used:
>>> mkdir(sample_buildout, 'showversions')
>>> write(sample_buildout, 'showversions', 'showversions.py',
... """
... import pkg_resources
...
... class Recipe:
...
... def __init__(self, buildout, name, options):
... pass
...
... def install(self):
... for project in 'zc.buildout', 'setuptools':
... req = pkg_resources.Requirement.parse(project)
... print project, pkg_resources.working_set.find(req).version
... """)
>>> write(sample_buildout, 'showversions', 'setup.py',
... """
... from setuptools import setup
...
... setup(
... name = "showversions",
... entry_points = {'zc.buildout': ['default = showversions:Recipe']},
... )
... """)
Now if we run the buildout, the buildout will upgrade itself to the
new versions found in new releases:
>>> import os
>>> os.chdir(sample_buildout)
>>> buildout = os.path.join(sample_buildout, 'bin', 'buildout')
>>> print system(buildout),
zc.buildout 99.99
setuptools 99.99
Our buildout script has been updated to use the new eggs:
>>> cat(sample_buildout, 'bin', 'buildout')
#!/usr/local/bin/python2.3
<BLANKLINE>
import sys
sys.path[0:0] = [
'/tmp/tmpc4avO6sample-buildout/eggs/zc.buildout-99.99-py2.3.egg',
'/tmp/tmpc4avO6sample-buildout/eggs/setuptools-99.99-py2.3.egg'
]
<BLANKLINE>
import zc.buildout.buildout
<BLANKLINE>
if __name__ == '__main__':
zc.buildout.buildout.main()
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