| Branch | Status |
|---|---|
| develop | |
| main |
service-control provides and manages the verified permissions. TBC
Prerequisites on host for development and build:
- python version 3.13
- pipenv
dockeranddocker compose
To create and activate a virtual Python environment with all dependencies installed:
make setupTo start the local postgres container, run this:
make start-local-dbYou may want to do an initial sync of your database by applying the most recent Django migrations with
app/manage.py migrateYou may also want to add a local superuser
app/manage.py createsuperuserAll packages used in production are pinned to a major version. Automatically updating these packages will use the latest minor (or patch) version available. Packages used for development, on the other hand, are not pinned unless they need to be used with a specific version of a production package (for example, boto3-stubs for boto3).
To update the packages to the latest minor/compatible versions, run:
pipenv update --devTo see what major/incompatible releases would be available, run:
pipenv update --dev --outdatedTo update packages to a new major release, run:
pipenv install logging-utilities~=5.0Run tests with, for example, 16 workers:
pytest -n 16There are some possibilities to debug this codebase from within visual studio code.
In order to debug the service from within vs code, you need to create a launch-configuration. Create
a folder .vscode in the root folder if it doesn't exist and put a file launch.json with this content
in it:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Attach",
"type": "debugpy",
"request": "attach",
"justMyCode": false,
"connect": {
"host": "localhost",
"port": 5678
}
}
]
}Alternatively, create the file via menu "Run" > "Add Configuration" by choosing
- Debugger: Python Debugger
- Debug Configration: Remote Attach
- Hostname:
localhost - Port number:
5678
Now you can start the server with make serve-debug.
The bootup will wait with the execution until the debugger is attached, which can most easily done by hitting F5.
The unit tests can also be invoked inside vs code directly (beaker icon).
To do this you need to have the following settings either in
.vscode/settings.json or in your workspace settings:
"python.testing.pytestArgs": [
"app"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,You can also create this file interactively via menu "Python: Configure Tests" in the Command Palette (Ctrl+Shift+P).
For the automatic test discovery to work, make sure that vs code has the Python
interpreter of your venv selected (.venv/bin/python).
You can change the Python interpreter via menu "Python: Select Interpreter"
in the Command Palette.
Type checking can be done by either calling mypy or the make target:
make type-checkThis will check all files in the repository.
For type-checking, the external library mypy is being used. See the type hints cheat sheet for help on getting the types right.
Some 3rd party libraries need to have explicit type stubs installed for the type checker to work. Some of them can be found in typeshed. Sometimes dedicated packages exist, as is the case with django-stubs.
If there aren't any type hints available, they can also be auto-generated with stubgen