mirror of
https://github.com/wger-project/wger.git
synced 2026-12-02 18:19:40 +01:00
Some changes to the installation scripts
These changes are necessary for the packaged version of the application (pip install wger). Among other things and (hopefully!) to make the installation more robust, all commands are routed through the 'wger' entry point, and calling 'invoke' on its own has been deprecated. Sadly, we had to revive an ugly hack that changes the sys path, but hopefully this doesn't cause any problems.
This commit is contained in:
4
.bowerrc
4
.bowerrc
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"directory" : "wger/core/static/bower_components",
|
||||
"interactive": false
|
||||
}
|
||||
@@ -69,7 +69,7 @@ Then install the python packages from pypi in the virtualenv::
|
||||
$ invoke create_settings \
|
||||
--settings-path /home/wger/wger/settings.py \
|
||||
--database-path /home/wger/wger/database.sqlite
|
||||
$ invoke bootstrap_wger \
|
||||
$ invoke bootstrap \
|
||||
--settings-path /home/wger/wger/settings.py \
|
||||
--no-start-server
|
||||
$ python manage.py runserver
|
||||
@@ -130,7 +130,7 @@ Stable version (from PyPI)
|
||||
|
||||
::
|
||||
|
||||
$ wger bootstrap_wger
|
||||
$ wger bootstrap
|
||||
|
||||
|
||||
3) Log in as: **admin**, password **admin**
|
||||
@@ -144,13 +144,13 @@ The available options for the ``wger`` command (if installed from PyPI) or
|
||||
<command>``::
|
||||
|
||||
|
||||
bootstrap_wger Performs all steps necessary to bootstrap the application
|
||||
bootstrap Performs all steps necessary to bootstrap the application
|
||||
config_location Returns the default location for the settings file and the data folder
|
||||
create_or_reset_admin Creates an admin user or resets the password for an existing one
|
||||
create_settings Creates a local settings file
|
||||
load_fixtures Loads all fixtures
|
||||
migrate_db Run all database migrations
|
||||
start_wger Start the application using django's built in webserver
|
||||
start Start the application using django's built in webserver
|
||||
|
||||
Contact
|
||||
=======
|
||||
|
||||
@@ -5,6 +5,14 @@ Changelog
|
||||
--------------------
|
||||
**2016-XX-XX**
|
||||
|
||||
.. warning ::
|
||||
There have been some changes to the installation procedure. Calling 'invoke'
|
||||
on its own has been deprecated, you should use the 'wger' command (which
|
||||
accepts the same options). Also some of these commands have been renamed:
|
||||
|
||||
* ``start_wger`` to ``wger``
|
||||
* ``bootstrap_wger`` ``bootstrap``
|
||||
|
||||
Upgrade steps from 1.7:
|
||||
|
||||
* Django update to 1.9: ``pip install -r requirements.txt``
|
||||
|
||||
@@ -24,17 +24,17 @@ in this manual.
|
||||
|
||||
You can get a list of all available commands with ``invoke --list`` or ``wger``.
|
||||
While you can do this from any folder in the application, some of them (e.g.
|
||||
``start_wger``) might only work from the root folder::
|
||||
``start``) might only work from the root folder::
|
||||
|
||||
Available tasks:
|
||||
|
||||
bootstrap_wger Performs all steps necessary to bootstrap the application
|
||||
bootstrap Performs all steps necessary to bootstrap the application
|
||||
config_location Returns the default location for the settings file and the data folder
|
||||
create_or_reset_admin Creates an admin user or resets the password for an existing one
|
||||
create_settings Creates a local settings file
|
||||
load_fixtures Loads all fixtures
|
||||
migrate_db Run all database migrations
|
||||
start_wger Start the application using django's built in webserver
|
||||
start Start the application using django's built in webserver
|
||||
|
||||
You can also get help on a specific command with ``invoke --help <command>``.
|
||||
|
||||
@@ -43,21 +43,21 @@ You can also get help on a specific command with ``invoke --help <command>``.
|
||||
settings file to use for the operation. If you use it, it is recommended to
|
||||
use absolute paths, for example::
|
||||
|
||||
invoke bootstrap_wger --settings-path /path/to/development/wger/settings-test.py
|
||||
invoke bootstrap --settings-path /path/to/development/wger/settings-test.py
|
||||
|
||||
|
||||
|
||||
Bootstrap wger
|
||||
~~~~~~~~~~~~~~
|
||||
Bootstrap
|
||||
~~~~~~~~~
|
||||
|
||||
Command: **bootstrap_wger**
|
||||
Command: **bootstrap**
|
||||
|
||||
This command bootstraps the application: it creates a settings file, initialises
|
||||
a sqlite database, loads all necessary fixtures for the application to work and
|
||||
creates a default administrator user. While it can also work with e.g. a postgreSQL
|
||||
database, you will need to create it yourself::
|
||||
|
||||
invoke bootstrap_wger
|
||||
invoke bootstrap
|
||||
|
||||
The most usual use-case is creating the settings file and the sqlite database to
|
||||
their default locations, but you can set your own paths if you want e.g. start
|
||||
@@ -65,7 +65,7 @@ developing on a branch that is going to change the database schema.
|
||||
|
||||
Usage::
|
||||
|
||||
Usage: inv[oke] [--core-opts] bootstrap_wger [--options] [other tasks here ...]
|
||||
Usage: inv[oke] [--core-opts] bootstrap [--options] [other tasks here ...]
|
||||
|
||||
Docstring:
|
||||
Performs all steps necessary to bootstrap the application
|
||||
@@ -81,11 +81,11 @@ Usage::
|
||||
Start wger
|
||||
~~~~~~~~~~
|
||||
|
||||
Command: **start_wger**
|
||||
Command: **start**
|
||||
|
||||
Starts an already installed application::
|
||||
|
||||
invoke start_wger
|
||||
invoke start
|
||||
|
||||
Please note that this is simply a comfort function and does not use any *magic*,
|
||||
it simply calls django's development server and (optionally) opens a browser
|
||||
@@ -94,7 +94,7 @@ is probably better.
|
||||
|
||||
Usage::
|
||||
|
||||
Usage: inv[oke] [--core-opts] start_wger [--options] [other tasks here ...]
|
||||
Usage: inv[oke] [--core-opts] start [--options] [other tasks here ...]
|
||||
|
||||
Docstring:
|
||||
Start the application using django's built in webserver
|
||||
|
||||
@@ -48,7 +48,7 @@ To install the server::
|
||||
$ invoke create_settings \
|
||||
--settings-path /home/wger/wger/settings.py \
|
||||
--database-path /home/wger/wger/database.sqlite
|
||||
$ invoke bootstrap_wger \
|
||||
$ invoke bootstrap \
|
||||
--settings-path /home/wger/wger/settings.py \
|
||||
--no-start-server
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ for the engine). Also set ``MEDIA_ROOT`` to ``/home/wger/media`` and
|
||||
Run the installation script, this will download some CSS and JS libraries and
|
||||
load all initial data::
|
||||
|
||||
invoke bootstrap_wger --settings-path /path/to/settings.py --no-start-server
|
||||
invoke bootstrap --settings-path /path/to/settings.py --no-start-server
|
||||
|
||||
|
||||
Collect all static resources::
|
||||
|
||||
@@ -29,10 +29,11 @@ RUN virtualenv --python python3 /home/wger/venv
|
||||
RUN . /home/wger/venv/bin/activate \
|
||||
&& pip install --upgrade pip \
|
||||
&& pip install -r requirements.txt \
|
||||
&& invoke create_settings \
|
||||
&& python setup.py develop \
|
||||
&& wger create_settings \
|
||||
--settings-path /home/wger/src/settings.py \
|
||||
--database-path /home/wger/db/database.sqlite \
|
||||
&& invoke bootstrap_wger \
|
||||
&& wger bootstrap \
|
||||
--settings-path /home/wger/src/settings.py \
|
||||
--no-start-server
|
||||
|
||||
|
||||
@@ -17,6 +17,12 @@ RUN dnf update;\
|
||||
nodejs npm libjpeg-turbo-devel zlib-devel git \
|
||||
tmux sudo redhat-rpm-config gcc python-imaging
|
||||
|
||||
# Set locale to UTF8, otherwise problems with the encoding can occur
|
||||
RUN locale-gen en_US.UTF-8
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LANGUAGE en_US:en
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
|
||||
# Add wger user
|
||||
RUN adduser wger
|
||||
RUN echo "wger ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/wger
|
||||
@@ -32,10 +38,11 @@ RUN virtualenv --python python3 /home/wger/venv
|
||||
RUN . /home/wger/venv/bin/activate \
|
||||
&& pip install --upgrade pip \
|
||||
&& pip install -r requirements_devel.txt \
|
||||
&& invoke create_settings \
|
||||
&& python setup.py develop \
|
||||
&& wger create_settings \
|
||||
--settings-path /home/wger/src/settings.py \
|
||||
--database-path /home/wger/db/database.sqlite \
|
||||
&& invoke bootstrap_wger \
|
||||
&& wger bootstrap \
|
||||
--settings-path /home/wger/src/settings.py \
|
||||
--no-start-server
|
||||
|
||||
@@ -45,9 +52,11 @@ RUN . /home/wger/venv/bin/activate \
|
||||
# to delete the node_modules folder and install everything again
|
||||
# -> https://github.com/npm/npm/issues/9863
|
||||
# -> https://github.com/npm/npm/issues/13306
|
||||
RUN rm -r node_modules \
|
||||
RUN cd wger \
|
||||
&& rm -r node_modules \
|
||||
&& npm install bower \
|
||||
&& npm install \
|
||||
&& cd .. \
|
||||
&& mkdir ~/media \
|
||||
&& sed -i "/^MEDIA_ROOT/c\MEDIA_ROOT='\/home\/wger\/media'" settings.py \
|
||||
&& . /home/wger/venv/bin/activate \
|
||||
|
||||
@@ -15,6 +15,13 @@ FROM wger/base
|
||||
MAINTAINER Roland Geider <roland@geider.net>
|
||||
EXPOSE 8000
|
||||
|
||||
# Set locale to UTF8, otherwise problems with the encoding can occur
|
||||
RUN locale-gen en_US.UTF-8
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LANGUAGE en_US:en
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
|
||||
|
||||
# Install dependencies
|
||||
RUN apt-get install -y vim tmux sqlite3
|
||||
|
||||
@@ -27,10 +34,11 @@ RUN virtualenv --python python3 /home/wger/venv
|
||||
RUN . /home/wger/venv/bin/activate \
|
||||
&& pip install --upgrade pip \
|
||||
&& pip install -r requirements_devel.txt \
|
||||
&& invoke create_settings \
|
||||
&& python setup.py develop \
|
||||
&& wger create_settings \
|
||||
--settings-path /home/wger/src/settings.py \
|
||||
--database-path /home/wger/db/database.sqlite \
|
||||
&& invoke bootstrap_wger \
|
||||
&& wger bootstrap \
|
||||
--settings-path /home/wger/src/settings.py \
|
||||
--no-start-server
|
||||
|
||||
@@ -40,9 +48,11 @@ RUN . /home/wger/venv/bin/activate \
|
||||
# to delete the node_modules folder and install everything again
|
||||
# -> https://github.com/npm/npm/issues/9863
|
||||
# -> https://github.com/npm/npm/issues/13306
|
||||
RUN rm -r node_modules \
|
||||
RUN cd wger \
|
||||
&& rm -r node_modules \
|
||||
&& npm install bower \
|
||||
&& npm install \
|
||||
&& cd .. \
|
||||
&& mkdir ~/media \
|
||||
&& sed -i "/^MEDIA_ROOT/c\MEDIA_ROOT='\/home\/wger\/media'" settings.py \
|
||||
&& . /home/wger/venv/bin/activate \
|
||||
|
||||
@@ -3,7 +3,7 @@ import sys
|
||||
|
||||
from django.core.management import execute_from_command_line
|
||||
|
||||
from tasks import (
|
||||
from wger.tasks import (
|
||||
setup_django_environment,
|
||||
get_user_config_path
|
||||
)
|
||||
|
||||
2
setup.py
2
setup.py
@@ -14,7 +14,7 @@ from setuptools import (
|
||||
from wger import get_version
|
||||
|
||||
|
||||
with open('README.rst') as readme:
|
||||
with open('README.rst', encoding='utf-8') as readme:
|
||||
long_description = readme.read()
|
||||
|
||||
with open('requirements.txt') as requirements_production:
|
||||
|
||||
4
wger/.bowerrc
Normal file
4
wger/.bowerrc
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"directory" : "core/static/bower_components",
|
||||
"interactive": false
|
||||
}
|
||||
@@ -28,6 +28,9 @@ invoke_cmd = 'invoke '
|
||||
|
||||
|
||||
def main():
|
||||
# Change the working directory so that invoke can find the tasks fiel
|
||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
args = sys.argv[1:]
|
||||
if len(args):
|
||||
run(invoke_cmd + ' '.join(args), pty=True)
|
||||
|
||||
@@ -16,6 +16,17 @@
|
||||
|
||||
|
||||
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
|
||||
@@ -40,7 +51,7 @@ logger = logging.getLogger(__name__)
|
||||
'browser': 'Whether to open the application in a browser window. Default: false',
|
||||
'settings-path': 'Path to settings file (absolute path recommended). Leave empty for default',
|
||||
'extra-args': 'Additional arguments to pass to the builtin server. Pass as string: "--arg1 --arg2=value". Default: none'})
|
||||
def start_wger(context, address='localhost', port=8000, browser=False, settings_path=None, extra_args=''):
|
||||
def start(context, address='localhost', port=8000, browser=False, settings_path=None, extra_args=''):
|
||||
'''
|
||||
Start the application using django's built in webserver
|
||||
'''
|
||||
@@ -64,13 +75,13 @@ def start_wger(context, address='localhost', port=8000, browser=False, settings_
|
||||
'port': 'Port to use. Default: 8000',
|
||||
'browser': 'Whether to open the application in a browser window. Default: false',
|
||||
'start-server': 'Whether to start the development server. Default: true'})
|
||||
def bootstrap_wger(context,
|
||||
settings_path=None,
|
||||
database_path=None,
|
||||
address='localhost',
|
||||
port=8000,
|
||||
browser=False,
|
||||
start_server=True):
|
||||
def bootstrap(context,
|
||||
settings_path=None,
|
||||
database_path=None,
|
||||
address='localhost',
|
||||
port=8000,
|
||||
browser=False,
|
||||
start_server=True):
|
||||
'''
|
||||
Performs all steps necessary to bootstrap the application
|
||||
'''
|
||||
@@ -99,15 +110,14 @@ def bootstrap_wger(context,
|
||||
create_or_reset_admin(context, settings_path=settings_path)
|
||||
|
||||
# Download JS libraries with bower
|
||||
os.chdir(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'wger'))
|
||||
context.run('npm install bower')
|
||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||
context.run('npm install bower')
|
||||
call_command('bower', 'install')
|
||||
|
||||
# Start the webserver
|
||||
if start_server:
|
||||
print('*** Bootstraping complete, starting application')
|
||||
start_wger(address=address, port=port, browser=browser, settings_path=settings_path)
|
||||
start(context, address=address, port=port, browser=browser, settings_path=settings_path)
|
||||
|
||||
|
||||
@task(help={'settings-path': 'Path to settings file (absolute path recommended). Leave empty for default',
|
||||
@@ -135,7 +145,7 @@ def create_settings(context, settings_path=None, database_path=None, url=None, d
|
||||
url = 'http://localhost:8000'
|
||||
|
||||
# Fill in the config file template
|
||||
settings_template = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'wger', 'settings.tpl')
|
||||
settings_template = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'settings.tpl')
|
||||
with open(settings_template, 'r') as settings_file:
|
||||
settings_content = settings_file.read()
|
||||
|
||||
@@ -198,11 +208,9 @@ def create_or_reset_admin(context, settings_path=None):
|
||||
except User.DoesNotExist:
|
||||
print("*** Created default admin user")
|
||||
|
||||
# os.chdir(os.path.dirname(inspect.stack()[0][1]))
|
||||
# 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")
|
||||
|
||||
|
||||
@@ -228,16 +236,14 @@ def load_fixtures(context, settings_path=None):
|
||||
setup_django_environment(settings_path)
|
||||
|
||||
|
||||
# os.chdir(os.path.dirname(inspect.stack()[0][1]))
|
||||
# current_dir = os.path.join(os.getcwd(), 'wger')
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# Gym
|
||||
path = os.path.join(current_dir, 'wger', 'gym', 'fixtures/')
|
||||
path = os.path.join(current_dir, 'gym', 'fixtures/')
|
||||
call_command("loaddata", path + "gym.json")
|
||||
|
||||
# Core
|
||||
path = os.path.join(current_dir, 'wger', 'core', 'fixtures/')
|
||||
path = os.path.join(current_dir, 'core', 'fixtures/')
|
||||
call_command("loaddata", path + "languages.json")
|
||||
call_command("loaddata", path + "groups.json")
|
||||
call_command("loaddata", path + "users.json")
|
||||
@@ -247,7 +253,7 @@ def load_fixtures(context, settings_path=None):
|
||||
call_command("loaddata", path + "setting_weight_units.json")
|
||||
|
||||
# Config
|
||||
path = os.path.join(current_dir, 'wger', 'config', 'fixtures/')
|
||||
path = os.path.join(current_dir, 'config', 'fixtures/')
|
||||
call_command("loaddata", path + "language_config.json")
|
||||
call_command("loaddata", path + "gym_config.json")
|
||||
|
||||
@@ -255,20 +261,20 @@ def load_fixtures(context, settings_path=None):
|
||||
# path = os.path.join(current_dir, 'manager', 'fixtures/')
|
||||
|
||||
# Exercises
|
||||
path = os.path.join(current_dir, 'wger', 'exercises', 'fixtures/')
|
||||
path = os.path.join(current_dir, '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, 'wger', 'nutrition', 'fixtures/')
|
||||
path = os.path.join(current_dir, '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, 'wger', 'gym', 'fixtures/')
|
||||
path = os.path.join(current_dir, 'gym', 'fixtures/')
|
||||
call_command("loaddata", path + "gym.json")
|
||||
call_command("loaddata", path + "gym-config.json")
|
||||
call_command("loaddata", path + "gym-adminconfig.json")
|
||||
Reference in New Issue
Block a user