Files
django-dav-events/setup.py
Jens Kleineheismann 105e227580
All checks were successful
buildbot/tox Build done.
Updated copyright information
2020-01-14 14:47:50 +01:00

132 lines
4.4 KiB
Python

#!/usr/bin/env python
import os
import posix
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 SetupPythonEnvironment(MyCommand):
description = 'create a (virtual) python environment'
def run(self):
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-dav) '
elif python_ver == 3:
path = os.path.join('env', 'python3')
symlink_path = os.path.join('env', 'python')
venv_module = 'venv'
prompt = 'py3-dav'
else:
sys.stderr.write('Python %d is not supported.\n' % python_ver)
sys.exit(posix.EX_USAGE)
print('Creating new python environment in {path}'.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 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)
class QuickSetup(MyCommand):
description = 'create a typical installation for developing'
def run(self):
python_bin = sys.executable if sys.executable else 'python'
django_project_path = 'env/django'
mgmt_script = os.path.join(django_project_path, 'manage.py')
sys.stdout.write('Install distribution in development mode...\n')
cmd = 'pip install -e .'
os.system(cmd)
sys.stdout.write('Setup django project in {}...\n'.format(django_project_path))
cmd = 'django-dav-admin setup {}'.format(django_project_path)
os.system(cmd)
sys.stdout.write('Enable modules...\n')
modules = ['dav_auth', 'dav_events', 'dav_registration']
for m in modules:
cmd = '{bin} {mgmt} enable_module {module}'.format(bin=python_bin,
mgmt=mgmt_script,
module=m)
os.system(cmd)
sys.stdout.write('Make database migrations...\n')
cmd = '{bin} {mgmt} makemigrations'.format(bin=python_bin, mgmt=mgmt_script)
os.system(cmd)
sys.stdout.write('Create database...\n')
cmd = '{bin} {mgmt} migrate'.format(bin=python_bin, mgmt=mgmt_script)
os.system(cmd)
sys.stdout.write('Create superuser \'root\'...\n')
cmd = ('{bin} {mgmt} createsuperuser'
' --username root').format(bin=python_bin, mgmt=mgmt_script)
os.system(cmd)
setup(
name='django-dav-events',
version='2.0',
description='A django based web application project to organize DAV Events.',
url='https://touren.alpenverein-karlsruhe.de',
author='Jens Kleineheismann',
author_email='heinzel@alpenverein-karlsruhe.de',
cmdclass={
'mkpyenv': SetupPythonEnvironment,
'quickdev': QuickSetup,
},
packages=find_packages(),
include_package_data=True,
test_suite='tests.test_suite',
entry_points={
'console_scripts': [
'django-dav-admin = dav_base.console_scripts.admin:main',
],
},
install_requires=[
'babel',
'django >= 1.11, < 2.0',
'django-extensions',
'django-bootstrap3 < 12',
'django-countries',
'django-datetime-widget',
'pytz',
'selenium',
'coverage',
],
extras_require={
'production': ['psycopg2'],
},
)