diff --git a/.gitlab/server.gitlab-ci.yml b/.gitlab/server.gitlab-ci.yml index 30b257e7bcedb3f6999f6902643874add5859449..5a7d27742e95ec4ce5d9d887027caf2224237b65 100644 --- a/.gitlab/server.gitlab-ci.yml +++ b/.gitlab/server.gitlab-ci.yml @@ -11,7 +11,7 @@ server:setup: expire_in: 15 min untracked: true cache: - key: "$CI_COMMIT_REF_SLUG" + key: '$CI_COMMIT_REF_SLUG' paths: - server/env script: @@ -20,12 +20,12 @@ server:setup: - cd server/ - python -m venv env - source env/bin/activate - - pip install -r requirements.txt + - pip install -r requirements-dev.txt server:test: image: python stage: test - needs: ["server:setup"] + needs: ['server:setup'] only: refs: - dev @@ -43,7 +43,7 @@ server:test: server:report: image: python stage: report - needs: ["server:test"] + needs: ['server:test'] only: refs: - merge_requests diff --git a/docs/source/installation/server.md b/docs/source/installation/server.md index 889c2465904a75dd53e19c1c5e83b149b3d05eb6..44a9345e540af8f0728599e95213699c8a896677 100644 --- a/docs/source/installation/server.md +++ b/docs/source/installation/server.md @@ -1,13 +1,21 @@ # Installing the server -It is recommended to use [Visual Studio Code](https://code.visualstudio.com/) to install and use the server, but it is not necessary. -In order to install the server, you will need to do the following: +The steps to install the server depend on if you are on Windows or Linux and if you are a developer or are running it in production. + +## Windows + +Clone the Git [repository](https://gitlab.liu.se/tddd96-grupp11/teknikattan-scoring-system): + +```bash +git clone https://gitlab.liu.se/tddd96-grupp11/teknikattan-scoring-system +cd ./teknikattan-scoring-system/ +``` Install [Python](https://www.python.org/downloads/). -Clone the git repository [teknikattan-scoring-system](https://gitlab.liu.se/tddd96-grupp11/teknikattan-scoring-system). +Make sure `Python` is [installed properly](#running-python). -Open a terminal and navigate to the root of the cloned project. +Make sure `pip` is [installed properly](#running-pip). Install virtualenv and create a virtual environment: @@ -17,28 +25,133 @@ cd server py -m venv env ``` -Activate the virtual environment (which is done slightly differently on Windows and Linux/Mac): - -On Windows: +Activate the virtual environment: ```bash Set-ExecutionPolicy Unrestricted -Scope Process ./env/Scripts/activate ``` -On Linux/Mac: +Continue to [development and production](#development-and-production). + +## Linux (Ubuntu) + +Clone the Git [repository](https://gitlab.liu.se/tddd96-grupp11/teknikattan-scoring-system): + +```bash +git clone https://gitlab.liu.se/tddd96-grupp11/teknikattan-scoring-system +cd ./teknikattan-scoring-system/ +``` + +Install [Python](https://www.python.org/downloads/). + +Make sure `Python` is [installed properly](#running-python). + +Install pip: + +```bash +sudo apt install python3-pip +``` + +Make sure `pip` is [installed properly](#running-pip). + +Install and create a Python virutal environment and activate it: ```bash +sudo apt install python3-venv +cd server +py -m venv env source env/bin/activate ``` -Lastly, install all project dependencies: +Continue to [development and production](#development-and-production). + +## Development and production + +Which dependencies you install will depend on if you are a developer or running the server in production. + +If running in production: ```bash pip install -r requirements.txt ``` +If you are a developer: + +```bash +pip install -r requirements-dev.txt +``` + You should now be ready to start the server. -Try it by running `python main.py` and navigate to `localhost:5000`. +Try it by running `py main.py` and navigate to `localhost:5000`. If everything worked as it should you should see a list of all available API calls. If you are using VS Code you can also start the server with the [task](../development/vscode.md) `start server`. + +## Common issues + +If you have any issues while installing, some of the things below might help. + +### Running Python + +Test that Python is installed properly: + +```bash +py --version +``` + +Make sure Python version > 3. +If it works, you should see something along the lines of: + +```bash +Python 3.9.4 +``` + +If `py` is not working, try one of the following instead: + +``` +py -3 +py3 +python +python3 +``` + +### Running pip + +Test that `pip` is installed properly: + +```bash +pip --version +``` + +Make sure pip is running with Python 3.x (not Python 2.x). +If everything works, it should look something along the lines of: + +``` +pip 20.2.3 from d:\home\workspace\teknikattan-scoring-system\server\env\lib\site-packages\pip (python 3.9) +``` + +If `pip` is not running with Python 3.x, try one of the following instead: + +``` +pip3 +py -m pip +``` + +If you still have trouble, try this [guide](https://pip.pypa.io/en/stable/installing/). + +### Problem: Failed building wheel for \<package\> when calling pip + +Run the following command before installing the requirements: + +``` +pip install wheel +``` + +This [guide](https://stackoverflow.com/questions/53204916/what-is-the-meaning-of-failed-building-wheel-for-x-in-pip-install) +can help you troubleshoot this problem further. + +### Problem: psycopg + +``` +pip install psycopg2 +``` diff --git a/server/README.md b/server/README.md index 864cc0049bb088d1b5ab43875c7175999b1608e0..cbb1e0222698728b2648ce0c31ffc06b35edc2c6 100644 --- a/server/README.md +++ b/server/README.md @@ -65,6 +65,10 @@ pip install -r requirements.txt ``` +The last step is to install all the required packages. +If you are running it in production, run `pip install -r requirements.txt`. +But if you are a developer, run `pip install -r requirements-dev.txt`. + ## Common problems ### Make sure python +3.8 is running with the python command diff --git a/server/requirements-dev.txt b/server/requirements-dev.txt new file mode 100644 index 0000000000000000000000000000000000000000..78e0bc63cccd764964148bd7955a2f99df02ccca Binary files /dev/null and b/server/requirements-dev.txt differ diff --git a/server/requirements.txt b/server/requirements.txt index bcb325f5f3a16a5ee0e655435923c38d8926b807..a8b73f433e1c0853e80d3ad9bb5ca72af77aeca7 100644 Binary files a/server/requirements.txt and b/server/requirements.txt differ