UPD: improved setup.py

This commit is contained in:
2019-03-29 16:55:46 +01:00
parent 4226e498f0
commit 80e9271209

View File

@@ -24,12 +24,14 @@ class SetupPythonEnvironment(MyCommand):
python_ver = sys.version_info.major python_ver = sys.version_info.major
if python_ver == 2: if python_ver == 2:
path = os.path.join('env', 'python2') path = os.path.join('env', 'python2')
symlink_path = os.path.join('env', 'python')
venv_module = 'virtualenv' venv_module = 'virtualenv'
prompt = '(dav) ' prompt = '(py2-dav) '
elif python_ver == 3: elif python_ver == 3:
path = os.path.join('env', 'python3') path = os.path.join('env', 'python3')
symlink_path = os.path.join('env', 'python')
venv_module = 'venv' venv_module = 'venv'
prompt = 'dav3' prompt = 'py3-dav'
else: else:
sys.stderr.write('Python %d is not supported.\n' % python_ver) sys.stderr.write('Python %d is not supported.\n' % python_ver)
sys.exit(posix.EX_USAGE) sys.exit(posix.EX_USAGE)
@@ -41,6 +43,11 @@ class SetupPythonEnvironment(MyCommand):
venv_module=venv_module, prompt=prompt)) venv_module=venv_module, prompt=prompt))
os.system(cmd) os.system(cmd)
if symlink_path and not os.path.exists(symlink_path):
symlink_dir = os.path.dirname(symlink_path)
relpath = os.path.relpath(path, symlink_dir)
os.symlink(relpath, symlink_path)
print('') print('')
print('Depending on your operating system or command shell,') print('Depending on your operating system or command shell,')
print('you should activate the new environment for this shell session') print('you should activate the new environment for this shell session')
@@ -59,7 +66,8 @@ class QuickSetup(MyCommand):
mgmt_script = os.path.join(django_project_path, 'manage.py') mgmt_script = os.path.join(django_project_path, 'manage.py')
sys.stdout.write('Install distribution in development mode...\n') sys.stdout.write('Install distribution in development mode...\n')
self.run_command('develop') cmd = 'pip install -e .'
os.system(cmd)
sys.stdout.write('Setup django project in {}...\n'.format(django_project_path)) sys.stdout.write('Setup django project in {}...\n'.format(django_project_path))
cmd = 'django-dav-admin setup {}'.format(django_project_path) cmd = 'django-dav-admin setup {}'.format(django_project_path)