Commit e9047ffc authored by Michael Salim's avatar Michael Salim
Browse files

auto-DB setup

parent ab05fbd8
......@@ -8,8 +8,12 @@ balsamjobs
argobalsam_env
env
db.sqlite3
balsam/argo/migrations
balsam/service/migrations
balsam/argo/migrations/*.py
!balsam/argo/migrations/__init__.py
balsam/service/migrations/*.py
!balsam/service/migrations/__init__.py
experiments
docs/_build/*
*.egg-info
......@@ -2,10 +2,36 @@
https://packaging.python.org/en/latest/distributing.html
'''
from setuptools import setup, find_packages
from setuptools.command.install import install
from setuptools.command.develop import develop
from codecs import open
from os import path
import os
def auto_setup_db():
import django
os.environ['DJANGO_SETTINGS_MODULE'] = 'balsam.django_config.settings'
django.setup()
from django.core.management import call_command
call_command('makemigrations',interactive=False,verbosity=2)
call_command('migrate',interactive=False,verbosity=2)
class PostInstallCommand(install):
'''Post-installation for installation mode'''
def run(self):
auto_setup_db()
install.run(self)
class PostDevelopCommand(develop):
'''Post-installation for installation mode'''
def run(self):
auto_setup_db()
develop.run(self)
here = path.abspath(path.dirname(__file__))
......@@ -40,4 +66,10 @@ setup(
],
'gui_scripts': [],
},
# Balsam DB auto-setup post installation
cmdclass={
'develop': PostDevelopCommand,
'install': PostInstallCommand,
},
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment