File: get_python_lib.py

package info (click to toggle)
soapysdr 0.8.1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 948 kB
  • sloc: cpp: 5,378; ansic: 471; python: 311; sh: 21; makefile: 18
file content (19 lines) | stat: -rw-r--r-- 565 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import os
import sys
import site
from sysconfig import get_path

if __name__ == '__main__':
    prefix = sys.argv[1]

    #ask sysconfig where to install the python module
    install_dir = get_path('platlib', 'posix_user', {'userbase': prefix})

    #use sites when the prefix is already recognized
    try:
        paths = [p for p in site.getsitepackages() if p.startswith(prefix)]
        if len(paths) == 1: install_dir = paths[0]
    except AttributeError: pass

    #strip the prefix to return a relative path
    print(os.path.relpath(install_dir, prefix))