-
Notifications
You must be signed in to change notification settings - Fork 724
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround for distutils bug in Ubuntu/Debian's Python3 versions
- Loading branch information
1 parent
74d4d40
commit f2095f8
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import sys | ||
import sysconfig | ||
import site | ||
|
||
if __name__ == '__main__': | ||
# This is a hack due to the distutils in debian/ubuntu's python3 being misconfigured | ||
# see discussion https://github.com/opencog/atomspace/issues/1782 | ||
# | ||
# If the bug is fixed, this script could be replaced by: | ||
# | ||
# from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True, prefix=prefix)) | ||
# | ||
# However, using this would not respect a python virtual environments, so in a way this is better! | ||
|
||
prefix = sys.argv[1] | ||
|
||
# use sites if the prefix is recognized and the sites module is available | ||
# (virtualenv is missing getsitepackages()) | ||
if hasattr(site, 'getsitepackages'): | ||
paths = [p for p in site.getsitepackages() if p.startswith(prefix)] | ||
if len(paths) == 1: | ||
print(paths[0]) | ||
exit(0) | ||
|
||
# use sysconfig platlib as the fall back | ||
print(sysconfig.get_paths()['platlib']) |