diff options
author | Daniel Holth <dholth@fastmail.fm> | 2014-11-12 21:19:24 -0500 |
---|---|---|
committer | Daniel Holth <dholth@fastmail.fm> | 2014-11-12 21:19:24 -0500 |
commit | 24b677c62834c46e960ec257ba1f607c37c698fd (patch) | |
tree | 44bf5b285d59907b4802bb3dfc0d8897182383e6 | |
parent | d52f690f8afa7063695f613b38a23f5efc1e04b4 (diff) | |
download | wheel-24b677c62834c46e960ec257ba1f607c37c698fd.tar.gz |
backout 366:e2a46b67c89a
-rw-r--r-- | CHANGES.txt | 6 | ||||
-rw-r--r-- | wheel/install.py | 37 | ||||
-rw-r--r-- | wheel/test/test_install.py | 21 |
3 files changed, 23 insertions, 41 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index e6beb32..26754c9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,9 +1,3 @@ -In next release ... - -- When force is given, write to temporary file and rename. This is - necessary because when a file exists, it may already be in use by a - running process. - 0.24.0 ====== - The python tag used for pure-python packages is now .pyN (major version diff --git a/wheel/install.py b/wheel/install.py index 768fec4..3af6d0c 100644 --- a/wheel/install.py +++ b/wheel/install.py @@ -335,36 +335,25 @@ class WheelFile(object): record_name = self.distinfo_name + '/RECORD' for info, (key, target, filename, dest) in name_trans.items(): name = info.filename + source = self.zipfile.open(info) + # Skip the RECORD file + if name == record_name: + continue ddir = os.path.dirname(dest) if not os.path.isdir(ddir): os.makedirs(ddir) - - if force: - dest = "{0}.tmp".format(dest) - - with self.zipfile.open(info) as source, open(dest, 'wb') as f: - destination = HashingFile(f) - - # Skip the RECORD file - if name == record_name: - continue - - if key == 'scripts': - hashbang = source.readline() - if hashbang.startswith(b'#!python'): - hashbang = b'#!' + exename + binary(os.linesep) - destination.write(hashbang) - shutil.copyfileobj(source, destination) - - if force: - tmp = dest - dest = dest[:-4] - os.rename(tmp, dest) - + destination = HashingFile(open(dest, 'wb')) + if key == 'scripts': + hashbang = source.readline() + if hashbang.startswith(b'#!python'): + hashbang = b'#!' + exename + binary(os.linesep) + destination.write(hashbang) + shutil.copyfileobj(source, destination) reldest = os.path.relpath(dest, root) reldest.replace(os.sep, '/') record_data.append((reldest, destination.digest(), destination.length)) - + destination.close() + source.close() # preserve attributes (especially +x bit for scripts) attrs = info.external_attr >> 16 if attrs: # tends to be 0 if Windows. diff --git a/wheel/test/test_install.py b/wheel/test/test_install.py index ff76c18..ddcddf5 100644 --- a/wheel/test/test_install.py +++ b/wheel/test/test_install.py @@ -36,16 +36,15 @@ def test_install(): for key in ('purelib', 'platlib', 'scripts', 'headers', 'data'):
locs[key] = os.path.join(tempdir, key)
os.mkdir(locs[key])
- for force in (False, True):
- whl.install(force=force, overrides=locs)
- assert len(os.listdir(locs['purelib'])) == 0
- assert check(locs['platlib'], 'hello.pyd')
- assert check(locs['platlib'], 'hello', 'hello.py')
- assert check(locs['platlib'], 'hello', '__init__.py')
- assert check(locs['data'], 'hello.dat')
- assert check(locs['headers'], 'hello.dat')
- assert check(locs['scripts'], 'hello.sh')
- assert check(locs['platlib'], 'test-1.0.dist-info', 'RECORD')
+ whl.install(overrides=locs)
+ assert len(os.listdir(locs['purelib'])) == 0
+ assert check(locs['platlib'], 'hello.pyd')
+ assert check(locs['platlib'], 'hello', 'hello.py')
+ assert check(locs['platlib'], 'hello', '__init__.py')
+ assert check(locs['data'], 'hello.dat')
+ assert check(locs['headers'], 'hello.dat')
+ assert check(locs['scripts'], 'hello.sh')
+ assert check(locs['platlib'], 'test-1.0.dist-info', 'RECORD')
finally:
shutil.rmtree(tempdir)
@@ -53,4 +52,4 @@ def test_install_tool(): """Slightly improve coverage of wheel.install"""
wheel.tool.install([TESTWHEEL], force=True, dry_run=True)
-
+
\ No newline at end of file |