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
Łukasz Nowak
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
Show 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
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
tmpeggs
=
tempfile
.
mkdtemp
()
...
...
@@ -80,9 +80,13 @@ try:
raise
ImportError
except
ImportError
:
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
)
setup_args
=
dict
(
to_dir
=
tmpeggs
,
download_delay
=
0
,
no_fake
=
True
)
ez
[
'use_setuptools'
](
**
setup_args
)
...
...
dev.py
View file @
3ed7c06b
...
...
@@ -17,7 +17,7 @@ This is different from a normal boostrapping process because the
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'
:
if
not
os
.
path
.
exists
(
d
):
...
...
@@ -49,16 +49,24 @@ try:
except
ImportError
:
pass
else
:
raise
SystemError
(
message
=
(
"Buildout development with a pre-installed setuptools or "
"distribute is not supported.%s"
%
(
''
if
nosite
else
' Try running with -S option to Python.'
))
"distribute is not supported."
)
if
not
nosite
:
message
+=
' Try running with -S option to Python.'
raise
SystemError
(
message
)
######################################################################
# Install distribute
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
)
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::
... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
... 'bootstrap.py --version 2.0.0')); print_('X')
... # doctest: +ELLIPSIS
X
...
Generated script '/sample/bin/buildout'.
...
X
X...Generated script '/sample/bin/buildout'...X
Let's make sure the generated `buildout` script uses it::
...
...
src/zc/buildout/buildout.py
View file @
3ed7c06b
...
...
@@ -18,7 +18,7 @@
import
zc.buildout.easy_install
no_site
=
zc
.
buildout
.
easy_install
.
no_site
from
.rmtree
import
rmtree
from
zc.buildout
.rmtree
import
rmtree
from
hashlib
import
md5
try
:
...
...
src/zc/buildout/download.py
View file @
3ed7c06b
...
...
@@ -17,6 +17,24 @@ try:
from
hashlib
import
md5
except
ImportError
:
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
import
logging
import
os
...
...
@@ -25,22 +43,11 @@ import re
import
shutil
import
sys
import
tempfile
import
urllib.request
,
urllib
.
parse
,
urllib
.
error
import
urllib.parse
import
zc.buildout
class
URLOpener
(
urllib
.
request
.
FancyURLopener
):
http_error_default
=
urllib
.
request
.
URLopener
.
http_error_default
class
ChecksumError
(
zc
.
buildout
.
UserError
):
pass
url_opener
=
URLOpener
()
class
Download
(
object
):
"""Configurable download utility.
...
...
@@ -158,7 +165,7 @@ class Download(object):
if
re
.
match
(
r"^[A-Za-z]:\\"
,
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
]
if
url_scheme
==
'file'
:
self
.
logger
.
debug
(
'Using local resource %s'
%
url
)
...
...
@@ -173,10 +180,9 @@ class Download(object):
"Couldn't download %r in offline mode."
%
url
)
self
.
logger
.
info
(
'Downloading %s'
%
url
)
urllib
.
request
.
_urlopener
=
url_opener
handle
,
tmp_path
=
tempfile
.
mkstemp
(
prefix
=
'buildout-'
)
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
):
raise
ChecksumError
(
'MD5 checksum mismatch downloading %r'
%
url
)
...
...
@@ -206,7 +212,7 @@ class Download(object):
else
:
if
re
.
match
(
r"^[A-Za-z]:\\"
,
url
):
url
=
'file:'
+
url
parsed
=
url
lib
.
parse
.
url
parse
(
url
,
'file'
)
parsed
=
urlparse
(
url
,
'file'
)
url_path
=
parsed
[
2
]
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'
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):
...
UserError: Error downloading extends for URL http://localhost/bar.txt:
HTTP Error 404: Not Found
...404...
>>> ls(cache)
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
# handle -S
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
if
no_site
:
...
...
@@ -1075,7 +1078,7 @@ def _create_script(contents, dest):
logger
.
info
(
"Generated script %r."
,
script
)
try
:
os
.
chmod
(
dest
,
0o755
)
os
.
chmod
(
dest
,
493
)
# 0755
except
(
AttributeError
,
os
.
error
):
pass
...
...
@@ -1143,7 +1146,7 @@ def _pyscript(path, dest, rsetup):
if
changed
:
open
(
dest
,
'w'
).
write
(
contents
)
try
:
os
.
chmod
(
dest
,
0o755
)
os
.
chmod
(
dest
,
493
)
# 0755
except
(
AttributeError
,
os
.
error
):
pass
logger
.
info
(
"Generated interpreter %r."
,
script
)
...
...
src/zc/buildout/isolation.txt
View file @
3ed7c06b
...
...
@@ -42,8 +42,7 @@ This document tests the 3rd option.
... system("%s -S %s init demo" % (sys.executable, bootstrap_py)),
... end='\n===')
... # doctest: +ELLIPSIS
X...
Creating '/sample/buildout.cfg'.
X...Creating '/sample/buildout.cfg'.
Creating directory '/sample/bin'.
Creating directory '/sample/parts'.
Creating directory '/sample/eggs'.
...
...
src/zc/buildout/rmtree.py
View file @
3ed7c06b
...
...
@@ -54,7 +54,7 @@ def rmtree (path):
0
"""
def
retry_writeable
(
func
,
path
,
exc
):
os
.
chmod
(
path
,
0o600
)
os
.
chmod
(
path
,
384
)
# 0600
func
(
path
)
shutil
.
rmtree
(
path
,
onerror
=
retry_writeable
)
...
...
src/zc/buildout/testing.py
View file @
3ed7c06b
...
...
@@ -14,7 +14,15 @@
"""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
logging
import
os
...
...
@@ -28,7 +36,6 @@ import sys
import
tempfile
import
threading
import
time
import
urllib.request
,
urllib
.
error
,
urllib
.
parse
import
zc.buildout.buildout
import
zc.buildout.easy_install
...
...
@@ -106,7 +113,7 @@ def system(command, input=''):
return
result
.
decode
()
def
get
(
url
):
return
urllib
.
request
.
urlopen
(
url
).
read
().
decode
(
)
return
str
(
urlopen
(
url
).
read
().
decode
()
)
def
_runsetup
(
setup
,
*
args
):
if
os
.
path
.
isdir
(
setup
):
...
...
@@ -265,10 +272,10 @@ def buildoutTearDown(test):
for
f
in
test
.
globs
[
'__tear_downs'
]:
f
()
class
Server
(
http
.
server
.
HTTPServer
):
class
Server
(
HTTPServer
):
def
__init__
(
self
,
tree
,
*
args
):
http
.
server
.
HTTPServer
.
__init__
(
self
,
*
args
)
HTTPServer
.
__init__
(
self
,
*
args
)
self
.
tree
=
os
.
path
.
abspath
(
tree
)
__run
=
True
...
...
@@ -279,15 +286,14 @@ class Server(http.server.HTTPServer):
def
handle_error
(
self
,
*
_
):
self
.
__run
=
False
class
Handler
(
http
.
server
.
BaseHTTPRequestHandler
):
class
Handler
(
BaseHTTPRequestHandler
):
Server
.
__log
=
False
def
__init__
(
self
,
request
,
address
,
server
):
self
.
__server
=
server
self
.
tree
=
server
.
tree
http
.
server
.
BaseHTTPRequestHandler
.
__init__
(
self
,
request
,
address
,
server
)
BaseHTTPRequestHandler
.
__init__
(
self
,
request
,
address
,
server
)
def
do_GET
(
self
):
if
'__stop__'
in
self
.
path
:
...
...
@@ -382,7 +388,7 @@ def start_server(tree):
def
stop_server
(
url
,
thread
=
None
):
try
:
url
lib
.
request
.
url
open
(
url
+
'__stop__'
)
urlopen
(
url
+
'__stop__'
)
except
Exception
:
pass
if
thread
is
not
None
:
...
...
src/zc/buildout/tests.py
View file @
3ed7c06b
...
...
@@ -1077,13 +1077,6 @@ because of the missing target file.
>>> write('recipe', 'some-file', '1')
>>> os.symlink(join('recipe', 'some-file'),
... join('recipe', 'another-file'))
>>> ls('recipe')
l another-file
- foo.py
d recipe.egg-info
- setup.py
- some-file
>>> remove('recipe', 'some-file')
>>> 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