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
Boxiang Sun
slapos.buildout
Commits
d9799304
Commit
d9799304
authored
Oct 24, 2006
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the ability to specify initialization code when creating scripts.
parent
bee2bc72
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
10 deletions
+50
-10
CHANGES.txt
CHANGES.txt
+10
-0
setup.py
setup.py
+1
-1
src/zc/buildout/easy_install.py
src/zc/buildout/easy_install.py
+12
-4
src/zc/buildout/easy_install.txt
src/zc/buildout/easy_install.txt
+27
-5
No files found.
CHANGES.txt
View file @
d9799304
...
...
@@ -20,6 +20,16 @@ priorities include:
Change History
**************
1.0.0b12 (2006-10-24)
=====================
Feature Changes
---------------
- Added an initialization argument to the
zc.buildout.easy_install.scripts function to include initialization
code in generated scripts.
1.0.0b11 (2006-10-24)
=====================
...
...
setup.py
View file @
d9799304
...
...
@@ -7,7 +7,7 @@ def read(*rnames):
name
=
"zc.buildout"
setup
(
name
=
name
,
version
=
"1.0.0b1
1
"
,
version
=
"1.0.0b1
2
"
,
author
=
"Jim Fulton"
,
author_email
=
"jim@zope.com"
,
description
=
"System for managing development buildouts"
,
...
...
src/zc/buildout/easy_install.py
View file @
d9799304
...
...
@@ -451,6 +451,7 @@ def scripts(reqs, working_set, executable, dest,
extra_paths
=
(),
arguments
=
''
,
interpreter
=
None
,
initialization
=
''
,
):
path
=
[
dist
.
location
for
dist
in
working_set
]
...
...
@@ -462,6 +463,9 @@ def scripts(reqs, working_set, executable, dest,
raise
TypeError
(
'Expected iterable of requirements or entry points,'
' got string.'
)
if
initialization
:
initialization
=
'
\
n
'
+
initialization
+
'
\
n
'
entry_points
=
[]
for
req
in
reqs
:
if
isinstance
(
req
,
str
):
...
...
@@ -470,7 +474,8 @@ def scripts(reqs, working_set, executable, dest,
for
name
in
pkg_resources
.
get_entry_map
(
dist
,
'console_scripts'
):
entry_point
=
dist
.
get_entry_info
(
'console_scripts'
,
name
)
entry_points
.
append
(
(
name
,
entry_point
.
module_name
,
'.'
.
join
(
entry_point
.
attrs
))
(
name
,
entry_point
.
module_name
,
'.'
.
join
(
entry_point
.
attrs
))
)
else
:
entry_points
.
append
(
req
)
...
...
@@ -485,7 +490,8 @@ def scripts(reqs, working_set, executable, dest,
sname
=
os
.
path
.
join
(
dest
,
sname
)
generated
.
extend
(
_script
(
module_name
,
attrs
,
path
,
sname
,
executable
,
arguments
)
_script
(
module_name
,
attrs
,
path
,
sname
,
executable
,
arguments
,
initialization
)
)
if
interpreter
:
...
...
@@ -494,7 +500,8 @@ def scripts(reqs, working_set, executable, dest,
return
generated
def
_script
(
module_name
,
attrs
,
path
,
dest
,
executable
,
arguments
):
def
_script
(
module_name
,
attrs
,
path
,
dest
,
executable
,
arguments
,
initialization
):
generated
=
[]
if
sys
.
platform
==
'win32'
:
# generate exe file and give the script a magic name:
...
...
@@ -510,6 +517,7 @@ def _script(module_name, attrs, path, dest, executable, arguments):
module_name
=
module_name
,
attrs
=
attrs
,
arguments
=
arguments
,
initialization
=
initialization
,
))
try
:
os
.
chmod
(
dest
,
0755
)
...
...
@@ -525,7 +533,7 @@ import sys
sys.path[0:0] = [
%(path)s,
]
%(initialization)s
import %(module_name)s
if __name__ == '__main__':
...
...
src/zc/buildout/easy_install.txt
View file @
d9799304
...
...
@@ -59,9 +59,6 @@ always_unzip
A flag indicating that newly-downloaded distributions should be
directories even if they could be installed as zip files.
arguments
Source code to be used to pass arguments when calling a script entry point.
The install method returns a working set containing the distributions
needed to meet the given requirements.
...
...
@@ -381,8 +378,8 @@ to be included in the a generated script:
Providing script arguments
--------------------------
A
n "argument" keyword argument can be used to pass arguments to an
entry point. The value passed source string to be placed between the
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
parentheses in the call:
>>> scripts = zc.buildout.easy_install.scripts(
...
...
@@ -402,6 +399,31 @@ parentheses in the call:
if __name__ == '__main__':
eggrecipedemo.main(1, 2)
Passing initialization code
---------------------------
You can also pass script initialization code:
>>> scripts = zc.buildout.easy_install.scripts(
... ['demo'], ws, sys.executable, bin, dict(demo='run'),
... arguments='1, 2',
... initialization='import os\nos.chdir("foo")')
>>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.4
import sys
sys.path[0:0] = [
'/sample-install/demo-0.3-py2.4.egg',
'/sample-install/demoneeded-1.1-py2.4.egg',
]
<BLANKLINE>
import os
os.chdir("foo")
<BLANKLINE>
import eggrecipedemo
<BLANKLINE>
if __name__ == '__main__':
eggrecipedemo.main(1, 2)
Handling custom build options for extensions
...
...
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