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 220c113

Browse filesBrowse files
committed
Add a hack to install purelib files.
1 parent c384f1c commit 220c113
Copy full SHA for 220c113

File tree

Expand file treeCollapse file tree

3 files changed

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

3 files changed

+26
-0
lines changed

‎rules_python/whl.py

Copy file name to clipboardExpand all lines: rules_python/whl.py
+26Lines changed: 26 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

@@ -54,6 +55,12 @@ def _dist_info(self):
5455
# google_cloud-0.27.0.dist-info
5556
return '{}-{}.dist-info'.format(self.distribution(), self.version())
5657

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())
63+
5764
def metadata(self):
5865
# Extract the structured data from metadata.json in the WHL's dist-info
5966
# directory.
@@ -105,6 +112,25 @@ def expand(self, directory):
105112
with zipfile.ZipFile(self.path(), 'r') as whl:
106113
whl.extractall(directory)
107114

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

‎tools/piptool.par

Copy file name to clipboard
861 Bytes
Binary file not shown.

‎tools/whltool.par

Copy file name to clipboard
1.68 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.