[Checkins] SVN: zc.buildout/branches/reinout-scripts/src/zc/buildout/easy_install.py Removed need for tempfile
Reinout van Rees
reinout at vanrees.org
Fri Sep 4 17:27:31 EDT 2009
Log message for revision 103558:
Removed need for tempfile
Changed:
U zc.buildout/branches/reinout-scripts/src/zc/buildout/easy_install.py
-=-
Modified: zc.buildout/branches/reinout-scripts/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/branches/reinout-scripts/src/zc/buildout/easy_install.py 2009-09-04 20:58:48 UTC (rev 103557)
+++ zc.buildout/branches/reinout-scripts/src/zc/buildout/easy_install.py 2009-09-04 21:27:30 UTC (rev 103558)
@@ -948,18 +948,18 @@
scripts_dir = os.path.join(dist.location, 'EGG-INFO', 'scripts')
if os.path.exists(scripts_dir):
for name in os.listdir(scripts_dir):
+ contents = open(os.path.join(scripts_dir, name)
+ ).read()
distutils_scripts.append(
- (name, os.path.join(scripts_dir, name)))
+ (name, contents))
else:
# Zipped egg: use zipfile to detect possible scripts.
zipped = zipfile.ZipFile(dist.location)
for filepath in zipped.namelist():
if filepath.startswith('EGG-INFO/scripts'):
name = os.path.basename(filepath)
- fd, tmp_script = tempfile.mkstemp()
- os.write(fd, zipped.read(filepath))
- os.close(fd)
- distutils_scripts.append((name, tmp_script))
+ contents = zipped.read(filepath)
+ distutils_scripts.append((name, contents))
else:
entry_points.append(req)
@@ -979,7 +979,7 @@
initialization, rpsetup)
)
- for name, full_script_path in distutils_scripts:
+ for name, contents in distutils_scripts:
if scripts is not None:
sname = scripts.get(name)
if sname is None:
@@ -991,7 +991,7 @@
spath, rpsetup = _relative_path_and_setup(sname, path, relative_paths)
generated.extend(
- _distutils_script(spath, sname, full_script_path,
+ _distutils_script(spath, sname, contents,
executable, initialization, rpsetup)
)
@@ -1081,9 +1081,10 @@
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]):
# The script doesn't follow distutil's rules. Ignore it.
return []
More information about the checkins
mailing list