-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_pyside_pth.py
35 lines (29 loc) · 1.06 KB
/
install_pyside_pth.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import sys
import os
from site import check_enableusersite
from pathlib import Path
# Handle both normal environments and virtualenvs
try:
from site import getusersitepackages, getsitepackages
except ImportError:
from sysconfig import get_path
getsitepackages = lambda: get_path('purelib')
getusersitepackages = getsitepackages
base_dir = Path(__file__).resolve().parent
target_path = base_dir / "pyside" / "site-packages"
if (os.path.isdir(target_path)):
print("Found install folder of {}".format(target_path))
else:
print("Failed to find pyside installation expected at {}".format(target_path))
sys.exit(1)
if check_enableusersite():
install_path = getusersitepackages()
if not os.path.exists(install_path):
os.makedirs(install_path)
else:
print("Warning, trying to write to user site packages, but check_enableusersite fails.")
sys.exit(1)
pyside_pth_path = os.path.join(install_path, f'pyside6.pth')
with open(pyside_pth_path, 'wb') as pth_file:
pth_file.write((str(target_path) + "\n").encode('charmap'))
print("PySide installed using {}".format(pyside_pth_path))