Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Update whl.py and tools to expand purelib,platlib #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions 28 rules_python/whl.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import os
import pkg_resources
import re
import shutil
import zipfile


Expand Down Expand Up @@ -53,6 +54,12 @@ def _dist_info(self):
# e.g. google_cloud-0.27.0-py2.py3-none-any.whl ->
# google_cloud-0.27.0.dist-info
return '{}-{}.dist-info'.format(self.distribution(), self.version())

def _data(self):
# Return the name of the data directory within the .whl file.
# e.g. google_cloud-0.27.0-py2.py3-none-any.whl ->
# google_cloud-0.27.0.data
return '{}-{}.data'.format(self.distribution(), self.version())

def metadata(self):
# Extract the structured data from metadata.json in the WHL's dist-info
Expand Down Expand Up @@ -105,6 +112,27 @@ def expand(self, directory):
with zipfile.ZipFile(self.path(), 'r') as whl:
whl.extractall(directory)

### PURELIB HACK START
# Find any lib directories, and move them to the top level.
try:
data_contents = os.listdir(self._data())
except:
data_contents = []

# TODO: This is probably wrong. These have different targets, and probably both need to be
# installed.
if 'purelib' in data_contents:
source = os.path.join(self._data(), 'purelib')
elif 'platlib' in data_contents:
source = os.path.join(self._data(), 'platlib')
else:
source = None

if source:
for f in os.listdir(source):
shutil.move(os.path.join(source, f), directory)
### PURELIB HACK END

# _parse_metadata parses METADATA files according to https://www.python.org/dev/peps/pep-0314/
def _parse_metadata(self, content):
# TODO: handle fields other than just name
Expand Down
Binary file modified BIN +1.89 KB (100%) tools/piptool.par
Binary file not shown.
Binary file modified BIN +2.79 KB (100%) tools/whltool.par
Binary file not shown.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.