Created
April 3, 2019 12:37
-
-
Save corneliouzbett/12fb4b2f92a9fc8fc3d136926fe97d77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def shared_locations(self): | |
""" | |
A dictionary of shared locations whose keys are in the set 'prefix', | |
'purelib', 'platlib', 'scripts', 'headers', 'data' and 'namespace'. | |
The corresponding value is the absolute path of that category for | |
this distribution, and takes into account any paths selected by the | |
user at installation time (e.g. via command-line arguments). In the | |
case of the 'namespace' key, this would be a list of absolute paths | |
for the roots of namespace packages in this distribution. | |
The first time this property is accessed, the relevant information is | |
read from the SHARED file in the .dist-info directory. | |
""" | |
result = {} | |
shared_path = os.path.join(self.path, 'SHARED') | |
if os.path.isfile(shared_path): | |
with codecs.open(shared_path, 'r', encoding='utf-8') as f: | |
lines = f.read().splitlines() | |
for line in lines: | |
key, value = line.split('=', 1) | |
if key == 'namespace': | |
result.setdefault(key, []).append(value) | |
else: | |
result[key] = value | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment