From 85b6e018decce3f497e4bde1b89100fe9a495d36 Mon Sep 17 00:00:00 2001 From: Jens Kleineheismann Date: Thu, 13 Dec 2018 16:45:11 +0100 Subject: [PATCH] UPD: improved install process. --- INSTALL.rst | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++ MANIFEST.in | 10 ++++-- README.rst | 63 ++--------------------------------- setup.py | 59 ++++++++++++++++++++++++++------ 4 files changed, 155 insertions(+), 73 deletions(-) create mode 100644 INSTALL.rst diff --git a/INSTALL.rst b/INSTALL.rst new file mode 100644 index 0000000..a920675 --- /dev/null +++ b/INSTALL.rst @@ -0,0 +1,96 @@ +REQUIREMENTS +============ +- Python 2.7 +- Python package virtualenv (in most cases this is distributed or installed together with python) +- Django (will be installed automatically) +- Several additional django related python packages (will be installed automatically) + +For production use you surly want a real web server that supports WSGI +(e.g. Apache httpd with mod_wsgi) and a real Database like PostgreSQL. + + +QUICK INSTALLATION FOR THE IMPATIENT +==================================== +python setup.py mkpyenv +source env/python/bin/activate +python setup.py quickdev + + +INSTALLATION +============ + +1. Python Environment +--------------------- + It is strongly recommended to create a separated python environment + for this django project. But it is not exactly necessary. + + The creation of a separated python environment is very easy with the + virtualenv tool (a python package). + + If you decide to not use virtualenv, proceed with step 2. + + - Create the python environment in a directory called ./env/python: + + ``virtualenv --prompt="(dav)" ./env/python`` + + - If you use a posix compatible shell (like bash, the linux default shell), + you have to activate the environment for the current shell session + with the following command: + + ``source ./env/python/bin/activate`` + + Your shell prompt should be prefixed with '(dav)' now. + + Do not exit the shell session (nor deactivate the environment) until the + whole installation is done. + After that you can call the command ``deactivate`` to deactivate the project + environment and access the systems standard python environment again. + + If you have left the session or deactivated the environment and want to + reactivate the environment (e.g. to execute a python command) use the + previous ``source ...`` command. + +2. Install files +---------------- + + * ``python setup.py develop`` + * ``django-dav-events-admin setup ./env/django`` + + The django project directory ('./env/django' within the previous example) + will be called *project root* for now on. + +3. Enable modules +----------------- + Our web application consist of several modules, that care about single + aspects of the whole picture. + You want to enable some of those modules by execute a + management command. + + Change into the *project root* (where the file ``manage.py`` lives) + and run + + * ``python manage.py enable_module dav_auth`` + * ``python manage.py enable_module dav_events`` + +4. Create the database schema / Populate the database +----------------------------------------------------- + While you still are in the *project root* directory, run + + * ``python manage.py makemigrations`` + * ``python manage.py migrate`` + +5. Create a super user or administrator account +----------------------------------------------- + While you still are in the *project root* directory, run + + * ``python manage.py createsuperuser`` + +6. Start test server +-------------------- + While you still are in the *project root* directory, run + + ``python manage.py runserver`` + + Now you should be able to connect to the test server via + + http://localhost:8000 diff --git a/MANIFEST.in b/MANIFEST.in index 8bc380f..91c5678 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,9 @@ -recursive-include dav_events/console_scripts/Resources *.py -recursive-include dav_events/static * +recursive-include dav_base/console_scripts/django_project_config *.py +recursive-include dav_base/static * +recursive-include dav_base/templates * +include dav_auth/module.json +recursive-include dav_auth/django_project_config *.py +recursive-include dav_auth/templates * +include dav_events/module.json +recursive-include dav_events/django_project_config *.py recursive-include dav_events/templates * diff --git a/README.rst b/README.rst index 1dc082a..1e3a386 100644 --- a/README.rst +++ b/README.rst @@ -5,71 +5,12 @@ This is the DAV Events django project. REQUIREMENTS ============ -- Python 2.7 -- Django -- Several additional django related python packages - -For production use you surly want a real web server that supports WSGI -(e.g. Apache httpd with mod_wsgi) and a real Database like PostgreSQL. +See INSTALL.rst INSTALLATION ============ - -1. Python Environment ---------------------- - It is strongly recommended to create a separated python environment - for your django project. But it is not exactly necessary. - - The creation of a separated python environment is very easy with the - virtualenv tool (a python package). - - If you decide to not use virtualenv, confirm_status with step 2. - - - Create the python environment in a directory called ./env/python: - - ``virtualenv --prompt="(dav)" ./env/python`` - - - If you use a posix compatible shell (like bash, the linux default shell), - you have to enter the environment with the following command: - - ``source ./env/python/bin/activate`` - - Your shell prompt should show the prefix '(dav)' now. - - Do not leave the environment (nor exit the shell) until the whole - installation is done. - After that you can call the command ``deactivate`` to leave. - - If you have left the environment and want to reenter it (e.g. to execute - a python command) use the previous ``source ...`` command. - -2. Install files ----------------- - - * ``python setup.py develop`` - * ``django-dav-events-admin setup ./env/django`` - - The django project directory ('./env/django' within the previous example) - will be called project root for now on. - -3. Create the database schema / Populate the database ------------------------------------------------------ - Change into the *project root* (where the file ``manage.py`` lives) - and run - - * ``python manage.py makemigrations`` - * ``python manage.py migrate`` - -4. Start test server --------------------- - While you still are in the *project root* directory, run - - ``python manage.py runserver`` - - Now you should be able to connect to the test server via - - http://localhost:8000 +See INSTALL.rst LICENCE diff --git a/setup.py b/setup.py index e116f2b..46ab6a7 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ class SetupPythonEnvironment(MyCommand): def run(self): python_bin = sys.executable if sys.executable else 'python' - path = 'env/python' + path = os.path.join('env', 'python') prompt = '(dav)' print('Creating new python environment in {path}'.format(path=path)) @@ -30,12 +30,50 @@ class SetupPythonEnvironment(MyCommand): ' {path}'.format(bin=python_bin, path=path, prompt=prompt)) os.system(cmd) - print('Depending on your operating system and shell,') - print('you should enter the new environment by running') - print('ONE of the following commands:') - print('> source %s/bin/activate' % path) - print('> %s/Scripts/activate.bat' % path) - print('> %s/Scripts/activate.ps1' % 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') + self.run_command('develop') + + 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'] + 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) if sys.version_info.major != 2: @@ -46,12 +84,13 @@ if sys.version_info.major != 2: setup( name='django-dav-events', version='1.0', - description='A django based web application project to submit DAV Events.', - url='https://www.heinzelwelt.de', + description='A django based web application project to organize DAV Events.', + url='https://heinzel.alpenverein-karlsruhe.de', maintainer='Jens Kleineheismann', - maintainer_email='heinzel@heinzelwelt.de', + maintainer_email='heinzel@alpenverein-karlsruhe.de', cmdclass={ 'mkpyenv': SetupPythonEnvironment, + 'quickdev': QuickSetup, }, packages=find_packages(), include_package_data=True,