Skip to content

Commit

Permalink
Merge pull request #172 from takluyver/wheels-data-lib
Browse files Browse the repository at this point in the history
Merge library files from wheels data directory
  • Loading branch information
takluyver committed Nov 26, 2018
2 parents 4bf55cb + 58695bb commit 60d487b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions nsist/tests/test_local_wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,19 @@ def test_extract_exclude_folder(tmpdir):

assert_isfile(str(pkgs / 'foo' / 'bar.txt'))
assert_not_path_exists(str(pkgs / 'foo' / 'bar'))

def test_extract_data_lib_sitepkg(tmpdir):
whl_file = str(tmpdir / 'foo.whl')
pkgs = tmpdir.mkdir('pkgs')

with ZipFile(whl_file, 'w') as zf:
zf.writestr('osgeo/bar.txt', b'blah')
# The case of 'Lib/site-packages' shouldn't matter
zf.writestr('foo-1.0.data/data/Lib/siTE-packages/osgeo/abc.txt', b'a')
zf.writestr('foo-1.0.data/data/lib/site-packages/osgeo/def.txt', b'd')

extract_wheel(whl_file, str(pkgs), exclude=['pkgs/foo/bar'])

assert_isfile(str(pkgs / 'osgeo' / 'bar.txt'))
assert_isfile(str(pkgs / 'osgeo' / 'abc.txt'))
assert_isfile(str(pkgs / 'osgeo' / 'def.txt'))
15 changes: 15 additions & 0 deletions nsist/wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,21 @@ def extract_wheel(whl_file, target_dir, exclude=None):
if (p / 'platlib').is_dir():
merge_dir_to(p / 'platlib', td)

# HACK: Some wheels from Christoph Gohlke's page have extra package
# files added in data/Lib/site-packages. This is a trick that relies
# on the default installation layout. It doesn't look like it will
# change, so in the best tradition of packaging, we'll work around
# the workaround.
# https://github.com/takluyver/pynsist/issues/171
# This is especially ugly because we do a case-insensitive match,
# regardless of the filesystem.
if (p / 'data').is_dir():
for sd in (p / 'data').iterdir():
if sd.name.lower() == 'lib' and sd.is_dir():
for sd2 in sd.iterdir():
if sd2.name.lower() == 'site-packages' and sd2.is_dir():
merge_dir_to(sd2, td)

# Copy to target directory
target = Path(target_dir)
copied_something = False
Expand Down

0 comments on commit 60d487b

Please sign in to comment.