-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
51 lines (42 loc) · 1.32 KB
/
setup.py
File metadata and controls
51 lines (42 loc) · 1.32 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from setuptools import setup
from setuptools.command.develop import develop
from setuptools.command.install import install
import subprocess
import os
import sys
def run_welcome_script():
"""Run src/installer/welcome.py.
This is called at the top level to ensure it runs during the
metadata generation phase of `pip install`.
"""
# Prevent running multiple times in the same session (pip often calls setup.py twice)
if os.environ.get('XMEM_INSTALL_RUNNING') == '1':
return
os.environ['XMEM_INSTALL_RUNNING'] = '1'
installer_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "src", "installer")
welcome_file = os.path.join(installer_dir, "welcome.py")
if not os.path.exists(welcome_file):
return
try:
# Use stdout directly to bypass some pip output capturing
subprocess.run(
[sys.executable, welcome_file],
check=False,
timeout=20,
)
except Exception:
pass
# Run it immediately when setup.py is loaded
run_welcome_script()
class PostDevelopCommand(develop):
def run(self):
develop.run(self)
class PostInstallCommand(install):
def run(self):
install.run(self)
setup(
cmdclass={
"develop": PostDevelopCommand,
"install": PostInstallCommand,
},
)