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
8a3f1e9f
Commit
8a3f1e9f
authored
May 12, 2012
by
Jim Fulton
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote branch 'remotes/origin/reinout-scripts'
Providing support for non-entry-point-based scripts.
parents
89feb749
6c71c546
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
141 additions
and
4 deletions
+141
-4
CHANGES.rst
CHANGES.rst
+4
-1
doc/tutorial.txt
doc/tutorial.txt
+4
-3
src/zc/buildout/downloadcache.txt
src/zc/buildout/downloadcache.txt
+1
-0
src/zc/buildout/easy_install.py
src/zc/buildout/easy_install.py
+68
-0
src/zc/buildout/easy_install.txt
src/zc/buildout/easy_install.txt
+51
-0
src/zc/buildout/tests.py
src/zc/buildout/tests.py
+12
-0
zc.recipe.egg_/src/zc/recipe/egg/README.txt
zc.recipe.egg_/src/zc/recipe/egg/README.txt
+1
-0
No files found.
CHANGES.rst
View file @
8a3f1e9f
Change History
**************
1.4.5
(unreleased)
?.?.?
(unreleased)
==================
- Distutils-style scripts are also installed now (for instance pyflakes' and
docutils' scripts). https://bugs.launchpad.net/zc.buildout/+bug/422724
- Switched development location to github.com/buildout.
- Avoid sorting the working set and requirements when it won't be
...
...
doc/tutorial.txt
View file @
8a3f1e9f
...
...
@@ -861,9 +861,10 @@ Installing scripts
If any of the named eggs have ``console_script`` entry
points, then scripts will be generated for the entry points.
If a distribution doesn't use setuptools, it may not declare it's
entry points. In that case, you can specify entry points in the
recipe data.
If a distribution doesn't use setuptools, it may not declare it's entry
points. In that case, you can specify entry points in the recipe data.
Buildout *does* detect distutils-style scripts without an entry point and
will generate a script for them when found.
Script initialization
=====================
...
...
src/zc/buildout/downloadcache.txt
View file @
8a3f1e9f
...
...
@@ -41,6 +41,7 @@ download:
<a href="demoneeded-1.0.zip">demoneeded-1.0.zip</a><br>
<a href="demoneeded-1.1.zip">demoneeded-1.1.zip</a><br>
<a href="demoneeded-1.2c1.zip">demoneeded-1.2c1.zip</a><br>
<a href="du_zipped-1.0-pyN.N.egg">du_zipped-1.0-pyN.N.egg</a><br>
<a href="extdemo-1.4.zip">extdemo-1.4.zip</a><br>
<a href="index/">index/</a><br>
<a href="other-1.0-py2.4.egg">other-1.0-py2.4.egg</a><br>
...
...
src/zc/buildout/easy_install.py
View file @
8a3f1e9f
...
...
@@ -863,16 +863,25 @@ def scripts(reqs, working_set, executable, dest=None,
initialization
=
'
\
n
'
+
initialization
+
'
\
n
'
entry_points
=
[]
distutils_scripts
=
[]
for
req
in
reqs
:
if
isinstance
(
req
,
str
):
req
=
pkg_resources
.
Requirement
.
parse
(
req
)
dist
=
working_set
.
find
(
req
)
# regular console_scripts entry points
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
))
)
# The metadata on "old-style" distutils scripts is not retained by
# distutils/setuptools, except by placing the original scripts in
# /EGG-INFO/scripts/.
if
dist
.
metadata_isdir
(
'scripts'
):
for
name
in
dist
.
metadata_listdir
(
'scripts'
):
contents
=
dist
.
get_metadata
(
'scripts/'
+
name
)
distutils_scripts
.
append
((
name
,
contents
))
else
:
entry_points
.
append
(
req
)
...
...
@@ -892,6 +901,22 @@ def scripts(reqs, working_set, executable, dest=None,
initialization
,
rpsetup
)
)
for
name
,
contents
in
distutils_scripts
:
if
scripts
is
not
None
:
sname
=
scripts
.
get
(
name
)
if
sname
is
None
:
continue
else
:
sname
=
name
sname
=
os
.
path
.
join
(
dest
,
sname
)
spath
,
rpsetup
=
_relative_path_and_setup
(
sname
,
path
,
relative_paths
)
generated
.
extend
(
_distutils_script
(
spath
,
sname
,
contents
,
executable
,
initialization
,
rpsetup
)
)
if
interpreter
:
sname
=
os
.
path
.
join
(
dest
,
interpreter
)
spath
,
rpsetup
=
_relative_path_and_setup
(
sname
,
path
,
relative_paths
)
...
...
@@ -899,6 +924,7 @@ def scripts(reqs, working_set, executable, dest=None,
return
generated
def
_relative_path_and_setup
(
sname
,
path
,
relative_paths
):
if
relative_paths
:
relative_paths
=
os
.
path
.
normcase
(
relative_paths
)
...
...
@@ -928,6 +954,7 @@ def _relative_depth(common, path):
path
=
dirname
return
n
def
_relative_path
(
common
,
path
):
r
=
[]
while
1
:
...
...
@@ -941,6 +968,7 @@ def _relative_path(common, path):
r
.
reverse
()
return
os
.
path
.
join
(
*
r
)
def
_relativitize
(
path
,
script
,
relative_paths
):
if
path
==
script
:
raise
AssertionError
(
"path == script"
)
...
...
@@ -975,6 +1003,33 @@ def _script(module_name, attrs, path, dest, arguments, initialization, rsetup):
initialization
=
initialization
,
relative_paths_setup
=
rsetup
,
)
return
_create_script
(
contents
,
dest
)
def
_distutils_script
(
path
,
dest
,
script_content
,
executable
,
initialization
,
rsetup
):
lines
=
script_content
.
splitlines
(
True
)
if
not
(
'#!'
in
lines
[
0
])
and
(
'python'
in
lines
[
0
]):
# The script doesn't follow distutil's rules. Ignore it.
return
[]
original_content
=
''
.
join
(
lines
[
1
:])
contents
=
distutils_script_template
%
dict
(
python
=
_safe_arg
(
executable
),
path
=
path
,
initialization
=
initialization
,
relative_paths_setup
=
rsetup
,
original_content
=
original_content
)
return
_create_script
(
contents
,
dest
)
def
_create_script
(
contents
,
dest
):
generated
=
[]
script
=
dest
if
is_win32
:
dest
+=
'-script.py'
changed
=
not
(
os
.
path
.
exists
(
dest
)
and
open
(
dest
).
read
()
==
contents
)
if
is_win32
:
...
...
@@ -998,6 +1053,7 @@ def _script(module_name, attrs, path, dest, arguments, initialization, rsetup):
generated
.
append
(
dest
)
return
generated
if
is_jython
and
jython_os_name
==
'linux'
:
script_header
=
'#!/usr/bin/env %(python)s'
else
:
...
...
@@ -1018,6 +1074,18 @@ if __name__ == '__main__':
%(module_name)s.%(attrs)s(%(arguments)s)
'''
distutils_script_template
=
script_header
+
'''
\
%(relative_paths_setup)s
import sys
sys.path[0:0] = [
%(path)s,
]
%(initialization)s
%(original_content)s
'''
def
_pyscript
(
path
,
dest
,
rsetup
):
generated
=
[]
...
...
src/zc/buildout/easy_install.txt
View file @
8a3f1e9f
...
...
@@ -101,6 +101,7 @@ We have a link server that has a number of eggs:
<a href="demoneeded-1.0.zip">demoneeded-1.0.zip</a><br>
<a href="demoneeded-1.1.zip">demoneeded-1.1.zip</a><br>
<a href="demoneeded-1.2c1.zip">demoneeded-1.2c1.zip</a><br>
<a href="du_zipped-1.0-pyN.N.egg">du_zipped-1.0-pyN.N.egg</a><br>
<a href="extdemo-1.4.zip">extdemo-1.4.zip</a><br>
<a href="index/">index/</a><br>
<a href="other-1.0-py2.4.egg">other-1.0-py2.4.egg</a><br>
...
...
@@ -865,6 +866,55 @@ We specified an interpreter and its paths are adjusted too:
__import__("code").interact(banner="", local=globals())
Installing distutils-style scripts
----------------------------------
Most python libraries use the console_scripts entry point nowadays. But
several still have a ``scripts=['bin/something']`` in their setup() call.
Buildout also installs those:
>>> distdir = tmpdir('distutilsscriptdir')
>>> distbin = tmpdir('distutilsscriptbin')
>>> ws = zc.buildout.easy_install.install(
... ['other'], distdir,
... links=[link_server], index=link_server+'index/')
>>> scripts = zc.buildout.easy_install.scripts(
... ['other'], ws, sys.executable, distbin)
>>> ls(distbin)
- distutilsscript
It also works for zipped eggs:
>>> distdir2 = tmpdir('distutilsscriptdir2')
>>> distbin2 = tmpdir('distutilsscriptbin2')
>>> ws = zc.buildout.easy_install.install(
... ['du_zipped'], distdir2,
... links=[link_server], index=link_server+'index/')
>>> scripts = zc.buildout.easy_install.scripts(
... ['du_zipped'], ws, sys.executable, distbin2)
>>> ls(distbin2)
- distutilsscript
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
interpreter. Buildout does the same, but additionally also adds the sys.path
like for the console_scripts:
>>> cat(distbin, 'distutilsscript')
#!/usr/local/bin/python2.7
<BLANKLINE>
import sys
sys.path[0:0] = [
'/distutilsscriptdir/other-1.0-pyN.N.egg',
]
<BLANKLINE>
<BLANKLINE>
print "distutils!"
Due to the nature of distutils scripts, buildout cannot pass arguments as
there's no specific method to pass them to.
Handling custom build options for extensions provided in source distributions
-----------------------------------------------------------------------------
...
...
@@ -984,6 +1034,7 @@ Let's update our link server with a new version of extdemo:
<a href="demoneeded-1.0.zip">demoneeded-1.0.zip</a><br>
<a href="demoneeded-1.1.zip">demoneeded-1.1.zip</a><br>
<a href="demoneeded-1.2c1.zip">demoneeded-1.2c1.zip</a><br>
<a href="du_zipped-1.0-pyN.N.egg">du_zipped-1.0-pyN.N.egg</a><br>
<a href="extdemo-1.4.zip">extdemo-1.4.zip</a><br>
<a href="extdemo-1.5.zip">extdemo-1.5.zip</a><br>
<a href="index/">index/</a><br>
...
...
src/zc/buildout/tests.py
View file @
8a3f1e9f
...
...
@@ -2624,14 +2624,26 @@ def create_sample_eggs(test, executable=sys.executable):
)
zc
.
buildout
.
testing
.
sdist
(
tmp
,
dest
)
write
(
tmp
,
'distutilsscript'
,
'#!/usr/bin/python
\
n
print "distutils!"'
)
write
(
tmp
,
'setup.py'
,
"from setuptools import setup
\
n
"
"setup(name='other', zip_safe=False, version='1.0', "
"scripts=['distutilsscript'],"
"py_modules=['eggrecipedemoneeded'])
\
n
"
)
zc
.
buildout
.
testing
.
bdist_egg
(
tmp
,
sys
.
executable
,
dest
)
write
(
tmp
,
'setup.py'
,
"from setuptools import setup
\
n
"
"setup(name='du_zipped', zip_safe=True, version='1.0', "
"scripts=['distutilsscript'],"
"py_modules=['eggrecipedemoneeded'])
\
n
"
)
zc
.
buildout
.
testing
.
bdist_egg
(
tmp
,
executable
,
dest
)
os
.
remove
(
os
.
path
.
join
(
tmp
,
'distutilsscript'
))
os
.
remove
(
os
.
path
.
join
(
tmp
,
'eggrecipedemoneeded.py'
))
for
i
in
(
1
,
2
,
3
,
4
):
...
...
zc.recipe.egg_/src/zc/recipe/egg/README.txt
View file @
8a3f1e9f
...
...
@@ -35,6 +35,7 @@ We have a link server that has a number of distributions:
<a href="demoneeded-1.0.zip">demoneeded-1.0.zip</a><br>
<a href="demoneeded-1.1.zip">demoneeded-1.1.zip</a><br>
<a href="demoneeded-1.2c1.zip">demoneeded-1.2c1.zip</a><br>
<a href="du_zipped-1.0-pyN.N.egg">du_zipped-1.0-pyN.N.egg</a><br>
<a href="extdemo-1.4.zip">extdemo-1.4.zip</a><br>
<a href="index/">index/</a><br>
<a href="other-1.0-py2.3.egg">other-1.0-py2.3.egg</a><br>
...
...
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