2016-09-05 14:30:43 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
import platform
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from distutils import sysconfig
|
|
|
|
|
|
|
|
|
|
|
|
def get_python_abiflags():
|
2016-09-14 09:42:54 +00:00
|
|
|
return sysconfig.get_config_var("ABIFLAGS")
|
2016-09-05 14:30:43 +00:00
|
|
|
|
|
|
|
def get_python_libloc():
|
|
|
|
# OSX is a pain. Python as shipped by apple installs libpython in /usr/lib
|
|
|
|
# so we hardcode that. Other systems can use --with-libpython-dir to
|
|
|
|
# override this.
|
|
|
|
if platform.system().lower() == 'darwin':
|
|
|
|
return '/usr/lib'
|
|
|
|
|
2016-09-14 09:42:54 +00:00
|
|
|
pylib_loc = sysconfig.get_config_var("LIBPL")
|
|
|
|
pylib_ldlibrary = sysconfig.get_config_var("LDLIBRARY")
|
2016-09-05 14:30:43 +00:00
|
|
|
|
2016-09-14 13:18:17 +00:00
|
|
|
py_sharedlib = os.path.join(pylib_loc, pylib_ldlibrary)
|
|
|
|
if os.path.exists(py_sharedlib):
|
|
|
|
return pylib_loc
|
|
|
|
|
|
|
|
# Workaround for Fedora
|
|
|
|
pylib_loc = sysconfig.get_config_var("LIBDIR")
|
|
|
|
pylib_ldlibrary = sysconfig.get_config_var("LDLIBRARY")
|
|
|
|
|
2016-09-14 09:42:54 +00:00
|
|
|
py_sharedlib = os.path.join(pylib_loc, pylib_ldlibrary)
|
|
|
|
if os.path.exists(py_sharedlib):
|
2016-09-05 14:30:43 +00:00
|
|
|
return pylib_loc
|
|
|
|
|
|
|
|
return "None"
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2017-03-23 15:09:05 +00:00
|
|
|
if len(sys.argv) > 3:
|
|
|
|
print("At most 2 arguments accepted")
|
2016-09-05 14:30:43 +00:00
|
|
|
exit(1)
|
|
|
|
|
|
|
|
if sys.argv[1] == '--abiflags':
|
|
|
|
print(get_python_abiflags())
|
|
|
|
elif sys.argv[1] == '--sosuffix':
|
|
|
|
get = sysconfig.get_config_var
|
|
|
|
suffix = get("EXT_SUFFIX") or get("SO") or ".so"
|
|
|
|
print(suffix[1:])
|
|
|
|
elif sys.argv[1] == '--pygi-overridedir':
|
2017-03-23 15:09:05 +00:00
|
|
|
prefix = sys.argv[2]
|
|
|
|
version = sys.version_info
|
|
|
|
|
|
|
|
# If we are installing in the same prefix as PyGobject
|
|
|
|
# make sure to install in the right place.
|
2016-09-05 14:30:43 +00:00
|
|
|
import gi
|
2017-03-23 15:09:05 +00:00
|
|
|
if os.path.commonprefix([gi._overridesdir, prefix]) == prefix:
|
|
|
|
print(gi._overridesdir)
|
|
|
|
exit(0)
|
|
|
|
|
|
|
|
# Otherwise follow python's way of install site packages inside
|
|
|
|
# the provided prefix
|
|
|
|
if os.name == 'posix':
|
|
|
|
print(os.path.join(
|
|
|
|
prefix, 'lib', 'python%d.%d' % (version.major, version.minor),
|
|
|
|
'site-packages', 'gi', 'overrides'))
|
|
|
|
else:
|
|
|
|
print(os.path.join(
|
|
|
|
prefix, 'Lib', 'Python%d%d' % (version.major, version.minor),
|
|
|
|
'site-packages', 'gi', 'overrides'))
|
2016-09-05 14:30:43 +00:00
|
|
|
elif sys.argv[1] == '--libloc':
|
|
|
|
print(get_python_libloc())
|