Commit f85a2848 authored by Reinout van Rees's avatar Reinout van Rees

Removed need for tempfile

parent 3ee1ab2c
...@@ -948,18 +948,18 @@ def scripts(reqs, working_set, executable, dest, ...@@ -948,18 +948,18 @@ def scripts(reqs, working_set, executable, dest,
scripts_dir = os.path.join(dist.location, 'EGG-INFO', 'scripts') scripts_dir = os.path.join(dist.location, 'EGG-INFO', 'scripts')
if os.path.exists(scripts_dir): if os.path.exists(scripts_dir):
for name in os.listdir(scripts_dir): for name in os.listdir(scripts_dir):
contents = open(os.path.join(scripts_dir, name)
).read()
distutils_scripts.append( distutils_scripts.append(
(name, os.path.join(scripts_dir, name))) (name, contents))
else: else:
# Zipped egg: use zipfile to detect possible scripts. # Zipped egg: use zipfile to detect possible scripts.
zipped = zipfile.ZipFile(dist.location) zipped = zipfile.ZipFile(dist.location)
for filepath in zipped.namelist(): for filepath in zipped.namelist():
if filepath.startswith('EGG-INFO/scripts'): if filepath.startswith('EGG-INFO/scripts'):
name = os.path.basename(filepath) name = os.path.basename(filepath)
fd, tmp_script = tempfile.mkstemp() contents = zipped.read(filepath)
os.write(fd, zipped.read(filepath)) distutils_scripts.append((name, contents))
os.close(fd)
distutils_scripts.append((name, tmp_script))
else: else:
entry_points.append(req) entry_points.append(req)
...@@ -979,7 +979,7 @@ def scripts(reqs, working_set, executable, dest, ...@@ -979,7 +979,7 @@ def scripts(reqs, working_set, executable, dest,
initialization, rpsetup) initialization, rpsetup)
) )
for name, full_script_path in distutils_scripts: for name, contents in distutils_scripts:
if scripts is not None: if scripts is not None:
sname = scripts.get(name) sname = scripts.get(name)
if sname is None: if sname is None:
...@@ -991,7 +991,7 @@ def scripts(reqs, working_set, executable, dest, ...@@ -991,7 +991,7 @@ def scripts(reqs, working_set, executable, dest,
spath, rpsetup = _relative_path_and_setup(sname, path, relative_paths) spath, rpsetup = _relative_path_and_setup(sname, path, relative_paths)
generated.extend( generated.extend(
_distutils_script(spath, sname, full_script_path, _distutils_script(spath, sname, contents,
executable, initialization, rpsetup) executable, initialization, rpsetup)
) )
...@@ -1081,9 +1081,10 @@ def _script(module_name, attrs, path, dest, executable, arguments, ...@@ -1081,9 +1081,10 @@ def _script(module_name, attrs, path, dest, executable, arguments,
return _create_script(contents, dest) return _create_script(contents, dest)
def _distutils_script(path, dest, original_file, executable, initialization, rsetup): def _distutils_script(path, dest, script_content, executable,
initialization, rsetup):
lines = open(original_file).readlines() lines = script_content.splitlines(True)
if not ('#!' in lines[0]) and ('python' in lines[0]): if not ('#!' in lines[0]) and ('python' in lines[0]):
# The script doesn't follow distutil's rules. Ignore it. # The script doesn't follow distutil's rules. Ignore it.
return [] return []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment