You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
build: migrate to poetry for Python dependency management (#269)
* docs: add instructions for dependency management
* ci: update checkout actions, tox installation and TIOBE schedule
* build: migrate to poetry for dependency management in charm 'argo_controller'
* build: migrate to poetry for dependency management in base project folder
## How to Manage Python Dependencies and Environments
2
+
3
+
4
+
### Prerequisites
5
+
6
+
`tox` is the only tool required locally, as `tox` internally installs and uses `poetry`, be it to manage Python dependencies or to run `tox` environments. To install it: `pipx install tox`.
7
+
8
+
Optionally, `poerty` can be additionally installed independently just for the sake of running Python commands locally outside of `tox` during debugging/development. To install it: `pipx install poetry`.
9
+
10
+
11
+
### Updating Dependencies
12
+
13
+
To add/update/remove any dependencies and/or to upgrade Python, simply:
14
+
15
+
1. add/update/remove such dependencies to/in/from the desired group(s) below `[tool.poetry.group.<your-group>.dependencies]` in `pyproject.toml`, and/or upgrade Python itself in `requires-python` under `[project]`
16
+
17
+
_⚠️ dependencies for the charm itself are also defined as dependencies of a dedicated group called `charm`, specifically below `[tool.poetry.group.charm.dependencies]`, and not as project dependencies below `[project.dependencies]` or `[tool.poetry.dependencies]` ⚠️_
18
+
19
+
2. run `tox -e update-requirements` to update the lock file
20
+
21
+
by this point, `poerty`, through `tox`, will let you know if there are any dependency conflicts to solve.
22
+
23
+
3. optionally, if you also want to update your local environment for running Python commands/scripts yourself and not through tox, see [Running Python Environments](#running-python-environments) below
24
+
25
+
26
+
### Running `tox` Environments
27
+
28
+
To run `tox` environments, either locally for development or in CI workflows for testing, ensure to have `tox` installed first and then simply run your `tox` environments natively (e.g.: `tox -e lint`). `tox` will internally first install `poetry` and then rely on it to install and run its environments.
29
+
30
+
31
+
### Running Python Environments
32
+
33
+
To run Python commands locally for debugging/development from any environments built from any combinations of dependency groups without relying on `tox`:
34
+
1. ensure you have `poetry` installed
35
+
2. install any required dependency groups: `poetry install --only <your-group-a>,<your-group-b>` (or all groups, if you prefer: `poetry install --all-groups`)
36
+
3. run Python commands via poetry: `poetry run python3 <your-command>`
0 commit comments