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
Jérome Perrin
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
...
@@ -166,6 +166,12 @@ initialization
arguments
arguments
Specify some arguments to be passed to entry points as Python source.
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:
Let's add an interpreter option:
>>> write(sample_buildout, 'buildout.cfg',
>>> write(sample_buildout, 'buildout.cfg',
...
@@ -356,7 +362,7 @@ extra-paths option:
...
@@ -356,7 +362,7 @@ extra-paths option:
... scripts = demo=foo
... scripts = demo=foo
... extra-paths =
... extra-paths =
... /foo/bar
... /foo/bar
...
/spam/eggs
...
${buildout:directory}/spam
... """ % dict(server=link_server))
... """ % dict(server=link_server))
>>> print system(buildout),
>>> print system(buildout),
...
@@ -374,7 +380,115 @@ Let's look at the script that was generated:
...
@@ -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/demo-0.4c1-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
'/foo/bar',
'/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>
<BLANKLINE>
import eggrecipedemo
import eggrecipedemo
...
@@ -402,7 +516,7 @@ to be included in generated scripts:
...
@@ -402,7 +516,7 @@ to be included in generated scripts:
... scripts = demo=foo
... scripts = demo=foo
... extra-paths =
... extra-paths =
... /foo/bar
... /foo/bar
...
/spam/eggs
...
${buildout:directory}/spam
... initialization = a = (1, 2
... initialization = a = (1, 2
... 3, 4)
... 3, 4)
... arguments = a, 2
... arguments = a, 2
...
@@ -421,7 +535,7 @@ to be included in generated scripts:
...
@@ -421,7 +535,7 @@ to be included in generated scripts:
'/sample-buildout/eggs/demo-0.4c1-py2.4.egg',
'/sample-buildout/eggs/demo-0.4c1-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
'/foo/bar',
'/foo/bar',
'/s
pam/eggs
',
'/s
ample-buildout/spam
',
]
]
<BLANKLINE>
<BLANKLINE>
a = (1, 2
a = (1, 2
...
@@ -454,7 +568,7 @@ declare entry points using the entry-points option:
...
@@ -454,7 +568,7 @@ declare entry points using the entry-points option:
... index = %(server)s/index
... index = %(server)s/index
... extra-paths =
... extra-paths =
... /foo/bar
... /foo/bar
...
/spam/eggs
...
${buildout:directory}/spam
... entry-points = alt=eggrecipedemo:alt other=foo.bar:a.b.c
... entry-points = alt=eggrecipedemo:alt other=foo.bar:a.b.c
... """ % dict(server=link_server))
... """ % dict(server=link_server))
...
@@ -479,7 +593,7 @@ declare entry points using the entry-points option:
...
@@ -479,7 +593,7 @@ declare entry points using the entry-points option:
'/sample-buildout/eggs/demo-0.4c1-py2.4.egg',
'/sample-buildout/eggs/demo-0.4c1-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
'/foo/bar',
'/foo/bar',
'/s
pam/eggs
',
'/s
ample-buildout/spam
',
]
]
<BLANKLINE>
<BLANKLINE>
import foo.bar
import foo.bar
...
...
zc.recipe.egg_/src/zc/recipe/egg/egg.py
View file @
aed2a76a
...
@@ -49,7 +49,7 @@ class Eggs(object):
...
@@ -49,7 +49,7 @@ class Eggs(object):
options
[
'develop-eggs-directory'
options
[
'develop-eggs-directory'
]
=
buildout
[
'buildout'
][
'develop-eggs-directory'
]
]
=
buildout
[
'buildout'
][
'develop-eggs-directory'
]
options
[
'_d'
]
=
options
[
'develop-eggs-directory'
]
# backward compat.
options
[
'_d'
]
=
options
[
'develop-eggs-directory'
]
# backward compat.
assert
options
.
get
(
'unzip'
)
in
(
'true'
,
'false'
,
None
)
assert
options
.
get
(
'unzip'
)
in
(
'true'
,
'false'
,
None
)
python
=
options
.
get
(
'python'
,
buildout
[
'buildout'
][
'python'
])
python
=
options
.
get
(
'python'
,
buildout
[
'buildout'
][
'python'
])
...
@@ -113,6 +113,18 @@ class Scripts(Eggs):
...
@@ -113,6 +113,18 @@ class Scripts(Eggs):
if
self
.
extra_paths
:
if
self
.
extra_paths
:
options
[
'extra-paths'
]
=
'
\
n
'
.
join
(
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
(
parse_entry_point
=
re
.
compile
(
'([^=]+)=(
\
w+(?:[.]
\
w+)*):(
\
w+(?:[.]
\
w+)*)$'
'([^=]+)=(
\
w+(?:[.]
\
w+)*):(
\
w+(?:[.]
\
w+)*)$'
).
match
).
match
...
@@ -154,6 +166,7 @@ class Scripts(Eggs):
...
@@ -154,6 +166,7 @@ class Scripts(Eggs):
interpreter
=
options
.
get
(
'interpreter'
),
interpreter
=
options
.
get
(
'interpreter'
),
initialization
=
options
.
get
(
'initialization'
,
''
),
initialization
=
options
.
get
(
'initialization'
,
''
),
arguments
=
options
.
get
(
'arguments'
,
''
),
arguments
=
options
.
get
(
'arguments'
,
''
),
relative_paths
=
self
.
_relative_paths
,
)
)
return
()
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