Skip to content

Environment and dependencies

Pierre Wan-Fat edited this page May 6, 2020 · 4 revisions

Python environment

Download and install the most recent version of Python from https://www.python.org (3.7 or newer). In Windows, agree when the Python installer asks you to add Python to the PATH. After the installation, if you type python from the command line, this should run the version you have just installed.

We'll use venv to create a virtual environment. Set it up:

cd path/to/project/Portail-des-eleves/backend
python -m venv venv

Then, activate the virtual environment: use source venv/bin/activate on Mac or Linux, venv\Scripts\activate.bat on Windows. There should be a (venv) at the beginning of each line in your command prompt.

Finally, install the dependencies with pip install -r requirements.txt. requirements.txt is a file listing the dependencies used in the project — as well as their exact version, which is even more important.

Missing dependencies

Missing dependencies can be installed using pip install <package>. You will then want to update requirements.txt by running pip freeze > requirements.txt (in the backend folder).

npm environment

On the frontend side, all the required dependencies (specified in package.json) can be installed with npm.

cd frontend/
npm install

You can then run the app with npm run start.

package-lock.json

The package-lock.json file should be commited.

Upgrading packages

If the version of one of the dependencies used in the project changed, you will need to upgrade the dependencies. Just run:

npm install

Managing dependencies

If you need to add a dependency or change the version of one of the dependencies, edit the frontend/package.json. Here is a quick guide to the semver convention used by package.json.