Move manage.py to ara.server.__main__ and add an entry point

This moves manage.py inside the package and sets up an "ara-manage"
console entry point for doing something like "ara-manage runserver"
instead of "python manage.py runserver".

Putting this under __main__ also allows users to do "python -m
ara.server".

Change-Id: I86b57f11fed2fea0295b1980e2734e35289d84f3
This commit is contained in:
David Moreau Simard 2018-12-06 11:53:11 -05:00
parent 1e2a936a18
commit 90ac1acc51
No known key found for this signature in database
GPG Key ID: CBEB466764A9E621
3 changed files with 16 additions and 7 deletions

7
manage.py → ara/server/__main__.py Executable file → Normal file
View File

@ -2,7 +2,8 @@
import os
import sys
if __name__ == "__main__":
def main():
from ara import server
os.environ.setdefault("ARA_CFG", os.path.dirname(server.__file__) + "/configs/dev.cfg")
@ -11,3 +12,7 @@ if __name__ == "__main__":
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
if __name__ == "__main__":
main()

View File

@ -29,6 +29,10 @@ setup-hooks =
packages =
ara
[entry_points]
console_scripts =
ara-manage = ara.server.__main__:main
[build_sphinx]
source-dir = doc/source
build-dir = doc/build

12
tox.ini
View File

@ -21,15 +21,15 @@ commands = sphinx-build -W -b html doc/source doc/build/html
commands = {toxinidir}/tests/linters.sh
[testenv:py3]
commands = python manage.py test ara
commands = ara-manage test ara
setenv =
ARA_CFG={toxinidir}/ara/server/configs/test.cfg
[testenv:runserver]
commands =
python manage.py migrate
python manage.py collectstatic --clear --no-input
python manage.py runserver
ara-manage migrate
ara-manage collectstatic --clear --no-input
ara-manage runserver
# Temporary venv to help bootstrap integration
[testenv:ansible-integration]
@ -49,6 +49,6 @@ whitelist_externals =
[testenv:cover]
commands =
coverage erase
coverage run {toxinidir}/manage.py test ara/server
coverage run -a {toxinidir}/manage.py test ara/api
coverage run {toxinidir}/ara/server/__main__.py test ara/server
coverage run -a {toxinidir}/ara/server/__main__.py test ara/api
coverage html