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
3ed7c06b
Commit
3ed7c06b
authored
Jul 22, 2012
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests now pass on Python 2.6, 2.7 and 3.2
parent
44046ba2
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
70 additions
and
55 deletions
+70
-55
bootstrap/bootstrap.py
bootstrap/bootstrap.py
+8
-4
dev.py
dev.py
+14
-6
src/zc/buildout/bootstrap.txt
src/zc/buildout/bootstrap.txt
+1
-5
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+1
-1
src/zc/buildout/download.py
src/zc/buildout/download.py
+21
-15
src/zc/buildout/download.txt
src/zc/buildout/download.txt
+2
-2
src/zc/buildout/easy_install.py
src/zc/buildout/easy_install.py
+6
-3
src/zc/buildout/isolation.txt
src/zc/buildout/isolation.txt
+1
-2
src/zc/buildout/rmtree.py
src/zc/buildout/rmtree.py
+1
-1
src/zc/buildout/testing.py
src/zc/buildout/testing.py
+15
-9
src/zc/buildout/tests.py
src/zc/buildout/tests.py
+0
-7
No files found.
bootstrap/bootstrap.py
View file @
3ed7c06b
...
@@ -18,7 +18,7 @@ The script accepts buildout command-line options, so you can
...
@@ -18,7 +18,7 @@ The script accepts buildout command-line options, so you can
use the -c option to specify an alternate configuration file.
use the -c option to specify an alternate configuration file.
"""
"""
import
os
,
shutil
,
sys
,
tempfile
,
urllib
.
request
,
urllib
.
error
,
urllib
.
parse
import
os
,
shutil
,
sys
,
tempfile
from
optparse
import
OptionParser
from
optparse
import
OptionParser
tmpeggs
=
tempfile
.
mkdtemp
()
tmpeggs
=
tempfile
.
mkdtemp
()
...
@@ -80,9 +80,13 @@ try:
...
@@ -80,9 +80,13 @@ try:
raise
ImportError
raise
ImportError
except
ImportError
:
except
ImportError
:
ez
=
{}
ez
=
{}
exec
(
urllib
.
request
.
urlopen
(
'http://python-distribute.org/distribute_setup.py'
try
:
).
read
(),
ez
)
from
urllib.request
import
urlopen
except
ImportError
:
from
urllib2
import
urlopen
exec
(
urlopen
(
'http://python-distribute.org/distribute_setup.py'
).
read
(),
ez
)
setup_args
=
dict
(
to_dir
=
tmpeggs
,
download_delay
=
0
,
no_fake
=
True
)
setup_args
=
dict
(
to_dir
=
tmpeggs
,
download_delay
=
0
,
no_fake
=
True
)
ez
[
'use_setuptools'
](
**
setup_args
)
ez
[
'use_setuptools'
](
**
setup_args
)
...
...
dev.py
View file @
3ed7c06b
...
@@ -17,7 +17,7 @@ This is different from a normal boostrapping process because the
...
@@ -17,7 +17,7 @@ This is different from a normal boostrapping process because the
buildout egg itself is installed as a develop egg.
buildout egg itself is installed as a develop egg.
"""
"""
import
os
,
shutil
,
sys
,
subprocess
,
urllib
.
request
,
urllib
.
error
,
urllib
.
parse
import
os
,
shutil
,
sys
,
subprocess
for
d
in
'eggs'
,
'develop-eggs'
,
'bin'
,
'parts'
:
for
d
in
'eggs'
,
'develop-eggs'
,
'bin'
,
'parts'
:
if
not
os
.
path
.
exists
(
d
):
if
not
os
.
path
.
exists
(
d
):
...
@@ -49,16 +49,24 @@ try:
...
@@ -49,16 +49,24 @@ try:
except
ImportError
:
except
ImportError
:
pass
pass
else
:
else
:
raise
SystemError
(
message
=
(
"Buildout development with a pre-installed setuptools or "
"Buildout development with a pre-installed setuptools or "
"distribute is not supported.%s"
"distribute is not supported."
%
(
''
if
nosite
else
' Try running with -S option to Python.'
))
)
if
not
nosite
:
message
+=
' Try running with -S option to Python.'
raise
SystemError
(
message
)
######################################################################
######################################################################
# Install distribute
# Install distribute
ez
=
{}
ez
=
{}
exec
(
urllib
.
request
.
urlopen
(
'http://python-distribute.org/distribute_setup.py'
).
read
(),
ez
)
try
:
from
urllib.request
import
urlopen
except
ImportError
:
from
urllib2
import
urlopen
exec
(
urlopen
(
'http://python-distribute.org/distribute_setup.py'
).
read
(),
ez
)
ez
[
'use_setuptools'
](
to_dir
=
'eggs'
,
download_delay
=
0
)
ez
[
'use_setuptools'
](
to_dir
=
'eggs'
,
download_delay
=
0
)
import
pkg_resources
import
pkg_resources
...
...
src/zc/buildout/bootstrap.txt
View file @
3ed7c06b
...
@@ -79,11 +79,7 @@ Now let's try with `2.0.0`, which happens to exist::
...
@@ -79,11 +79,7 @@ Now let's try with `2.0.0`, which happens to exist::
... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
... 'bootstrap.py --version 2.0.0')); print_('X')
... 'bootstrap.py --version 2.0.0')); print_('X')
... # doctest: +ELLIPSIS
... # doctest: +ELLIPSIS
X
X...Generated script '/sample/bin/buildout'...X
...
Generated script '/sample/bin/buildout'.
...
X
Let's make sure the generated `buildout` script uses it::
Let's make sure the generated `buildout` script uses it::
...
...
src/zc/buildout/buildout.py
View file @
3ed7c06b
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
import
zc.buildout.easy_install
import
zc.buildout.easy_install
no_site
=
zc
.
buildout
.
easy_install
.
no_site
no_site
=
zc
.
buildout
.
easy_install
.
no_site
from
.rmtree
import
rmtree
from
zc.buildout
.rmtree
import
rmtree
from
hashlib
import
md5
from
hashlib
import
md5
try
:
try
:
...
...
src/zc/buildout/download.py
View file @
3ed7c06b
...
@@ -17,6 +17,24 @@ try:
...
@@ -17,6 +17,24 @@ try:
from
hashlib
import
md5
from
hashlib
import
md5
except
ImportError
:
except
ImportError
:
from
md5
import
new
as
md5
from
md5
import
new
as
md5
try
:
# Python 3
from
urllib.request
import
FancyURLopener
,
URLopener
,
urlretrieve
from
urllib.parse
import
urlparse
from
urllib
import
request
as
urllib
# for monkey patch below :(
except
ImportError
:
# Python 2
from
urllib
import
FancyURLopener
,
URLopener
,
urlretrieve
from
urlparse
import
urlparse
import
urllib
class
URLOpener
(
FancyURLopener
):
http_error_default
=
URLopener
.
http_error_default
urllib
.
_urlopener
=
URLOpener
()
# Ook! Monkey patch!
from
zc.buildout.easy_install
import
realpath
from
zc.buildout.easy_install
import
realpath
import
logging
import
logging
import
os
import
os
...
@@ -25,22 +43,11 @@ import re
...
@@ -25,22 +43,11 @@ import re
import
shutil
import
shutil
import
sys
import
sys
import
tempfile
import
tempfile
import
urllib.request
,
urllib
.
parse
,
urllib
.
error
import
urllib.parse
import
zc.buildout
import
zc.buildout
class
URLOpener
(
urllib
.
request
.
FancyURLopener
):
http_error_default
=
urllib
.
request
.
URLopener
.
http_error_default
class
ChecksumError
(
zc
.
buildout
.
UserError
):
class
ChecksumError
(
zc
.
buildout
.
UserError
):
pass
pass
url_opener
=
URLOpener
()
class
Download
(
object
):
class
Download
(
object
):
"""Configurable download utility.
"""Configurable download utility.
...
@@ -158,7 +165,7 @@ class Download(object):
...
@@ -158,7 +165,7 @@ class Download(object):
if
re
.
match
(
r"^[A-Za-z]:\\"
,
url
):
if
re
.
match
(
r"^[A-Za-z]:\\"
,
url
):
url
=
'file:'
+
url
url
=
'file:'
+
url
parsed_url
=
url
lib
.
parse
.
url
parse
(
url
,
'file'
)
parsed_url
=
urlparse
(
url
,
'file'
)
url_scheme
,
_
,
url_path
=
parsed_url
[:
3
]
url_scheme
,
_
,
url_path
=
parsed_url
[:
3
]
if
url_scheme
==
'file'
:
if
url_scheme
==
'file'
:
self
.
logger
.
debug
(
'Using local resource %s'
%
url
)
self
.
logger
.
debug
(
'Using local resource %s'
%
url
)
...
@@ -173,10 +180,9 @@ class Download(object):
...
@@ -173,10 +180,9 @@ class Download(object):
"Couldn't download %r in offline mode."
%
url
)
"Couldn't download %r in offline mode."
%
url
)
self
.
logger
.
info
(
'Downloading %s'
%
url
)
self
.
logger
.
info
(
'Downloading %s'
%
url
)
urllib
.
request
.
_urlopener
=
url_opener
handle
,
tmp_path
=
tempfile
.
mkstemp
(
prefix
=
'buildout-'
)
handle
,
tmp_path
=
tempfile
.
mkstemp
(
prefix
=
'buildout-'
)
try
:
try
:
tmp_path
,
headers
=
url
lib
.
request
.
url
retrieve
(
url
,
tmp_path
)
tmp_path
,
headers
=
urlretrieve
(
url
,
tmp_path
)
if
not
check_md5sum
(
tmp_path
,
md5sum
):
if
not
check_md5sum
(
tmp_path
,
md5sum
):
raise
ChecksumError
(
raise
ChecksumError
(
'MD5 checksum mismatch downloading %r'
%
url
)
'MD5 checksum mismatch downloading %r'
%
url
)
...
@@ -206,7 +212,7 @@ class Download(object):
...
@@ -206,7 +212,7 @@ class Download(object):
else
:
else
:
if
re
.
match
(
r"^[A-Za-z]:\\"
,
url
):
if
re
.
match
(
r"^[A-Za-z]:\\"
,
url
):
url
=
'file:'
+
url
url
=
'file:'
+
url
parsed
=
url
lib
.
parse
.
url
parse
(
url
,
'file'
)
parsed
=
urlparse
(
url
,
'file'
)
url_path
=
parsed
[
2
]
url_path
=
parsed
[
2
]
if
parsed
[
0
]
==
'file'
:
if
parsed
[
0
]
==
'file'
:
...
...
src/zc/buildout/download.txt
View file @
3ed7c06b
...
@@ -256,11 +256,11 @@ ChecksumError: MD5 checksum mismatch downloading 'http://localhost/foo.txt'
...
@@ -256,11 +256,11 @@ ChecksumError: MD5 checksum mismatch downloading 'http://localhost/foo.txt'
If the file is completely missing it should notify the user of the error:
If the file is completely missing it should notify the user of the error:
>>> download(server_url+'bar.txt') # doctest: +NORMALIZE_WHITESPACE
>>> download(server_url+'bar.txt') # doctest: +NORMALIZE_WHITESPACE
+ELLIPSIS
Traceback (most recent call last):
Traceback (most recent call last):
...
...
UserError: Error downloading extends for URL http://localhost/bar.txt:
UserError: Error downloading extends for URL http://localhost/bar.txt:
HTTP Error 404: Not Found
...404...
>>> ls(cache)
>>> ls(cache)
Finally, let's see what happens if the download cache to be used doesn't exist
Finally, let's see what happens if the download cache to be used doesn't exist
...
...
src/zc/buildout/easy_install.py
View file @
3ed7c06b
...
@@ -25,7 +25,10 @@ import sys
...
@@ -25,7 +25,10 @@ import sys
# handle -S
# handle -S
def
normpath
(
p
):
def
normpath
(
p
):
return
p
[:
-
1
]
if
p
.
endswith
(
os
.
path
.
sep
)
else
p
if
p
.
endswith
(
os
.
path
.
sep
):
return
p
[:
-
1
]
else
:
return
p
no_site
=
'site'
not
in
sys
.
modules
no_site
=
'site'
not
in
sys
.
modules
if
no_site
:
if
no_site
:
...
@@ -1075,7 +1078,7 @@ def _create_script(contents, dest):
...
@@ -1075,7 +1078,7 @@ def _create_script(contents, dest):
logger
.
info
(
"Generated script %r."
,
script
)
logger
.
info
(
"Generated script %r."
,
script
)
try
:
try
:
os
.
chmod
(
dest
,
0o755
)
os
.
chmod
(
dest
,
493
)
# 0755
except
(
AttributeError
,
os
.
error
):
except
(
AttributeError
,
os
.
error
):
pass
pass
...
@@ -1143,7 +1146,7 @@ def _pyscript(path, dest, rsetup):
...
@@ -1143,7 +1146,7 @@ def _pyscript(path, dest, rsetup):
if
changed
:
if
changed
:
open
(
dest
,
'w'
).
write
(
contents
)
open
(
dest
,
'w'
).
write
(
contents
)
try
:
try
:
os
.
chmod
(
dest
,
0o755
)
os
.
chmod
(
dest
,
493
)
# 0755
except
(
AttributeError
,
os
.
error
):
except
(
AttributeError
,
os
.
error
):
pass
pass
logger
.
info
(
"Generated interpreter %r."
,
script
)
logger
.
info
(
"Generated interpreter %r."
,
script
)
...
...
src/zc/buildout/isolation.txt
View file @
3ed7c06b
...
@@ -42,8 +42,7 @@ This document tests the 3rd option.
...
@@ -42,8 +42,7 @@ This document tests the 3rd option.
... system("%s -S %s init demo" % (sys.executable, bootstrap_py)),
... system("%s -S %s init demo" % (sys.executable, bootstrap_py)),
... end='\n===')
... end='\n===')
... # doctest: +ELLIPSIS
... # doctest: +ELLIPSIS
X...
X...Creating '/sample/buildout.cfg'.
Creating '/sample/buildout.cfg'.
Creating directory '/sample/bin'.
Creating directory '/sample/bin'.
Creating directory '/sample/parts'.
Creating directory '/sample/parts'.
Creating directory '/sample/eggs'.
Creating directory '/sample/eggs'.
...
...
src/zc/buildout/rmtree.py
View file @
3ed7c06b
...
@@ -54,7 +54,7 @@ def rmtree (path):
...
@@ -54,7 +54,7 @@ def rmtree (path):
0
0
"""
"""
def
retry_writeable
(
func
,
path
,
exc
):
def
retry_writeable
(
func
,
path
,
exc
):
os
.
chmod
(
path
,
0o600
)
os
.
chmod
(
path
,
384
)
# 0600
func
(
path
)
func
(
path
)
shutil
.
rmtree
(
path
,
onerror
=
retry_writeable
)
shutil
.
rmtree
(
path
,
onerror
=
retry_writeable
)
...
...
src/zc/buildout/testing.py
View file @
3ed7c06b
...
@@ -14,7 +14,15 @@
...
@@ -14,7 +14,15 @@
"""Various test-support utility functions
"""Various test-support utility functions
"""
"""
import
http.server
try
:
# Python 3
from
http.server
import
HTTPServer
,
BaseHTTPRequestHandler
from
urllib.request
import
urlopen
except
ImportError
:
# Python 2
from
BaseHTTPServer
import
HTTPServer
,
BaseHTTPRequestHandler
from
urllib2
import
urlopen
import
errno
import
errno
import
logging
import
logging
import
os
import
os
...
@@ -28,7 +36,6 @@ import sys
...
@@ -28,7 +36,6 @@ import sys
import
tempfile
import
tempfile
import
threading
import
threading
import
time
import
time
import
urllib.request
,
urllib
.
error
,
urllib
.
parse
import
zc.buildout.buildout
import
zc.buildout.buildout
import
zc.buildout.easy_install
import
zc.buildout.easy_install
...
@@ -106,7 +113,7 @@ def system(command, input=''):
...
@@ -106,7 +113,7 @@ def system(command, input=''):
return
result
.
decode
()
return
result
.
decode
()
def
get
(
url
):
def
get
(
url
):
return
urllib
.
request
.
urlopen
(
url
).
read
().
decode
(
)
return
str
(
urlopen
(
url
).
read
().
decode
()
)
def
_runsetup
(
setup
,
*
args
):
def
_runsetup
(
setup
,
*
args
):
if
os
.
path
.
isdir
(
setup
):
if
os
.
path
.
isdir
(
setup
):
...
@@ -265,10 +272,10 @@ def buildoutTearDown(test):
...
@@ -265,10 +272,10 @@ def buildoutTearDown(test):
for
f
in
test
.
globs
[
'__tear_downs'
]:
for
f
in
test
.
globs
[
'__tear_downs'
]:
f
()
f
()
class
Server
(
http
.
server
.
HTTPServer
):
class
Server
(
HTTPServer
):
def
__init__
(
self
,
tree
,
*
args
):
def
__init__
(
self
,
tree
,
*
args
):
http
.
server
.
HTTPServer
.
__init__
(
self
,
*
args
)
HTTPServer
.
__init__
(
self
,
*
args
)
self
.
tree
=
os
.
path
.
abspath
(
tree
)
self
.
tree
=
os
.
path
.
abspath
(
tree
)
__run
=
True
__run
=
True
...
@@ -279,15 +286,14 @@ class Server(http.server.HTTPServer):
...
@@ -279,15 +286,14 @@ class Server(http.server.HTTPServer):
def
handle_error
(
self
,
*
_
):
def
handle_error
(
self
,
*
_
):
self
.
__run
=
False
self
.
__run
=
False
class
Handler
(
http
.
server
.
BaseHTTPRequestHandler
):
class
Handler
(
BaseHTTPRequestHandler
):
Server
.
__log
=
False
Server
.
__log
=
False
def
__init__
(
self
,
request
,
address
,
server
):
def
__init__
(
self
,
request
,
address
,
server
):
self
.
__server
=
server
self
.
__server
=
server
self
.
tree
=
server
.
tree
self
.
tree
=
server
.
tree
http
.
server
.
BaseHTTPRequestHandler
.
__init__
(
BaseHTTPRequestHandler
.
__init__
(
self
,
request
,
address
,
server
)
self
,
request
,
address
,
server
)
def
do_GET
(
self
):
def
do_GET
(
self
):
if
'__stop__'
in
self
.
path
:
if
'__stop__'
in
self
.
path
:
...
@@ -382,7 +388,7 @@ def start_server(tree):
...
@@ -382,7 +388,7 @@ def start_server(tree):
def
stop_server
(
url
,
thread
=
None
):
def
stop_server
(
url
,
thread
=
None
):
try
:
try
:
url
lib
.
request
.
url
open
(
url
+
'__stop__'
)
urlopen
(
url
+
'__stop__'
)
except
Exception
:
except
Exception
:
pass
pass
if
thread
is
not
None
:
if
thread
is
not
None
:
...
...
src/zc/buildout/tests.py
View file @
3ed7c06b
...
@@ -1077,13 +1077,6 @@ because of the missing target file.
...
@@ -1077,13 +1077,6 @@ because of the missing target file.
>>> write('recipe', 'some-file', '1')
>>> write('recipe', 'some-file', '1')
>>> os.symlink(join('recipe', 'some-file'),
>>> os.symlink(join('recipe', 'some-file'),
... join('recipe', 'another-file'))
... join('recipe', 'another-file'))
>>> ls('recipe')
l another-file
- foo.py
d recipe.egg-info
- setup.py
- some-file
>>> remove('recipe', 'some-file')
>>> remove('recipe', 'some-file')
>>> print_(system(join(sample_buildout, 'bin', 'buildout')), end='')
>>> print_(system(join(sample_buildout, 'bin', 'buildout')), end='')
...
...
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