Move tasks.py back to the source folder

This was causing many problems with the installation and was only needed for
the packaged version in pypi.

See #277 for more details
This commit is contained in:
Roland Geider
2016-04-26 18:34:32 +02:00
parent 2250b686ad
commit d0813d2429
9 changed files with 22 additions and 39 deletions

View File

@@ -24,8 +24,8 @@ install:
- sh -c "if [ '$DB' = 'postgresql' ]; then pip install psycopg2; fi"
- pip install -r requirements_devel.txt
- sh -c "if [ '$DB' = 'sqlite' ]; then invoke --root wger create_settings; fi"
- sh -c "if [ '$DB' = 'postgresql' ]; then invoke --root wger create_settings --database-type postgresql; fi"
- sh -c "if [ '$DB' = 'sqlite' ]; then invoke create_settings; fi"
- sh -c "if [ '$DB' = 'postgresql' ]; then invoke create_settings --database-type postgresql; fi"
# Create test databases
before_script:

View File

@@ -3,6 +3,7 @@ include AUTHORS.txt
include AGPL.txt
include CC-BY-SA.txt
include requirements.txt
include tasks.py
recursive-include wger *.*
recursive-exclude wger *.pyc

View File

@@ -55,10 +55,10 @@ and stable state.
$ git clone https://github.com/rolandgeider/wger.git
$ cd wger
$ pip install -r requirements.txt # or requirements_devel.txt to develop
$ invoke --root wger create_settings \
$ invoke create_settings \
--settings-path /home/wger/wger/settings.py \
--database-path /home/wger/wger/database.sqlite
$ invoke --root wger bootstrap_wger
$ invoke bootstrap_wger
--settings-path /home/wger/wger/settings.py \
--no-start-server
$ python manage.py runserver

View File

@@ -14,10 +14,10 @@ and populate it with data on the first run::
$ git clone https://github.com/rolandgeider/wger.git
$ cd wger
$ pip install -r requirements_devel.txt
$ invoke --root wger create_settings \
$ invoke create_settings \
--settings-path /home/wger/wger/settings.py \
--database-path /home/wger/wger/database.sqlite
$ invoke --root wger bootstrap_wger
$ invoke bootstrap_wger
--settings-path /home/wger/wger/settings.py \
--no-start-server
$ python manage.py runserver

View File

@@ -30,10 +30,10 @@ RUN npm install bower \
&& . /home/wger/venv/bin/activate \
&& pip install --upgrade pip \
&& pip install -r requirements.txt \
&& invoke --root wger create_settings \
&& invoke create_settings \
--settings-path /home/wger/src/settings.py \
--database-path /home/wger/db/database.sqlite \
&& invoke --root wger bootstrap_wger \
&& invoke bootstrap_wger \
--settings-path /home/wger/src/settings.py \
--no-start-server

View File

@@ -27,10 +27,10 @@ RUN virtualenv --python python3 /home/wger/venv
RUN . /home/wger/venv/bin/activate \
&& pip install --upgrade pip \
&& pip install -r requirements_devel.txt \
&& invoke --root wger create_settings \
&& invoke create_settings \
--settings-path /home/wger/src/settings.py \
--database-path /home/wger/db/database.sqlite \
&& invoke --root wger bootstrap_wger \
&& invoke bootstrap_wger \
--settings-path /home/wger/src/settings.py \
--no-start-server

View File

@@ -3,18 +3,13 @@ import sys
from django.core.management import execute_from_command_line
from wger.tasks import (
from tasks import (
setup_django_environment,
get_user_config_path
)
if __name__ == "__main__":
# Add the current directory to the system path. This is needed because
# tasks.py removes it, read the comment the on why this clutch is needed.
# Otherwise "local" setting files could not be imported
sys.path.append('.')
# If user passed the settings flag ignore the default wger settings
if not any('--settings' in s for s in sys.argv):
setup_django_environment(get_user_config_path('wger', 'settings.py'))

View File

@@ -16,16 +16,6 @@
import sys
#
# This is an ugly and terrible hack, please don't do this!
#
# The reason we do this is that during django's setup later in this script, it
# tries to load the standard library's "mail" module which collides with our
# (perhaps unluckily named) app with the same name. Since this script is only
# used for installation and does not depend on anything from wger proper, it
# is kind of OK to change the system path.
sys.path = sys.path[1:]
import time
import logging
import threading
@@ -108,7 +98,7 @@ def bootstrap_wger(settings_path=None,
create_or_reset_admin(settings_path=settings_path)
# Download JS libraries with bower
os.chdir(os.path.dirname(os.path.abspath(__file__)))
os.chdir(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'wger'))
run('npm install bower')
call_command('bower', 'install')
@@ -143,7 +133,7 @@ def create_settings(settings_path=None, database_path=None, url=None, database_t
url = 'http://localhost:8000'
# Fill in the config file template
settings_template = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'settings.tpl')
settings_template = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'wger', 'settings.tpl')
with open(settings_template, 'r') as settings_file:
settings_content = settings_file.read()
@@ -210,7 +200,7 @@ def create_or_reset_admin(settings_path=None):
# current_dir = os.path.join(os.getcwd(), 'wger')
current_dir = os.path.dirname(os.path.abspath(__file__))
path = os.path.join(current_dir, 'core', 'fixtures/')
path = os.path.join(current_dir, 'wger', 'core', 'fixtures/')
call_command("loaddata", path + "users.json")
@@ -241,11 +231,11 @@ def load_fixtures(settings_path=None):
current_dir = os.path.dirname(os.path.abspath(__file__))
# Gym
path = os.path.join(current_dir, 'gym', 'fixtures/')
path = os.path.join(current_dir, 'wger', 'gym', 'fixtures/')
call_command("loaddata", path + "gym.json")
# Core
path = os.path.join(current_dir, 'core', 'fixtures/')
path = os.path.join(current_dir, 'wger', 'core', 'fixtures/')
call_command("loaddata", path + "languages.json")
call_command("loaddata", path + "groups.json")
call_command("loaddata", path + "users.json")
@@ -253,7 +243,7 @@ def load_fixtures(settings_path=None):
call_command("loaddata", path + "days_of_week.json")
# Config
path = os.path.join(current_dir, 'config', 'fixtures/')
path = os.path.join(current_dir, 'wger', 'config', 'fixtures/')
call_command("loaddata", path + "language_config.json")
call_command("loaddata", path + "gym_config.json")
@@ -261,20 +251,20 @@ def load_fixtures(settings_path=None):
# path = os.path.join(current_dir, 'manager', 'fixtures/')
# Exercises
path = os.path.join(current_dir, 'exercises', 'fixtures/')
path = os.path.join(current_dir, 'wger', 'exercises', 'fixtures/')
call_command("loaddata", path + "equipment.json")
call_command("loaddata", path + "muscles.json")
call_command("loaddata", path + "categories.json")
call_command("loaddata", path + "exercises.json")
# Nutrition
path = os.path.join(current_dir, 'nutrition', 'fixtures/')
path = os.path.join(current_dir, 'wger', 'nutrition', 'fixtures/')
call_command("loaddata", path + "ingredients.json")
call_command("loaddata", path + "weight_units.json")
call_command("loaddata", path + "ingredient_units.json")
# Gym
path = os.path.join(current_dir, 'gym', 'fixtures/')
path = os.path.join(current_dir, 'wger', 'gym', 'fixtures/')
call_command("loaddata", path + "gym.json")
call_command("loaddata", path + "gym-config.json")
call_command("loaddata", path + "gym-adminconfig.json")

View File

@@ -24,10 +24,7 @@ version of the application. It simply redirects all arguments to the invoke
command, which does all the work.
'''
# Get the absolute path so we can pass it to invoke. This is only needed
# for the packaged version.
tasks_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'wger')
invoke_cmd = 'invoke --root {} '.format(tasks_path)
invoke_cmd = 'invoke '
def main():