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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.buildout
Commits
c32aa1b2
Commit
c32aa1b2
authored
Apr 15, 2012
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed multi-python support
parent
b00423b2
Changes
17
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
97 additions
and
545 deletions
+97
-545
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+0
-2
src/zc/buildout/buildout.txt
src/zc/buildout/buildout.txt
+0
-20
src/zc/buildout/easy_install.py
src/zc/buildout/easy_install.py
+38
-67
src/zc/buildout/easy_install.txt
src/zc/buildout/easy_install.txt
+12
-26
src/zc/buildout/testing.py
src/zc/buildout/testing.py
+10
-59
src/zc/buildout/testing.txt
src/zc/buildout/testing.txt
+3
-17
src/zc/buildout/tests.py
src/zc/buildout/tests.py
+5
-57
src/zc/buildout/testselectingpython.py
src/zc/buildout/testselectingpython.py
+0
-68
src/zc/buildout/update.txt
src/zc/buildout/update.txt
+1
-1
src/zc/buildout/upgrading_distribute.txt
src/zc/buildout/upgrading_distribute.txt
+0
-1
zc.recipe.egg_/src/zc/recipe/egg/README.txt
zc.recipe.egg_/src/zc/recipe/egg/README.txt
+5
-11
zc.recipe.egg_/src/zc/recipe/egg/api.txt
zc.recipe.egg_/src/zc/recipe/egg/api.txt
+1
-2
zc.recipe.egg_/src/zc/recipe/egg/custom.py
zc.recipe.egg_/src/zc/recipe/egg/custom.py
+8
-9
zc.recipe.egg_/src/zc/recipe/egg/custom.txt
zc.recipe.egg_/src/zc/recipe/egg/custom.txt
+7
-19
zc.recipe.egg_/src/zc/recipe/egg/egg.py
zc.recipe.egg_/src/zc/recipe/egg/egg.py
+7
-10
zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt
zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt
+0
-143
zc.recipe.egg_/src/zc/recipe/egg/tests.py
zc.recipe.egg_/src/zc/recipe/egg/tests.py
+0
-33
No files found.
src/zc/buildout/buildout.py
View file @
c32aa1b2
...
...
@@ -113,8 +113,6 @@ _buildout_default_options = _annotate_section({
'bin-directory'
:
'bin'
,
'parts-directory'
:
'parts'
,
'installed'
:
'.installed.cfg'
,
'python'
:
'buildout'
,
'executable'
:
sys
.
executable
,
'log-level'
:
'INFO'
,
'log-format'
:
''
,
},
'DEFAULT_VALUE'
)
...
...
src/zc/buildout/buildout.txt
View file @
c32aa1b2
...
...
@@ -739,8 +739,6 @@ COMMAND_LINE_VALUE).
COMPUTED_VALUE
eggs-directory= eggs
DEFAULT_VALUE
executable= ...
DEFAULT_VALUE
installed= .installed.cfg
DEFAULT_VALUE
log-format=
...
...
@@ -751,8 +749,6 @@ COMMAND_LINE_VALUE).
/sample-buildout/buildout.cfg
parts-directory= parts
DEFAULT_VALUE
python= buildout
DEFAULT_VALUE
<BLANKLINE>
[data-dir]
path= foo bins
...
...
@@ -2209,7 +2205,6 @@ database is shown.
develop-eggs-directory = /sample-buildout/develop-eggs
directory = /sample-buildout
eggs-directory = /sample-buildout/eggs
executable = /usr/local/bin/python2.3
installed = /sample-buildout/.installed.cfg
log-format =
log-level = INFO
...
...
@@ -2217,7 +2212,6 @@ database is shown.
offline = false
parts =
parts-directory = /sample-buildout/parts
python = buildout
verbosity = 20
<BLANKLINE>
...
...
@@ -2245,10 +2239,6 @@ eggs-directory
*never* be modified. This can be a relative path, which is
interpreted relative to the directory option.
executable
The Python executable used to run the buildout. See the python
option below.
installed
The file path where information about the results of the previous
buildout run is written. This can be a relative path, which is
...
...
@@ -2268,16 +2258,6 @@ parts
parts-directory
A working directory that parts can used to store data.
python
The name of a section containing information about the default
Python interpreter. Recipes that need a installation
typically have options to tell them which Python installation to
use. By convention, if a section-specific option isn't used, the
option is looked for in the buildout section. The option must
point to a section with an executable option giving the path to a
Python executable. By default, the buildout section defines the
default Python as the Python used to run the buildout.
verbosity
A log-level adjustment. Typically, this is set via the -q and -v
command-line options.
...
...
src/zc/buildout/easy_install.py
View file @
c32aa1b2
This diff is collapsed.
Click to expand it.
src/zc/buildout/easy_install.txt
View file @
c32aa1b2
...
...
@@ -53,10 +53,6 @@ index
we'll just point to an empty directory on our link server. This
will make our examples run a little bit faster.
executable
A path to a Python executable. Distributions will be installed
using this executable and will be for the matching Python version.
path
A list of additional directories to search for locally-installed
distributions.
...
...
@@ -547,7 +543,7 @@ from the demo egg:
>>> scripts = zc.buildout.easy_install.scripts(
... ['demo'], ws, sys.executable, bin)
the
four
arguments we passed were:
the
three
arguments we passed were:
1. A sequence of distribution requirements. These are of the same
form as setuptools requirements. Here we passed a single
...
...
@@ -555,8 +551,6 @@ the four arguments we passed were:
2. A working set,
3. The Python executable to use, and
3. The destination directory.
The bin directory now contains a generated script:
...
...
@@ -582,7 +576,7 @@ interpreter and without having to provide a '.py' suffix.
The demo script run the entry point defined in the demo egg:
>>> cat(bin, 'demo') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.
4
#!/usr/local/bin/python2.
7
<BLANKLINE>
import sys
sys.path[0:0] = [
...
...
@@ -615,11 +609,11 @@ For example, we could have passed entry point information directly
rather than passing a requirement:
>>> scripts = zc.buildout.easy_install.scripts(
... [('demo', 'eggrecipedemo', 'main')],
...
ws,
sys.executable, bin)
... [('demo', 'eggrecipedemo', 'main')],
ws,
... sys.executable, bin)
>>> cat(bin, 'demo') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.
4
#!/usr/local/bin/python2.
7
<BLANKLINE>
import sys
sys.path[0:0] = [
...
...
@@ -663,7 +657,7 @@ The py script simply runs the Python interactive interpreter with
the path set:
>>> cat(bin, 'py') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.
4
#!/usr/local/bin/python2.
7
<BLANKLINE>
import sys
<BLANKLINE>
...
...
@@ -749,7 +743,7 @@ to be included in the a generated script:
... extra_paths=[foo])
>>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.
4
#!/usr/local/bin/python2.
7
<BLANKLINE>
import sys
sys.path[0:0] = [
...
...
@@ -775,7 +769,7 @@ parentheses in the call:
... arguments='1, 2')
>>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.
4
#!/usr/local/bin/python2.
7
import sys
sys.path[0:0] = [
'/sample-install/demo-0.3-py2.4.egg',
...
...
@@ -798,7 +792,7 @@ You can also pass script initialization code:
... initialization='import os\nos.chdir("foo")')
>>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.
4
#!/usr/local/bin/python2.
7
import sys
sys.path[0:0] = [
'/sample-install/demo-0.3-py2.4.egg',
...
...
@@ -838,7 +832,7 @@ to pass a common base directory of the scripts and eggs:
... relative_paths=bo)
>>> cat(bo, 'bin', 'run')
#!/usr/local/bin/python2.
4
#!/usr/local/bin/python2.
7
<BLANKLINE>
import os
<BLANKLINE>
...
...
@@ -870,7 +864,7 @@ Of course, running the script works:
We specified an interpreter and its paths are adjusted too:
>>> cat(bo, 'bin', 'py')
#!/usr/local/bin/python2.
4
#!/usr/local/bin/python2.
7
<BLANKLINE>
import os
<BLANKLINE>
...
...
@@ -950,10 +944,6 @@ index
we'll just point to an empty directory on our link server. This
will make our examples run a little bit faster.
executable
A path to a Python executable. Distributions will be installed
using this executable and will be for the matching Python version.
path
A list of additional directories to search for locally-installed
distributions.
...
...
@@ -1122,10 +1112,6 @@ build_ext
A dictionary of options to be passed to the distutils build_ext
command when building extensions.
executable
A path to a Python executable. Distributions will be installed
using this executable and will be for the matching Python version.
We have a local directory containing the extdemo source:
>>> ls(extdemo)
...
...
src/zc/buildout/testing.py
View file @
c32aa1b2
...
...
@@ -108,7 +108,7 @@ def system(command, input=''):
def
get
(
url
):
return
urllib2
.
urlopen
(
url
).
read
()
def
_runsetup
(
setup
,
executable
,
*
args
):
def
_runsetup
(
setup
,
*
args
):
if
os
.
path
.
isdir
(
setup
):
setup
=
os
.
path
.
join
(
setup
,
'setup.py'
)
args
=
list
(
args
)
...
...
@@ -117,7 +117,7 @@ def _runsetup(setup, executable, *args):
try
:
os
.
chdir
(
os
.
path
.
dirname
(
setup
))
zc
.
buildout
.
easy_install
.
call_subprocess
(
[
executable
,
setup
]
+
args
,
[
sys
.
executable
,
setup
]
+
args
,
env
=
dict
(
os
.
environ
,
PYTHONPATH
=
setuptools_location
))
if
os
.
path
.
exists
(
'build'
):
rmtree
(
'build'
)
...
...
@@ -125,64 +125,15 @@ def _runsetup(setup, executable, *args):
os
.
chdir
(
here
)
def
sdist
(
setup
,
dest
):
_runsetup
(
setup
,
sys
.
executable
,
'sdist'
,
'-d'
,
dest
,
'--formats=zip'
)
def
bdist_egg
(
setup
,
executable
,
dest
):
_runsetup
(
setup
,
executable
,
'bdist_egg'
,
'-d'
,
dest
)
def
find_python
(
version
):
e
=
os
.
environ
.
get
(
'PYTHON%s'
%
version
)
if
e
is
not
None
:
return
e
if
is_win32
:
e
=
'
\
Py
t
hon%s%s
\
py
t
hon.exe'
%
tuple
(
version
.
split
(
'.'
))
if
os
.
path
.
exists
(
e
):
return
e
_runsetup
(
setup
,
'sdist'
,
'-d'
,
dest
,
'--formats=zip'
)
def
bdist_egg
(
setup
,
executable
,
dest
=
None
):
# Backward compat:
if
dest
is
None
:
dest
=
executable
else
:
cmd
=
'python%s -c "import sys; print sys.executable"'
%
version
p
=
subprocess
.
Popen
(
cmd
,
shell
=
True
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
close_fds
=
MUST_CLOSE_FDS
)
i
,
o
=
(
p
.
stdin
,
p
.
stdout
)
i
.
close
()
e
=
o
.
read
().
strip
()
o
.
close
()
if
os
.
path
.
exists
(
e
):
return
e
cmd
=
'python -c "import sys; print
\
'
%s.%s
\
'
% sys.version_info[:2]"'
p
=
subprocess
.
Popen
(
cmd
,
shell
=
True
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
close_fds
=
MUST_CLOSE_FDS
)
i
,
o
=
(
p
.
stdin
,
p
.
stdout
)
i
.
close
()
e
=
o
.
read
().
strip
()
o
.
close
()
if
e
==
version
:
cmd
=
'python -c "import sys; print sys.executable"'
p
=
subprocess
.
Popen
(
cmd
,
shell
=
True
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
close_fds
=
MUST_CLOSE_FDS
)
i
,
o
=
(
p
.
stdin
,
p
.
stdout
)
i
.
close
()
e
=
o
.
read
().
strip
()
o
.
close
()
if
os
.
path
.
exists
(
e
):
return
e
raise
ValueError
(
"Couldn't figure out the executable for Python %(version)s.
\
n
"
"Set the environment variable PYTHON%(version)s to the location
\
n
"
"of the Python %(version)s executable before running the tests."
%
{
'version'
:
version
})
assert
executable
==
sys
.
executable
,
(
executable
,
sys
.
executable
)
_runsetup
(
setup
,
'bdist_egg'
,
'-d'
,
dest
)
def
wait_until
(
label
,
func
,
*
args
,
**
kw
):
if
'timeout'
in
kw
:
...
...
src/zc/buildout/testing.txt
View file @
c32aa1b2
...
...
@@ -109,26 +109,12 @@ number of names to the test namespace:
setup argument is a directory, the thge setup.py file in that
directory is used.
``bdist_egg(setup,
executable,
dest)``
Create an egg by running the given setup file
with the given
Python executable
and placing the result in the given destination
``bdist_egg(setup, dest)``
Create an egg by running the given setup file
and placing the result in the given destination
directory. If the setup argument is a directory, then the
setup.py file in that directory is used.
``find_python(version)``
Find a Python executable for the given version, where version is a
string like "2.4".
This function uses the following strategy to find a Python of the
given version:
- Look for an environment variable of the form PYTHON%(version)s.
- On windows, look for \Pythonm%(version)s\python
- on Unix, try running python%(version)s or just python to get the
executable
``zc.buildout.testing.buildoutTearDown(test)``
----------------------------------------------
...
...
src/zc/buildout/tests.py
View file @
c32aa1b2
...
...
@@ -22,7 +22,6 @@ import tempfile
import
unittest
import
zc.buildout.easy_install
import
zc.buildout.testing
import
zc.buildout.testselectingpython
import
zipfile
os_path_sep
=
os
.
path
.
sep
...
...
@@ -499,55 +498,6 @@ Then try to install it again:
"""
def
make_sure__get_version_works_with_2_digit_python_versions
():
"""
This is a test of an internal function used by higher-level machinery.
We'll start by creating a faux 'python' that executable that prints a
2-digit version. This is a bit of a pain to do portably. :(
>>> mkdir('demo')
>>> write('demo', 'setup.py',
... '''
... from setuptools import setup
... setup(name='demo',
... entry_points = {'console_scripts': ['demo = demo:main']},
... )
... ''')
>>> write('demo', 'demo.py',
... '''
... def main():
... print 'Python 2.5'
... ''')
>>> write('buildout.cfg',
... '''
... [buildout]
... develop = demo
... parts =
... ''')
>>> print system(join('bin', 'buildout')),
Develop: '/sample-buildout/demo'
>>> import zc.buildout.easy_install
>>> ws = zc.buildout.easy_install.working_set(
... ['demo'], sys.executable, ['develop-eggs'])
>>> bool(zc.buildout.easy_install.scripts(
... ['demo'], ws, sys.executable, 'bin'))
True
>>> print system(join('bin', 'demo')),
Python 2.5
Now, finally, let's test _get_version:
>>> zc.buildout.easy_install._get_version(join('bin', 'demo'))
'2.5'
"""
def
create_sections_on_command_line
():
"""
>>> write('buildout.cfg',
...
...
@@ -2655,6 +2605,7 @@ def increment_on_command_line():
######################################################################
def
create_sample_eggs
(
test
,
executable
=
sys
.
executable
):
assert
executable
==
sys
.
executable
,
(
executable
,
sys
.
executable
)
write
=
test
.
globs
[
'write'
]
dest
=
test
.
globs
[
'sample_eggs'
]
tmp
=
tempfile
.
mkdtemp
()
...
...
@@ -2680,7 +2631,7 @@ def create_sample_eggs(test, executable=sys.executable):
"setup(name='other', zip_safe=False, version='1.0', "
"py_modules=['eggrecipedemoneeded'])
\
n
"
)
zc
.
buildout
.
testing
.
bdist_egg
(
tmp
,
executable
,
dest
)
zc
.
buildout
.
testing
.
bdist_egg
(
tmp
,
sys
.
executable
,
dest
)
os
.
remove
(
os
.
path
.
join
(
tmp
,
'eggrecipedemoneeded.py'
))
...
...
@@ -2701,7 +2652,7 @@ def create_sample_eggs(test, executable=sys.executable):
"['demo = eggrecipedemo:main']},"
" zip_safe=True, version='0.%s%s')
\
n
"
%
(
i
,
c1
)
)
zc
.
buildout
.
testing
.
bdist_egg
(
tmp
,
executable
,
dest
)
zc
.
buildout
.
testing
.
bdist_egg
(
tmp
,
dest
)
write
(
tmp
,
'eggrecipebigdemo.py'
,
'import eggrecipedemo'
)
write
(
...
...
@@ -2712,7 +2663,7 @@ def create_sample_eggs(test, executable=sys.executable):
" py_modules=['eggrecipebigdemo'], "
" zip_safe=True, version='0.1')
\
n
"
)
zc
.
buildout
.
testing
.
bdist_egg
(
tmp
,
executable
,
dest
)
zc
.
buildout
.
testing
.
bdist_egg
(
tmp
,
sys
.
executable
,
dest
)
finally
:
shutil
.
rmtree
(
tmp
)
...
...
@@ -2858,7 +2809,7 @@ def bootstrapSetup(test):
normalize_bang
=
(
re
.
compile
(
re
.
escape
(
'#!'
+
zc
.
buildout
.
easy_install
.
_safe_arg
(
sys
.
executable
))),
'#!/usr/local/bin/python2.
4
'
,
'#!/usr/local/bin/python2.
7
'
,
)
def
test_suite
():
...
...
@@ -2874,8 +2825,6 @@ def test_suite():
zc
.
buildout
.
testing
.
normalize_egg_py
,
(
re
.
compile
(
'__buildout_signature__ = recipes-
\
S+
'
),
'
__buildout_signature__
=
recipes
-
SSSSSSSSSSS
'),
(re.compile('
executable
=
[
\
S
]
+
python
\
S
*
', re.I),
'
executable
=
python
'),
(re.compile('
[
-
d
]
setuptools
-
\
S
+
[.]
egg
'), '
setuptools
.
egg
'),
(re.compile('
zc
.
buildout
(
-
\
S
+
)
?
[.]
egg
(
-
link
)
?
'),
'
zc
.
buildout
.
egg
'),
...
...
@@ -2989,7 +2938,6 @@ def test_suite():
(re.compile(r'^[*]...'), '...'),
]),
),
zc.buildout.testselectingpython.test_suite(),
zc.buildout.rmtree.test_suite(),
doctest.DocFileSuite(
'windows.txt',
...
...
src/zc/buildout/testselectingpython.py
deleted
100644 → 0
View file @
b00423b2
##############################################################################
#
# Copyright (c) 2006 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
import
os
,
re
,
sys
,
unittest
from
zope.testing
import
doctest
,
renormalizing
import
zc.buildout.tests
import
zc.buildout.testing
if
sys
.
version_info
[:
2
]
==
(
2
,
4
):
other_version
=
"2.5"
else
:
other_version
=
"2.4"
__test__
=
dict
(
test_selecting_python_via_easy_install
=
"""
\
We can specify a specific Python executable.
>>> dest = tmpdir('sample-install')
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server],
... index='http://www.python.org/pypi/',
... always_unzip=True, executable=other_executable)
>>> ls(dest)
d demo-0.3-py%(other_version)s.egg
d demoneeded-1.1-py%(other_version)s.egg
"""
%
dict
(
other_version
=
other_version
)
)
def
multi_python
(
test
):
other_executable
=
zc
.
buildout
.
testing
.
find_python
(
other_version
)
sample_eggs
=
test
.
globs
[
'tmpdir'
](
'sample_eggs'
)
os
.
mkdir
(
os
.
path
.
join
(
sample_eggs
,
'index'
))
test
.
globs
[
'sample_eggs'
]
=
sample_eggs
zc
.
buildout
.
tests
.
create_sample_eggs
(
test
,
executable
=
other_executable
)
test
.
globs
[
'other_executable'
]
=
other_executable
def
setup
(
test
):
zc
.
buildout
.
testing
.
buildoutSetUp
(
test
)
multi_python
(
test
)
zc
.
buildout
.
tests
.
add_source_dist
(
test
)
test
.
globs
[
'link_server'
]
=
test
.
globs
[
'start_server'
](
test
.
globs
[
'sample_eggs'
])
def
test_suite
():
return
doctest
.
DocTestSuite
(
setUp
=
setup
,
tearDown
=
zc
.
buildout
.
testing
.
buildoutTearDown
,
checker
=
renormalizing
.
RENormalizing
([
(
re
.
compile
(
'setuptools-
\
S+-py%s.egg
'
% other_version),
'
setuptools
-
V
-
py
%
s
.
egg
' % other_version),
]),
)
src/zc/buildout/update.txt
View file @
c32aa1b2
...
...
@@ -89,7 +89,7 @@ Our buildout script has been updated to use the new eggs (HACK: only for
setuptools):
>>> cat(sample_buildout, 'bin', 'buildout')
#!/usr/local/bin/python2.
4
#!/usr/local/bin/python2.
7
<BLANKLINE>
import sys
sys.path[0:0] = [
...
...
src/zc/buildout/upgrading_distribute.txt
View file @
c32aa1b2
...
...
@@ -47,7 +47,6 @@ test: we only want to test that ``_get_dist()`` isn't getting called:
... dest=dest,
... links=[link_server],
... index=link_server+'index/',
... executable=sys.executable,
... always_unzip=True)
>>> installer._get_dist = mock_get_dist
>>> installer._call_easy_install('setuptools', None, dest, dist)
...
...
zc.recipe.egg_/src/zc/recipe/egg/README.txt
View file @
c32aa1b2
...
...
@@ -23,12 +23,6 @@ index
we'll just point to an empty directory on our link server. This
will make our examples run a little bit faster.
python
The name of a section to get the Python executable from.
If not specified, then the buildout python option is used. The
Python executable is found in the executable option of the named
section.
We have a link server that has a number of distributions:
>>> print get(link_server),
...
...
@@ -373,7 +367,7 @@ extra-paths option:
Let's look at the script that was generated:
>>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.
4
#!/usr/local/bin/python2.
7
<BLANKLINE>
import sys
sys.path[0:0] = [
...
...
@@ -420,7 +414,7 @@ breaking scripts.
Let's look at the script that was generated:
>>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.
4
#!/usr/local/bin/python2.
7
<BLANKLINE>
import os
<BLANKLINE>
...
...
@@ -467,7 +461,7 @@ each individual script section:
Generated script '/sample-buildout/bin/foo'.
>>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.
4
#!/usr/local/bin/python2.
7
<BLANKLINE>
import os
<BLANKLINE>
...
...
@@ -520,7 +514,7 @@ to be included in generated scripts:
Generated script '/sample-buildout/bin/foo'.
>>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.
4
#!/usr/local/bin/python2.
7
<BLANKLINE>
import sys
sys.path[0:0] = [
...
...
@@ -578,7 +572,7 @@ declare entry points using the entry-points option:
- other
>>> cat(sample_buildout, 'bin', 'other')
#!/usr/local/bin/python2.
4
#!/usr/local/bin/python2.
7
<BLANKLINE>
import sys
sys.path[0:0] = [
...
...
zc.recipe.egg_/src/zc/recipe/egg/api.txt
View file @
c32aa1b2
...
...
@@ -6,7 +6,7 @@ and generate scripts based on the resulting working sets. The egg
recipe provides an API that other recipes can use.
A recipe can reuse the egg recipe, supporting the eggs, find-links,
index,
extra-paths, and python
options. This is done by creating an
index,
and extra-paths
options. This is done by creating an
egg recipe instance in a recipes's contructor. In the recipe's
install script, the egg-recipe instance's working_set method is used
to collect the requested eggs and working set.
...
...
@@ -112,7 +112,6 @@ computed by the egg recipe by looking at .installed.cfg:
develop-eggs-directory = /sample-buildout/develop-eggs
eggs = demo<0.3
eggs-directory = /sample-buildout/eggs
executable = /usr/local/bin/python2.3
extras = other
find-links = http://localhost:27071/
index = http://localhost:27071/index
...
...
zc.recipe.egg_/src/zc/recipe/egg/custom.py
View file @
c32aa1b2
...
...
@@ -16,8 +16,12 @@
$Id$
"""
import
logging
,
os
,
re
,
zipfile
import
logging
import
os
import
re
import
sys
import
zc.buildout.easy_install
import
zipfile
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -29,9 +33,6 @@ class Base:
options
[
'_d'
]
=
buildout
[
'buildout'
][
'develop-eggs-directory'
]
python
=
options
.
get
(
'python'
,
buildout
[
'buildout'
][
'python'
])
options
[
'executable'
]
=
buildout
[
python
][
'executable'
]
self
.
build_ext
=
build_ext
(
buildout
,
options
)
def
update
(
self
):
...
...
@@ -92,8 +93,8 @@ class Custom(Base):
try
:
return
zc
.
buildout
.
easy_install
.
build
(
distribution
,
options
[
'_d'
],
self
.
build_ext
,
self
.
links
,
self
.
index
,
options
[
'executable'
],
[
options
[
'_e'
]]
,
newest
=
self
.
newest
,
self
.
links
,
self
.
index
,
sys
.
executable
,
[
options
[
'_e'
]],
newest
=
self
.
newest
,
)
finally
:
self
.
_restore_environment
()
...
...
@@ -130,9 +131,7 @@ class Develop(Base):
def
install
(
self
):
options
=
self
.
options
return
zc
.
buildout
.
easy_install
.
develop
(
options
[
'setup'
],
options
[
'_d'
],
self
.
build_ext
,
options
[
'executable'
],
)
options
[
'setup'
],
options
[
'_d'
],
self
.
build_ext
)
def
build_ext
(
buildout
,
options
):
...
...
zc.recipe.egg_/src/zc/recipe/egg/custom.txt
View file @
c32aa1b2
...
...
@@ -76,12 +76,6 @@ index
we'll just point to an empty directory on our link server. This
will make our examples run a little bit faster.
python
The name of a section to get the Python executable from.
If not specified, then the buildout python option is used. The
Python executable is found in the executable option of the named
section.
environment
The name of a section with additional environment variables. The
environment variables are set before the egg is built.
...
...
@@ -502,12 +496,6 @@ swig-cpp
swig-opts
List of SWIG command line options
python
The name of a section to get the Python executable from.
If not specified, then the buildout python option is used. The
Python executable is found in the executable option of the named
section.
To illustrate this, we'll use a directory containing the extdemo
example from the earlier section:
...
...
zc.recipe.egg_/src/zc/recipe/egg/egg.py
View file @
c32aa1b2
...
...
@@ -12,12 +12,14 @@
#
##############################################################################
"""Install packages as eggs
$Id$
"""
import
logging
,
os
,
re
,
zipfile
import
logging
import
os
import
re
import
sys
import
zc.buildout.easy_install
import
zipfile
class
Eggs
(
object
):
...
...
@@ -52,9 +54,6 @@ class Eggs(object):
assert
options
.
get
(
'unzip'
)
in
(
'true'
,
'false'
,
None
)
python
=
options
.
get
(
'python'
,
buildout
[
'buildout'
][
'python'
])
options
[
'executable'
]
=
buildout
[
python
][
'executable'
]
def
working_set
(
self
,
extra
=
()):
"""Separate method to just get the working set
...
...
@@ -71,7 +70,7 @@ class Eggs(object):
if
self
.
buildout
[
'buildout'
].
get
(
'offline'
)
==
'true'
:
ws
=
zc
.
buildout
.
easy_install
.
working_set
(
distributions
,
options
[
'executable'
],
distributions
,
[
options
[
'develop-eggs-directory'
],
options
[
'eggs-directory'
]]
)
else
:
...
...
@@ -83,7 +82,6 @@ class Eggs(object):
distributions
,
options
[
'eggs-directory'
],
links
=
self
.
links
,
index
=
self
.
index
,
executable
=
options
[
'executable'
],
path
=
[
options
[
'develop-eggs-directory'
]],
newest
=
self
.
buildout
[
'buildout'
].
get
(
'newest'
)
==
'true'
,
allow_hosts
=
self
.
allow_hosts
,
...
...
@@ -159,8 +157,7 @@ class Scripts(Eggs):
reqs
.
append
(
name
)
return
zc
.
buildout
.
easy_install
.
scripts
(
reqs
,
ws
,
options
[
'executable'
],
options
[
'bin-directory'
],
reqs
,
ws
,
sys
.
executable
,
options
[
'bin-directory'
],
scripts
=
scripts
,
extra_paths
=
self
.
extra_paths
,
interpreter
=
options
.
get
(
'interpreter'
),
...
...
zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt
deleted
100644 → 0
View file @
b00423b2
Controlling which Python to use
-------------------------------
The following assumes that you have Python 2.4 installed.
We can specify the python to use by specifying the name of a section
to read the Python executable from. The default is the section
defined by the python buildout option.
We have a link server:
>>> print get(link_server),
<html><body>
<a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
<a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
<a href="demo-0.2-py2.4.egg">demo-0.2-py2.4.egg</a><br>
<a href="demo-0.3-py2.4.egg">demo-0.3-py2.4.egg</a><br>
<a href="demo-0.4c1-py2.4.egg">demo-0.4c1-py2.4.egg</a><br>
<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="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>
</body></html>
We have a sample buildout. Let's update it's configuration file to
install the demo package using Python 2.4.
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... parts = demo
... eggs-directory = eggs
... index = http://www.python.org/pypi/
...
... [python2.4]
... executable = %(python23)s
...
... [demo]
... recipe = zc.recipe.egg
... eggs = demo <0.3
... find-links = %(server)s
... python = python2.4
... interpreter = py-demo
... """ % dict(server=link_server, python23=other_executable))
Now, if we run the buildout:
>>> import os
>>> os.chdir(sample_buildout)
>>> buildout = os.path.join(sample_buildout, 'bin', 'buildout')
>>> print system(buildout),
Installing demo.
Getting distribution for 'demo<0.3'.
Got demo 0.2.
Getting distribution for 'demoneeded'.
Getting distribution for 'setuptools'.
Got setuptools 0.6.
Got demoneeded 1.2c1.
Generated script '/sample-buildout/bin/demo'.
Generated interpreter '/sample-buildout/bin/py-demo'.
we'll get the Python 2.4 eggs for demo and demoneeded:
>>> ls(sample_buildout, 'eggs')
- demo-0.2-py2.4.egg
- demoneeded-1.2c1-py2.4.egg
d setuptools-0.6-py2.4.egg
d setuptools-0.6-py2.5.egg
- zc.buildout-1.0-py2.5.egg
And the generated scripts invoke Python 2.4:
>>> import sys
>>> if sys.platform == 'win32':
... script_name = 'demo-script.py'
... else:
... script_name = 'demo'
>>> f = open(os.path.join(sample_buildout, 'bin', script_name))
>>> shebang = f.readline().strip()
>>> if shebang[:3] == '#!"' and shebang[-1] == '"':
... shebang = '#!'+shebang[3:-1]
>>> shebang == '#!' + other_executable
True
>>> print f.read(), # doctest: +NORMALIZE_WHITESPACE
<BLANKLINE>
import sys
sys.path[0:0] = [
'/sample-buildout/eggs/demo-0.2-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
]
<BLANKLINE>
import eggrecipedemo
<BLANKLINE>
if __name__ == '__main__':
eggrecipedemo.main()
>>> if sys.platform == 'win32':
... f = open(os.path.join(sample_buildout, 'bin', 'py-demo-script.py'))
... else:
... f = open(os.path.join(sample_buildout, 'bin', 'py-demo'))
>>> shebang = f.readline().strip()
>>> if shebang[:3] == '#!"' and shebang[-1] == '"':
... shebang = '#!'+shebang[3:-1]
>>> shebang == '#!' + other_executable
True
>>> print f.read(), # doctest: +NORMALIZE_WHITESPACE
<BLANKLINE>
import sys
<BLANKLINE>
sys.path[0:0] = [
'/sample-buildout/eggs/demo-0.2-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
]
<BLANKLINE>
_interactive = True
if len(sys.argv) > 1:
_options, _args = __import__("getopt").getopt(sys.argv[1:], 'ic:m:')
_interactive = False
for (_opt, _val) in _options:
if _opt == '-i':
_interactive = True
elif _opt == '-c':
exec _val
elif _opt == '-m':
sys.argv[1:] = _args
_args = []
__import__("runpy").run_module(
_val, {}, "__main__", alter_sys=True)
<BLANKLINE>
if _args:
sys.argv[:] = _args
__file__ = _args[0]
del _options, _args
execfile(__file__)
<BLANKLINE>
if _interactive:
del _interactive
__import__("code").interact(banner="", local=globals())
>>> f.close()
zc.recipe.egg_/src/zc/recipe/egg/tests.py
View file @
c32aa1b2
...
...
@@ -14,7 +14,6 @@
import
os
,
re
,
shutil
,
sys
import
zc.buildout.tests
import
zc.buildout.testselectingpython
import
zc.buildout.testing
import
unittest
...
...
@@ -33,10 +32,6 @@ def setUp(test):
zc
.
buildout
.
tests
.
easy_install_SetUp
(
test
)
zc
.
buildout
.
testing
.
install_develop
(
'zc.recipe.egg'
,
test
)
def
setUpSelecting
(
test
):
zc
.
buildout
.
testselectingpython
.
setup
(
test
)
zc
.
buildout
.
testing
.
install_develop
(
'zc.recipe.egg'
,
test
)
def
test_suite
():
suite
=
unittest
.
TestSuite
((
doctest
.
DocFileSuite
(
...
...
@@ -68,8 +63,6 @@ def test_suite():
'zc.buildout-
\
S+
\
s*'
),
'__buildout_signature__ = sample- zc.recipe.egg-'
),
(
re
.
compile
(
'executable = [
\
S ]+py
t
hon
\
S*
'
, re.I),
'
executable
=
python
'),
(
re
.
compile
(
'find-links = http://localhost:
\
d+/
'
),
'
find
-
links
=
http
:
//
localhost
:
8080
/
'),
(re.compile('
index
=
http
:
//
localhost
:
\
d
+/
index
'),
...
...
@@ -89,33 +82,7 @@ def test_suite():
(re.compile('
extdemo
[.]
pyd
'), '
extdemo
.
so
')
]),
),
))
if sys.version_info[:2] == (2, 5):
# Only run selecting python tests if not 2.4, since
# 2.4 is the alternate python used in the tests.
suite.addTest(
doctest.DocFileSuite(
'
selecting
-
python
.
txt
',
setUp=setUpSelecting,
tearDown=zc.buildout.testing.buildoutTearDown,
checker=renormalizing.RENormalizing([
zc.buildout.testing.normalize_path,
zc.buildout.testing.normalize_endings,
zc.buildout.testing.normalize_script,
(re.compile('
Got
setuptools
\
S
+
'), '
Got
setuptools
V
'),
(re.compile('
([
d
-
]
)
?
setuptools
-
\
S
+-
py
'),
'
setuptools
-
V
-
py
'),
(re.compile('
-
py2
[.][
0
-
35
-
9
][.]
'), '
py2
.
5.
'),
(re.compile('
zc
.
buildout
-
\
S
+
[.]
egg
'),
'
zc
.
buildout
.
egg
'),
(re.compile('
zc
.
buildout
[.]
egg
-
link
'),
'
zc
.
buildout
.
egg
'),
]),
),
)
return suite
if __name__ == '
__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