forked from hypothesis/h
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run
executable file
·47 lines (41 loc) · 1.75 KB
/
run
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
#!/usr/bin/env python
from distutils.core import run_setup
from os import environ
from os.path import abspath, dirname, exists, join
import sys
VIRTUAL_ENV_WARNING = """
Please be sure to deactivate the python virtual environment and run this script
again.
The offending virtual environment is '%s'.
"""
if __name__ == '__main__':
# Make sure a virtual environment is not active.
if 'VIRTUAL_ENV' in environ:
print VIRTUAL_ENV_WARNING % environ['VIRTUAL_ENV']
exit(1)
# Activate the virtual environment if it is present.
# While this may seem to contradict the check above, the python activation
# does a better job than the shell script at prioritizing the virtual site
# packages. Activating with the shell script can lead to issues with
# system-wide modules in namespace packages (such as zope.interface).
activate = abspath(join(dirname(__file__), 'bin', 'activate_this.py'))
if exists(activate):
with open(activate) as f:
code = compile(f.read(), activate, 'exec')
exec(code, {}, dict(__file__=activate))
# Importing pkg_resources here seems to fix issues with namespace
# packages from the system-wide python polluting our environment
# on Debian and Debian-derived (Ubuntu) distributions.
import pkg_resources
# If the distribution has not been set up for development, do so.
if not environ.get('PYTHONSETUP'):
# Use an environment variable to signal not to do this on reload
environ['PYTHONSETUP'] = 'True'
try:
start_args = list(sys.argv)
run_setup('setup.py', ['develop'])
finally:
sys.argv = start_args
# Start the application
from h.script import start
start(sys.argv[1:])