Files
django-dav-events/setup.py
heinzel 0c2261074a
All checks were successful
Run tests / Execute tox to run the test suite (push) Successful in 2m39s
Update INSTALL.rst
2024-09-10 09:32:51 +02:00

113 lines
4.2 KiB
Python

#!/usr/bin/env python
import os
import posix
import sys
from setuptools import setup, find_packages
from setuptools import Command
class SetupPythonEnvironment(Command):
description = 'create a (virtual) python environment'
def run(self):
python_bin = sys.executable if sys.executable else 'python'
python_major_ver = sys.version_info.major
python_minor_ver = sys.version_info.minor
if python_major_ver == 3:
dirname = 'python%i.%i' % (python_major_ver, python_minor_ver)
path = os.path.join('env', dirname)
symlink_path = os.path.join('env', 'python')
venv_module = 'venv'
prompt = 'py%i.%i-dav' % (python_major_ver, python_minor_ver)
else:
sys.stderr.write('Python %d is not supported.\n' % python_major_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(Command):
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)
def get_long_description():
path = os.path.abspath(os.path.dirname(__file__))
file = os.path.join(path, 'README.rst')
with open(file) as f:
return f.read()
setup(
name='django-dav-events',
version='2.2.1',
description='A django based web application project to drive the Touren- & Kurseportal of DAV Karlsruhe.',
long_description=get_long_description(),
long_description_content_type='text/x-rst',
url='https://dev.heinzelwerk.de/git/DAV-KA/django-dav-events',
author='Jens Kleineheismann',
author_email='heinzel@alpenverein-karlsruhe.de',
cmdclass={
'mkpyenv': SetupPythonEnvironment,
'quickdev': QuickSetup,
},
packages=find_packages(),
include_package_data=True,
entry_points={
'console_scripts': [
'django-dav-admin = dav_base.console_scripts.admin:main',
],
},
)