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

Commit d5320dd

Browse filesBrowse files
author
Andrew Giel
authored
Merge pull request #1 from ubiquity6/andrew/purelib-hack
Update whl.py and tools to expand purelib,platlib
2 parents 3886b1a + a9858a4 commit d5320dd
Copy full SHA for d5320dd

File tree

Expand file treeCollapse file tree

3 files changed

+28
-0
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+28
-0
lines changed

‎rules_python/whl.py

Copy file name to clipboardExpand all lines: rules_python/whl.py
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import os
1919
import pkg_resources
2020
import re
21+
import shutil
2122
import zipfile
2223

2324

@@ -53,6 +54,12 @@ def _dist_info(self):
5354
# e.g. google_cloud-0.27.0-py2.py3-none-any.whl ->
5455
# google_cloud-0.27.0.dist-info
5556
return '{}-{}.dist-info'.format(self.distribution(), self.version())
57+
58+
def _data(self):
59+
# Return the name of the data directory within the .whl file.
60+
# e.g. google_cloud-0.27.0-py2.py3-none-any.whl ->
61+
# google_cloud-0.27.0.data
62+
return '{}-{}.data'.format(self.distribution(), self.version())
5663

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

115+
### PURELIB HACK START
116+
# Find any lib directories, and move them to the top level.
117+
try:
118+
data_contents = os.listdir(self._data())
119+
except:
120+
data_contents = []
121+
122+
# TODO: This is probably wrong. These have different targets, and probably both need to be
123+
# installed.
124+
if 'purelib' in data_contents:
125+
source = os.path.join(self._data(), 'purelib')
126+
elif 'platlib' in data_contents:
127+
source = os.path.join(self._data(), 'platlib')
128+
else:
129+
source = None
130+
131+
if source:
132+
for f in os.listdir(source):
133+
shutil.move(os.path.join(source, f), directory)
134+
### PURELIB HACK END
135+
108136
# _parse_metadata parses METADATA files according to https://www.python.org/dev/peps/pep-0314/
109137
def _parse_metadata(self, content):
110138
# TODO: handle fields other than just name

‎tools/piptool.par

Copy file name to clipboard
1.89 KB
Binary file not shown.

‎tools/whltool.par

Copy file name to clipboard
2.79 KB
Binary file not shown.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.