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
Łukasz Nowak
slapos.buildout
Commits
aed2a76a
Commit
aed2a76a
authored
Mar 17, 2009
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a relative-paths option to generate egg paths relative to script
locations when generating scripts.
parent
f2617ede
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
134 additions
and
7 deletions
+134
-7
zc.recipe.egg_/src/zc/recipe/egg/README.txt
zc.recipe.egg_/src/zc/recipe/egg/README.txt
+120
-6
zc.recipe.egg_/src/zc/recipe/egg/egg.py
zc.recipe.egg_/src/zc/recipe/egg/egg.py
+14
-1
No files found.
zc.recipe.egg_/src/zc/recipe/egg/README.txt
View file @
aed2a76a
...
...
@@ -166,6 +166,12 @@ initialization
arguments
Specify some arguments to be passed to entry points as Python source.
relative-paths
If set to true, then egg paths will be generated relative to the
script path. This allows a buildout to be moved without breaking
egg paths. This option can be set in either the script section or
in the buildout section.
Let's add an interpreter option:
>>> write(sample_buildout, 'buildout.cfg',
...
...
@@ -356,7 +362,7 @@ extra-paths option:
... scripts = demo=foo
... extra-paths =
... /foo/bar
...
/spam/eggs
...
${buildout:directory}/spam
... """ % dict(server=link_server))
>>> print system(buildout),
...
...
@@ -374,7 +380,115 @@ Let's look at the script that was generated:
'/sample-buildout/eggs/demo-0.4c1-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
'/foo/bar',
'/spam/eggs',
'/sample-buildout/spam',
]
<BLANKLINE>
import eggrecipedemo
<BLANKLINE>
if __name__ == '__main__':
eggrecipedemo.main()
Relative egg paths
------------------
If the relative-paths option is specified with a true value, then
paths will be generated relative to the script. This is useful when
you want to be able to move a buildout directory around without
breaking scripts.
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... parts = demo
...
... [demo]
... recipe = zc.recipe.egg
... find-links = %(server)s
... index = %(server)s/index
... scripts = demo=foo
... relative-paths = true
... extra-paths =
... /foo/bar
... ${buildout:directory}/spam
... """ % dict(server=link_server))
>>> print system(buildout),
Uninstalling demo.
Installing demo.
Generated script '/sample-buildout/bin/foo'.
Let's look at the script that was generated:
>>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.4
<BLANKLINE>
import os
<BLANKLINE>
def dirname(n, path):
while n >= 0:
n -= 1
path = os.path.dirname(path)
return path
<BLANKLINE>
join = os.path.join
<BLANKLINE>
import sys
sys.path[0:0] = [
join(dirname(1, __file__), 'eggs/demo-0.4c1-py2.4.egg'),
join(dirname(1, __file__), 'eggs/demoneeded-1.2c1-py2.4.egg'),
'/foo/bar',
join(dirname(1, __file__), 'spam'),
]
<BLANKLINE>
import eggrecipedemo
<BLANKLINE>
if __name__ == '__main__':
eggrecipedemo.main()
You can specify relative paths in the buildout section, rather than in
each individual script section:
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... parts = demo
... relative-paths = true
...
... [demo]
... recipe = zc.recipe.egg
... find-links = %(server)s
... index = %(server)s/index
... scripts = demo=foo
... extra-paths =
... /foo/bar
... ${buildout:directory}/spam
... """ % dict(server=link_server))
>>> print system(buildout),
Uninstalling demo.
Installing demo.
Generated script '/sample-buildout/bin/foo'.
>>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.4
<BLANKLINE>
import os
<BLANKLINE>
def dirname(n, path):
while n >= 0:
n -= 1
path = os.path.dirname(path)
return path
<BLANKLINE>
join = os.path.join
<BLANKLINE>
import sys
sys.path[0:0] = [
join(dirname(1, __file__), 'eggs/demo-0.4c1-py2.4.egg'),
join(dirname(1, __file__), 'eggs/demoneeded-1.2c1-py2.4.egg'),
'/foo/bar',
join(dirname(1, __file__), 'spam'),
]
<BLANKLINE>
import eggrecipedemo
...
...
@@ -402,7 +516,7 @@ to be included in generated scripts:
... scripts = demo=foo
... extra-paths =
... /foo/bar
...
/spam/eggs
...
${buildout:directory}/spam
... initialization = a = (1, 2
... 3, 4)
... arguments = a, 2
...
...
@@ -421,7 +535,7 @@ to be included in generated scripts:
'/sample-buildout/eggs/demo-0.4c1-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
'/foo/bar',
'/s
pam/eggs
',
'/s
ample-buildout/spam
',
]
<BLANKLINE>
a = (1, 2
...
...
@@ -454,7 +568,7 @@ declare entry points using the entry-points option:
... index = %(server)s/index
... extra-paths =
... /foo/bar
...
/spam/eggs
...
${buildout:directory}/spam
... entry-points = alt=eggrecipedemo:alt other=foo.bar:a.b.c
... """ % dict(server=link_server))
...
...
@@ -479,7 +593,7 @@ declare entry points using the entry-points option:
'/sample-buildout/eggs/demo-0.4c1-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
'/foo/bar',
'/s
pam/eggs
',
'/s
ample-buildout/spam
',
]
<BLANKLINE>
import foo.bar
...
...
zc.recipe.egg_/src/zc/recipe/egg/egg.py
View file @
aed2a76a
...
...
@@ -49,7 +49,7 @@ class Eggs(object):
options
[
'develop-eggs-directory'
]
=
buildout
[
'buildout'
][
'develop-eggs-directory'
]
options
[
'_d'
]
=
options
[
'develop-eggs-directory'
]
# backward compat.
assert
options
.
get
(
'unzip'
)
in
(
'true'
,
'false'
,
None
)
python
=
options
.
get
(
'python'
,
buildout
[
'buildout'
][
'python'
])
...
...
@@ -113,6 +113,18 @@ class Scripts(Eggs):
if
self
.
extra_paths
:
options
[
'extra-paths'
]
=
'
\
n
'
.
join
(
self
.
extra_paths
)
relative_paths
=
options
.
get
(
'relative-paths'
,
buildout
[
'buildout'
].
get
(
'relative-paths'
,
'false'
)
)
if
relative_paths
==
'true'
:
options
[
'buildout-directory'
]
=
buildout
[
'buildout'
][
'directory'
]
self
.
_relative_paths
=
options
[
'buildout-directory'
]
else
:
self
.
_relative_paths
=
''
assert
relative_paths
==
'false'
parse_entry_point
=
re
.
compile
(
'([^=]+)=(
\
w+(?:[.]
\
w+)*):(
\
w+(?:[.]
\
w+)*)$'
).
match
...
...
@@ -154,6 +166,7 @@ class Scripts(Eggs):
interpreter
=
options
.
get
(
'interpreter'
),
initialization
=
options
.
get
(
'initialization'
,
''
),
arguments
=
options
.
get
(
'arguments'
,
''
),
relative_paths
=
self
.
_relative_paths
,
)
return
()
...
...
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