84 lines
2.6 KiB
Python
84 lines
2.6 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
import os
|
|
import sys
|
|
from setuptools import setup, find_packages
|
|
from setuptools import Command
|
|
|
|
|
|
class MyCommand(Command):
|
|
user_options = []
|
|
|
|
def initialize_options(self):
|
|
pass
|
|
|
|
def finalize_options(self):
|
|
pass
|
|
|
|
|
|
class CreatePythonEnvironment(MyCommand):
|
|
description = 'create a (virtual) python environment'
|
|
|
|
@staticmethod
|
|
def run():
|
|
python_bin = sys.executable if sys.executable else 'python'
|
|
python_ver = sys.version_info.major
|
|
if python_ver == 2:
|
|
path = os.path.join('env', 'python2')
|
|
symlink_path = os.path.join('env', 'python')
|
|
venv_module = 'virtualenv'
|
|
prompt = '(py2) '
|
|
elif python_ver == 3:
|
|
path = os.path.join('env', 'python3')
|
|
symlink_path = os.path.join('env', 'python')
|
|
venv_module = 'venv'
|
|
prompt = 'py3'
|
|
else:
|
|
sys.stderr.write('Python {} is not supported.\n'.format(python_ver))
|
|
sys.exit(os.EX_USAGE)
|
|
|
|
sys.stdout.write('Creating new python environment in {path}\n'.format(path=path))
|
|
cmd = ('{bin} -m {venv_module}'
|
|
' --prompt="{prompt}"'
|
|
' {path}'.format(bin=python_bin, path=path,
|
|
venv_module=venv_module, prompt=prompt))
|
|
os.system(cmd)
|
|
|
|
if symlink_path and symlink_path != 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('Depending on your operating system or command shell,')
|
|
print('you should activate the new environment for this shell session')
|
|
print('by running ONE of the following commands:')
|
|
print('- Windows: %s' % os.path.join(path, 'Scripts', 'activate'))
|
|
print('- C Shell: source %s/bin/activate.csh' % path)
|
|
print('- All others: source %s/bin/activate' % path)
|
|
|
|
|
|
setup(
|
|
name='django-deploy',
|
|
version='0.2.dev0',
|
|
description='Helper to deploy django apps.',
|
|
url='https://dev.heinzelwerk.de/git/python/django-deploy',
|
|
maintainer='Jens Kleineheismann',
|
|
maintainer_email='heinzel@farbemachtstark.de',
|
|
cmdclass={
|
|
'python': CreatePythonEnvironment,
|
|
},
|
|
packages=find_packages('src'),
|
|
package_dir={'': 'src'},
|
|
#include_package_data=True,
|
|
entry_points={
|
|
'console_scripts': [
|
|
'django-deploy.py = django_deploy:main',
|
|
],
|
|
},
|
|
install_requires=[
|
|
'django',
|
|
'mock',
|
|
],
|
|
)
|