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
f31130ae
Commit
f31130ae
authored
Oct 14, 2015
by
Reinout van Rees
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #24. Distutils scripts in dev eggs are detected now
parent
e57e1ff8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
3 deletions
+52
-3
src/zc/buildout/easy_install.py
src/zc/buildout/easy_install.py
+52
-3
No files found.
src/zc/buildout/easy_install.py
View file @
f31130ae
...
...
@@ -86,6 +86,7 @@ buildout_and_setuptools_path = [
]
FILE_SCHEME
=
re
.
compile
(
'file://'
,
re
.
I
).
match
DUNDER_FILE_PATTERN
=
re
.
compile
(
r"__file__ = '(?P<filename>.+)'$"
)
class
_Monkey
(
object
):
def
__init__
(
self
,
module
,
**
kw
):
...
...
@@ -859,7 +860,6 @@ def build(spec, dest, build_ext,
return
installer
.
build
(
spec
,
build_ext
)
def
_rm
(
*
paths
):
for
path
in
paths
:
if
os
.
path
.
isdir
(
path
):
...
...
@@ -867,6 +867,7 @@ def _rm(*paths):
elif
os
.
path
.
exists
(
path
):
os
.
remove
(
path
)
def
_copyeggs
(
src
,
dest
,
suffix
,
undo
):
result
=
[]
undo
.
append
(
lambda
:
_rm
(
*
result
))
...
...
@@ -882,6 +883,45 @@ def _copyeggs(src, dest, suffix, undo):
return
result
[
0
]
_develop_distutils_scripts
=
{}
def
_detect_distutils_scripts
(
directory
):
"""Record detected distutils scripts from develop eggs
``setup.py develop`` doesn't generate metadata on distutils scripts, in
contrast to ``setup.py install``. So we have to store the information for
later.
"""
dir_contents
=
os
.
listdir
(
directory
)
egginfo_filenames
=
[
filename
for
filename
in
dir_contents
if
filename
.
endswith
(
'.egg-link'
)]
if
not
egginfo_filenames
:
return
egg_name
=
egginfo_filenames
[
0
].
replace
(
'.egg-link'
,
''
)
marker
=
'EASY-INSTALL-DEV-SCRIPT'
scripts_found
=
[]
for
filename
in
dir_contents
:
dev_script_content
=
open
(
os
.
path
.
join
(
directory
,
filename
)).
read
()
if
marker
in
dev_script_content
:
# The distutils bin script points at the actual file we need.
for
line
in
dev_script_content
.
splitlines
():
match
=
DUNDER_FILE_PATTERN
.
search
(
line
)
if
match
:
actual_script_filename
=
match
.
group
(
'filename'
)
actual_script_content
=
open
(
actual_script_filename
).
read
()
scripts_found
.
append
([
filename
,
actual_script_content
])
if
scripts_found
:
logger
.
debug
(
"Distutils scripts found for develop egg %s: %s"
,
egg_name
,
scripts_found
)
_develop_distutils_scripts
[
egg_name
]
=
scripts_found
def
develop
(
setup
,
dest
,
build_ext
=
None
,
executable
=
sys
.
executable
):
...
...
@@ -924,7 +964,7 @@ def develop(setup, dest,
tmp3
=
tempfile
.
mkdtemp
(
'build'
,
dir
=
dest
)
undo
.
append
(
lambda
:
shutil
.
rmtree
(
tmp3
))
args
=
[
executable
,
tsetup
,
'-q'
,
'develop'
,
'-m
x
N'
,
'-d'
,
tmp3
]
args
=
[
executable
,
tsetup
,
'-q'
,
'develop'
,
'-mN'
,
'-d'
,
tmp3
]
log_level
=
logger
.
getEffectiveLevel
()
if
log_level
<=
0
:
...
...
@@ -936,7 +976,7 @@ def develop(setup, dest,
logger
.
debug
(
"in: %r
\
n
%s"
,
directory
,
' '
.
join
(
args
))
call_subprocess
(
args
)
_detect_distutils_scripts
(
tmp3
)
return
_copyeggs
(
tmp3
,
dest
,
'.egg-link'
,
undo
)
finally
:
...
...
@@ -957,6 +997,7 @@ def working_set(specs, executable, path=None,
return
install
(
specs
,
None
,
path
=
path
)
def
scripts
(
reqs
,
working_set
,
executable
,
dest
=
None
,
scripts
=
None
,
extra_paths
=
(),
...
...
@@ -1002,12 +1043,20 @@ def scripts(reqs, working_set, executable, dest=None,
# distutils/setuptools, except by placing the original scripts in
# /EGG-INFO/scripts/.
if
dist
.
metadata_isdir
(
'scripts'
):
# egg-info metadata from installed egg.
for
name
in
dist
.
metadata_listdir
(
'scripts'
):
if
dist
.
metadata_isdir
(
'scripts/'
+
name
):
# Probably Python 3 __pycache__ directory.
continue
contents
=
dist
.
get_metadata
(
'scripts/'
+
name
)
distutils_scripts
.
append
((
name
,
contents
))
elif
dist
.
key
in
_develop_distutils_scripts
:
# Development eggs don't have metadata about scripts, so we
# collected it ourselves in develop()/ and
# _detect_distutils_scripts().
for
name
,
contents
in
_develop_distutils_scripts
[
dist
.
key
]:
distutils_scripts
.
append
((
name
,
contents
))
else
:
entry_points
.
append
(
req
)
...
...
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