From d33dc0584062e42c2b8dcb858cf13c0ec9ecbd59 Mon Sep 17 00:00:00 2001 From: mcbloch Date: Fri, 5 Apr 2019 01:25:30 +0200 Subject: [PATCH 01/13] use pip-tools for dependecy management, update setup script --- first-setup.sh | 19 +++++++++----- populate-db.sh | 2 +- requirements.in | 12 +++++++++ requirements.txt | 65 +++++++++++++++++++++++++++++------------------- 4 files changed, 66 insertions(+), 32 deletions(-) create mode 100644 requirements.in diff --git a/first-setup.sh b/first-setup.sh index 12c83b0..95413c7 100755 --- a/first-setup.sh +++ b/first-setup.sh @@ -2,15 +2,22 @@ # A simple file to run all instructions from the README ## this should be run in the root of the repository -if [ ! -d "vent" ]; then +if [ ! -d "venv" ]; then + echo "No venv found, creating a new one" python -m venv venv fi -venv/bin/pip install -r requirements.txt +source venv/bin/activate + +echo "Downloading dependencies" +pip-sync + +echo "Copying config template. All custom config options can be set in the config.py file" cd app cp config.example.py config.py -cp -t . database/* -venv/bin/python create_database.py -rm -f add_* create_database.py -venv/bin/python haldis.py runserver cd .. + +echo "Seeding database" +./populate-db.sh + +echo "You can now run the server with 'python app/haldis.py runserver'" diff --git a/populate-db.sh b/populate-db.sh index 599127f..20c635c 100755 --- a/populate-db.sh +++ b/populate-db.sh @@ -2,5 +2,5 @@ cd app cp database/* . -../venv/bin/python create_database.py +python create_database.py rm -f add_* create_database.py muhscheme diff --git a/requirements.in b/requirements.in new file mode 100644 index 0000000..3a662b0 --- /dev/null +++ b/requirements.in @@ -0,0 +1,12 @@ +Flask +Flask-Login +Flask-Bootstrap +Flask-SQLAlchemy +Flask-DebugToolbar +airbrake +Flask-WTF +Flask-OAuthlib +Flask-Admin +Flask-Migrate +Flask-Script +pip-tools diff --git a/requirements.txt b/requirements.txt index 2d4c041..45ae639 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,25 +1,40 @@ -Flask==0.12 -Flask-Admin==1.4.2 -Flask-Bootstrap==3.3.7.1 -Flask-DebugToolbar==0.10.0 -Flask-Login==0.4.0 -Flask-Migrate==2.0.3 -Flask-OAuthlib==0.9.3 -Flask-SQLAlchemy==2.1 -Flask-Script==2.0.5 -Flask-WTF==0.14.2 -Jinja2==2.9.5 -Mako==1.0.6 -MarkupSafe==0.23 -PyMySQL==0.7.9 -SQLAlchemy==1.1.5 -WTForms==2.1 -Werkzeug==0.11.15 -airbrake==1.3.3 -alembic==0.8.10 -blinker==1.4 -itsdangerous==0.24 -oauthlib==2.0.1 -requests==2.13.0 -requests-oauthlib==0.7.0 -six==1.10.0 +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile +# +airbrake==2.1.2 +alembic==1.0.8 # via flask-migrate +blinker==1.4 # via flask-debugtoolbar +certifi==2019.3.9 # via requests +chardet==3.0.4 # via requests +click==7.0 # via flask, pip-tools +dominate==2.3.5 # via flask-bootstrap +flask-admin==1.5.3 +flask-bootstrap==3.3.7.1 +flask-debugtoolbar==0.10.1 +flask-login==0.4.1 +flask-migrate==2.4.0 +flask-oauthlib==0.9.5 +flask-script==2.0.6 +flask-sqlalchemy==2.3.2 +flask-wtf==0.14.2 +flask==1.0.2 +idna==2.8 # via requests +itsdangerous==1.1.0 # via flask, flask-debugtoolbar +jinja2==2.10 # via flask +mako==1.0.8 # via alembic +markupsafe==1.1.1 # via jinja2, mako +oauthlib==2.1.0 # via flask-oauthlib, requests-oauthlib +pip-tools==3.6.0 +python-dateutil==2.8.0 # via alembic +python-editor==1.0.4 # via alembic +requests-oauthlib==1.1.0 # via flask-oauthlib +requests==2.21.0 # via airbrake, requests-oauthlib +six==1.12.0 # via pip-tools, python-dateutil +sqlalchemy==1.3.2 # via alembic, flask-sqlalchemy +urllib3==1.24.1 # via requests +visitor==0.1.3 # via flask-bootstrap +werkzeug==0.15.2 # via flask, flask-debugtoolbar +wtforms==2.2.1 # via flask-admin, flask-wtf From 4fe2634668e7eaa00eb1029e2a9bd3a3cc8bd732 Mon Sep 17 00:00:00 2001 From: mcbloch Date: Fri, 5 Apr 2019 01:29:48 +0200 Subject: [PATCH 02/13] fix pip-tools dep --- first-setup.sh | 4 +++- requirements.in | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/first-setup.sh b/first-setup.sh index 95413c7..a1fa5bd 100755 --- a/first-setup.sh +++ b/first-setup.sh @@ -6,9 +6,11 @@ if [ ! -d "venv" ]; then echo "No venv found, creating a new one" python -m venv venv fi - source venv/bin/activate +echo "Installing pip-tools" +pip install pip-tools + echo "Downloading dependencies" pip-sync diff --git a/requirements.in b/requirements.in index 3a662b0..b41e92c 100644 --- a/requirements.in +++ b/requirements.in @@ -9,4 +9,3 @@ Flask-OAuthlib Flask-Admin Flask-Migrate Flask-Script -pip-tools From 07895c5e8799ab36ebd14c1f3610eec38177c17c Mon Sep 17 00:00:00 2001 From: mcbloch Date: Fri, 5 Apr 2019 01:48:59 +0200 Subject: [PATCH 03/13] add some nice formatting --- first-setup.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/first-setup.sh b/first-setup.sh index a1fa5bd..198eca1 100755 --- a/first-setup.sh +++ b/first-setup.sh @@ -2,24 +2,31 @@ # A simple file to run all instructions from the README ## this should be run in the root of the repository +bold=$(tput bold) +normal=$(tput sgr0) + +B="\n${bold}" +E="${normal}" + if [ ! -d "venv" ]; then - echo "No venv found, creating a new one" + echo -e "${B} No venv found, creating a new one ${E}" python -m venv venv fi source venv/bin/activate -echo "Installing pip-tools" + +echo -e "${B} Installing pip-tools ${E}" pip install pip-tools -echo "Downloading dependencies" +echo -e "${B} Downloading dependencies ${E}" pip-sync -echo "Copying config template. All custom config options can be set in the config.py file" +echo -e "${B} Copying config template. All custom config options can be set in the config.py file ${E}" cd app cp config.example.py config.py cd .. -echo "Seeding database" +echo -e "${B} Seeding database ${E}" ./populate-db.sh -echo "You can now run the server with 'python app/haldis.py runserver'" +echo -e "${B} Activate your venv using 'source venv/bin/activate'.\nThen run the server with 'python app/haldis.py runserver' ${E}" From 9e4beb7787bed88ae7dd6e90b5a4b6ec0f8b2cb5 Mon Sep 17 00:00:00 2001 From: mcbloch Date: Fri, 5 Apr 2019 02:04:46 +0200 Subject: [PATCH 04/13] update readme with extra docs --- README.md | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2f4fa0c..dc3b8eb 100644 --- a/README.md +++ b/README.md @@ -6,16 +6,29 @@ Start an order and let people add items with a simple mouse-click! No more calculating prices and making lists! Be lazier today! -Local hosting steps -=================== -0. This is a Python 3 project so make sure to use python 3 and pip3 everywhere -1. Run `pip install -r requirements.txt` -2. `cd app` -3. Copy `config.example.py` to `config.py` -4. Copy the python files from `database/` to `app/` (yes, it's sad, I know) -5. Run `python create_database.py` in `app/` (if you want to fill the DB with sample data be sure to answer `Y` to `Do you still want to add something?`) -6. Run `rm -f add_* create_database.py*` in `app/` -7. Run `python haldis.py runserver` +## Local setup ---- -Or run `./first-setup.sh` in the root of the git folder (in linux) +There is a special script to get started with the project. Just run it in the root of the project. + + first-setup.sh + +This will create a virtual environment, install the necessary dependencies and will give you the option to seed the database. + +If you are using a database other then sqlite you will first need to configure the correct uri to the database in the generated 'config.py' file. +Afterwards upgrade the database to the latest version using + + python haldis.py db upgrade + +You can now still seed the database by running + + ./populate-db.sh + +in the root folder of the project. + +## Development + +### Changing the database + +1. Update models located in 'app/models.py' +2. Run `python haldis.py db migrate` to create a new migration. +3. Apply the changes to the database using `python haldis.py db upgrade` From e4b8ae58d64a8c88a14b4f9995c4279e2f0c6d1b Mon Sep 17 00:00:00 2001 From: mcbloch Date: Fri, 5 Apr 2019 02:05:54 +0200 Subject: [PATCH 05/13] typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dc3b8eb..097b86d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Be lazier today! There is a special script to get started with the project. Just run it in the root of the project. - first-setup.sh + ./first-setup.sh This will create a virtual environment, install the necessary dependencies and will give you the option to seed the database. From c68fe1f7b99120e541132e7ce935da760b0662e9 Mon Sep 17 00:00:00 2001 From: mcbloch Date: Fri, 5 Apr 2019 02:12:39 +0200 Subject: [PATCH 06/13] add command to run the server/manage deps --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 097b86d..be6e006 100644 --- a/README.md +++ b/README.md @@ -17,18 +17,27 @@ This will create a virtual environment, install the necessary dependencies and w If you are using a database other then sqlite you will first need to configure the correct uri to the database in the generated 'config.py' file. Afterwards upgrade the database to the latest version using - python haldis.py db upgrade + python app/haldis.py db upgrade You can now still seed the database by running ./populate-db.sh in the root folder of the project. + + +Activate the virtual environment using + + source venv/bin/activate + +Finally run the webserver with + + python app/haldis.py runserver ## Development ### Changing the database 1. Update models located in 'app/models.py' -2. Run `python haldis.py db migrate` to create a new migration. -3. Apply the changes to the database using `python haldis.py db upgrade` +2. Run `python app/haldis.py db migrate` to create a new migration. +3. Apply the changes to the database using `python app/haldis.py db upgrade` From 539e6ff2c46e9bfdbeb6c9e0e078a77ebd487412 Mon Sep 17 00:00:00 2001 From: mcbloch Date: Fri, 5 Apr 2019 02:12:52 +0200 Subject: [PATCH 07/13] add command to run the server/manage deps --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index be6e006..5d0bfde 100644 --- a/README.md +++ b/README.md @@ -41,3 +41,14 @@ Finally run the webserver with 1. Update models located in 'app/models.py' 2. Run `python app/haldis.py db migrate` to create a new migration. 3. Apply the changes to the database using `python app/haldis.py db upgrade` + +### Adding dependencies/libraries + +1. Add new dependency to the `requirements.in` file +2. Run `pip-compile` to add freeze the dependency in the `requirements.txt` file together with it's own deps +3. Run `pip-sync` to download the library + +### Updating dependencies +Run `pip-compile --upgrade` + +For more information about managing the dependencies see [jazzband/pip-tools: A set of tools to keep your pinned Python dependencies fresh.](https://github.com/jazzband/pip-tools) From 807807e0acc18da7a30339ada80a3176e8efa036 Mon Sep 17 00:00:00 2001 From: mcbloch Date: Fri, 5 Apr 2019 02:14:30 +0200 Subject: [PATCH 08/13] update some wording --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5d0bfde..2ada295 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,8 @@ Finally run the webserver with ### Adding dependencies/libraries 1. Add new dependency to the `requirements.in` file -2. Run `pip-compile` to add freeze the dependency in the `requirements.txt` file together with it's own deps -3. Run `pip-sync` to download the library +2. Run `pip-compile` to freeze the dependency into the `requirements.txt` file together with it's own deps +3. Run `pip-sync` to download frozen deps ### Updating dependencies Run `pip-compile --upgrade` From 0910d0c43099bfde890d320eb0b1115b9c9ae20b Mon Sep 17 00:00:00 2001 From: mcbloch Date: Fri, 5 Apr 2019 02:42:49 +0200 Subject: [PATCH 09/13] throw a ton of badges into the readme --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 2ada295..1175ba7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,15 @@ Haldis ======= +[![chat mattermost](https://img.shields.io/badge/chat-mattermost-blue.svg)](https://mattermost.zeus.gent/zeus/channels/haldis) +![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/zeuswpi/haldis.svg) +![GitHub issues](https://img.shields.io/github/issues/zeuswpi/haldis.svg) +![GitHub pull requests](https://img.shields.io/github/issues-pr/zeuswpi/haldis.svg) +![Mozilla HTTP Observatory Grade](https://img.shields.io/mozilla-observatory/grade-score/haldis.zeus.gent.svg?publish) +![Website](https://img.shields.io/website/https/haldis.zeus.gent.svg) +![GitHub commit activity](https://img.shields.io/github/commit-activity/y/zeuswpi/haldis.svg) +![GitHub contributors](https://img.shields.io/github/contributors/zeuswpi/haldis.svg) +![GitHub last commit](https://img.shields.io/github/last-commit/zeuswpi/haldis.svg) +![GitHub top language](https://img.shields.io/github/languages/top/zeuswpi/haldis.svg) Haldis is your friendly neighbourhood servant. He exists so lazy fucks like you and me don't need to keep tabs of who is ordering what from where. Start an order and let people add items with a simple mouse-click! From 5769597a12b8b6fcc2d6af36f25fd4fbd48edd2b Mon Sep 17 00:00:00 2001 From: mcbloch Date: Fri, 5 Apr 2019 02:45:21 +0200 Subject: [PATCH 10/13] more readable --- README.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1175ba7..8649464 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,23 @@ Haldis ======= +- Contact [![chat mattermost](https://img.shields.io/badge/chat-mattermost-blue.svg)](https://mattermost.zeus.gent/zeus/channels/haldis) -![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/zeuswpi/haldis.svg) -![GitHub issues](https://img.shields.io/github/issues/zeuswpi/haldis.svg) -![GitHub pull requests](https://img.shields.io/github/issues-pr/zeuswpi/haldis.svg) + +- Website ![Mozilla HTTP Observatory Grade](https://img.shields.io/mozilla-observatory/grade-score/haldis.zeus.gent.svg?publish) ![Website](https://img.shields.io/website/https/haldis.zeus.gent.svg) -![GitHub commit activity](https://img.shields.io/github/commit-activity/y/zeuswpi/haldis.svg) -![GitHub contributors](https://img.shields.io/github/contributors/zeuswpi/haldis.svg) -![GitHub last commit](https://img.shields.io/github/last-commit/zeuswpi/haldis.svg) + +- Stats ![GitHub top language](https://img.shields.io/github/languages/top/zeuswpi/haldis.svg) +![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/zeuswpi/haldis.svg) + +- Repo activity +![GitHub issues](https://img.shields.io/github/issues/zeuswpi/haldis.svg) +![GitHub pull requests](https://img.shields.io/github/issues-pr/zeuswpi/haldis.svg) +![GitHub contributors](https://img.shields.io/github/contributors/zeuswpi/haldis.svg) + +![GitHub last commit](https://img.shields.io/github/last-commit/zeuswpi/haldis.svg) +![GitHub commit activity](https://img.shields.io/github/commit-activity/y/zeuswpi/haldis.svg) Haldis is your friendly neighbourhood servant. He exists so lazy fucks like you and me don't need to keep tabs of who is ordering what from where. Start an order and let people add items with a simple mouse-click! From 1a5ac94d6b4ce4e5439091b10af29086973c3599 Mon Sep 17 00:00:00 2001 From: mcbloch Date: Fri, 5 Apr 2019 02:47:08 +0200 Subject: [PATCH 11/13] remove less import badges --- README.md | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/README.md b/README.md index 8649464..50e4fad 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,13 @@ Haldis ======= -- Contact [![chat mattermost](https://img.shields.io/badge/chat-mattermost-blue.svg)](https://mattermost.zeus.gent/zeus/channels/haldis) -- Website ![Mozilla HTTP Observatory Grade](https://img.shields.io/mozilla-observatory/grade-score/haldis.zeus.gent.svg?publish) ![Website](https://img.shields.io/website/https/haldis.zeus.gent.svg) -- Stats -![GitHub top language](https://img.shields.io/github/languages/top/zeuswpi/haldis.svg) -![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/zeuswpi/haldis.svg) - -- Repo activity +![GitHub last commit](https://img.shields.io/github/last-commit/zeuswpi/haldis.svg) ![GitHub issues](https://img.shields.io/github/issues/zeuswpi/haldis.svg) ![GitHub pull requests](https://img.shields.io/github/issues-pr/zeuswpi/haldis.svg) -![GitHub contributors](https://img.shields.io/github/contributors/zeuswpi/haldis.svg) - -![GitHub last commit](https://img.shields.io/github/last-commit/zeuswpi/haldis.svg) ![GitHub commit activity](https://img.shields.io/github/commit-activity/y/zeuswpi/haldis.svg) Haldis is your friendly neighbourhood servant. He exists so lazy fucks like you and me don't need to keep tabs of who is ordering what from where. From c9e0857ae0db289343d341c6ff90f708a7a1e3cb Mon Sep 17 00:00:00 2001 From: mcbloch Date: Fri, 5 Apr 2019 02:48:24 +0200 Subject: [PATCH 12/13] more on one line? --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 50e4fad..c07d678 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ Haldis ======= -[![chat mattermost](https://img.shields.io/badge/chat-mattermost-blue.svg)](https://mattermost.zeus.gent/zeus/channels/haldis) - -![Mozilla HTTP Observatory Grade](https://img.shields.io/mozilla-observatory/grade-score/haldis.zeus.gent.svg?publish) +[![chat mattermost](https://img.shields.io/badge/chat-mattermost-blue.svg)](https://mattermost.zeus.gent/zeus/channels/haldis) | ![Website](https://img.shields.io/website/https/haldis.zeus.gent.svg) +![Mozilla HTTP Observatory Grade](https://img.shields.io/mozilla-observatory/grade-score/haldis.zeus.gent.svg?publish) ![GitHub last commit](https://img.shields.io/github/last-commit/zeuswpi/haldis.svg) ![GitHub issues](https://img.shields.io/github/issues/zeuswpi/haldis.svg) From 55d3c111151f2e6869d989f27ba5e3b4d32e381c Mon Sep 17 00:00:00 2001 From: mcbloch Date: Fri, 5 Apr 2019 02:48:58 +0200 Subject: [PATCH 13/13] vert line is ugly --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c07d678..affbfb6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Haldis ======= -[![chat mattermost](https://img.shields.io/badge/chat-mattermost-blue.svg)](https://mattermost.zeus.gent/zeus/channels/haldis) | +[![chat mattermost](https://img.shields.io/badge/chat-mattermost-blue.svg)](https://mattermost.zeus.gent/zeus/channels/haldis) ![Website](https://img.shields.io/website/https/haldis.zeus.gent.svg) ![Mozilla HTTP Observatory Grade](https://img.shields.io/mozilla-observatory/grade-score/haldis.zeus.gent.svg?publish)