-
-
Notifications
You must be signed in to change notification settings - Fork 394
Add poetry dependency manager and package builder #368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
713ea54
cbbc453
cd2dfb2
08dd179
ef51164
32e9c07
a2f9b7c
bb8558c
825af51
62df241
78af477
b5fd573
3cc87cf
6f2004a
a06e90d
945b20c
f98d2f6
15e427e
3b24911
97c7337
e8f66a9
f59ad99
f561374
4a69f11
4b82769
50e05a3
48de3e0
4b1f52a
7f6ac4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,13 +29,43 @@ Thank you so much for showing interest in contributing to TagStudio! Here are a | |
|
||
### Prerequisites | ||
|
||
- [Python](https://www.python.org/downloads/) 3.12 | ||
- [Ruff](https://github.com/astral-sh/ruff) (Included in `requirements-dev.txt`) | ||
- [Mypy](https://github.com/python/mypy) (Included in `requirements-dev.txt`) | ||
- [PyTest](https://docs.pytest.org) (Included in `requirements-dev.txt`) | ||
- [Python](https://www.python.org/downloads/) 3.12 | ||
- [Poetry](https://python-poetry.org/docs/) | ||
- [Ruff](https://github.com/astral-sh/ruff) (Included in `requirements-dev.txt`) | ||
- [Mypy](https://github.com/python/mypy) (Included in `requirements-dev.txt`) | ||
- [PyTest](https://docs.pytest.org) (Included in `requirements-dev.txt`) | ||
|
||
> [!TIP] | ||
> On Linux and macOS, you can launch the `tagstudio.sh` script to skip the following process, minus the `requirements-dev.txt` installation step. _Using the script is fine if you just want to launch the program from source._ | ||
|
||
### Creating a Python Virtual Environment | ||
|
||
There are two ways to create a virtual Environment. | ||
Using a poetry or using pyvenv. | ||
|
||
#### Poetry | ||
|
||
After installing poetry and python you can install the dependencies with the following command: | ||
|
||
```shell | ||
poetry install | ||
``` | ||
|
||
If you plan to make a pull request or develop the code run this instead to also install the dev dependencies: | ||
|
||
```shell | ||
poetry install --with dev | ||
``` | ||
You should run these (or any other poetry command) at the root of the project where the pyproject.toml file is located. | ||
|
||
You can start tag studio with: | ||
|
||
```shell | ||
poetry run tagstudio | ||
``` | ||
|
||
#### Pyvenv | ||
|
||
If you wish to launch the source version of TagStudio outside of your IDE: | ||
|
||
> [!IMPORTANT] | ||
|
@@ -44,6 +74,7 @@ If you wish to launch the source version of TagStudio outside of your IDE: | |
> [!TIP] | ||
> On Linux and macOS, you can launch the `tagstudio.sh` script to skip the following process, minus the `requirements-dev.txt` installation step. _Using the script is fine if you just want to launch the program from source._ | ||
|
||
If you plan to make a pull request or develop the code run this instead to also install the dev dependencies: | ||
1. Make sure you're using the correct Python version: | ||
- If the output matches `Python 3.12.x` (where the x is any number) then you're using the correct Python version and can skip to step 2. Otherwise, you can install the correct Python version from the [Python](https://www.python.org/downloads/) website, or you can use a tool like [pyenv](https://github.com/pyenv/pyenv/) to install the correct version without changes to your system: | ||
1. Follow pyenv's [install instructions](https://github.com/pyenv/pyenv/?tab=readme-ov-file#installation) for your system. | ||
|
@@ -66,7 +97,6 @@ If you wish to launch the source version of TagStudio outside of your IDE: | |
|CSH/TCSH|`.venv/bin/activate.csh` | | ||
|PWSH |`.venv/bin/activate.ps1` | | ||
|
||
|
||
4. Install the required packages: | ||
|
||
- `pip install -r requirements.txt` | ||
|
@@ -76,7 +106,14 @@ _Learn more about setting up a virtual environment [here](https://docs.python.or | |
|
||
### Manually Launching (Outside of an IDE) | ||
|
||
If you encounter errors about the Python version, or seemingly vague script errors, [pyenv](https://github.com/pyenv/pyenv/) may solve your issue. See step 1 of [Creating a Python Virtual Environment](#creating-a-python-virtual-environment). | ||
|
||
If you are using poetry just run | ||
|
||
```shell | ||
poetry run tagstudio | ||
``` | ||
|
||
You can also use the following scripts: | ||
|
||
- **Windows** (start_win.bat) | ||
|
||
|
@@ -96,9 +133,13 @@ If you encounter errors about the Python version, or seemingly vague script erro | |
|
||
- Alternatively, with the virtual environment loaded, run the python file at `tagstudio\tag_studio.py` from your terminal. If you're in the project's root directory, simply run `python3 tagstudio/tag_studio.py`. | ||
|
||
If you encounter errors about the Python version, or seemingly vague script errors, [pyenv](https://github.com/pyenv/pyenv/) may solve your issue. See step 1 of [Creating a Python Virtual Environment](#creating-a-python-virtual-environment). | ||
|
||
## Workflow Checks | ||
|
||
When pushing your code, several automated workflows will check it against predefined tests and style checks. It's _highly recommended_ that you run these checks locally beforehand to avoid having to fight back-and-forth with the workflow checks inside your pull requests. | ||
These tools are installed into your environment if you ran `poetry install --with dev`. | ||
You can run the tools by prepending `poetry run` to the command. Like `poetry run ruff`. | ||
|
||
> [!TIP] | ||
> To format the code automatically before each commit, there's a configured action available for the `pre-commit` hook. Install it by running `pre-commit install`. The hook will be executed each time on running `git commit`. | ||
|
@@ -189,6 +230,27 @@ Most of the style guidelines can be checked, fixed, and enforced via Ruff. Older | |
- Cause unreasonable slowdowns to the program outside of a progress-indicated task | ||
- Cause undesirable visual glitches or artifacts on screen | ||
|
||
#### Adding dependencies | ||
|
||
If you want to add a dependency to the project use `poetry add <dependency-name>`. | ||
For example: `poetry add httpx`. | ||
If you decide you did not want to add the dependency after all you can use `poetry remove <dependency-name>`. | ||
|
||
If you decide to commit this change be sure to also update the requirements.txt file by generating it from the pyproject.toml with: | ||
|
||
```shell | ||
poetry export --without-hashes --format=requirements.txt > requirements.txt | ||
``` | ||
|
||
If you want to add a dev dependency instead use: `poetry add <name> --group dev`. | ||
To regenerate the requirements-dev.txt use: | ||
|
||
```shell | ||
poetry export --without-hashes --without main --with dev --format=requirements.txt > requirements-dev.txt | ||
``` | ||
|
||
Do not forget to actually commit the updated requirement.txt and pyproject.toml and poetry.lock files when you change/add dependencies. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an important detail missing from this MD file. The explanation of what the lock file is. The troublesome command When you add a new dependencies, poetry will use the caret symbol, I personally dislike this behaviour as it is implicit in nature. Are future dependencies going to follow the pinned nature of the repo? I don't know, but poetry will update the pyproject.toml file as it sees best. This might lead to trouble and worth a note in the readme. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The section you comment on explains how to add dependencies. The reader does not need to know what the I could add a sentence saying that it is better to pin a specific version of a dependency There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a thing I have seen many times in projects that start using poetry. I don't mind the sections that are already added. Im saying I think this detail is missing. It has burned many people in projects I have worked on the past years. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you suggest a text? Like there is not more to it then the poetry.lock pins the versions of each dependency so you get reproducible builds. |
||
## Documentation Guidelines | ||
|
||
Documentation contributions include anything inside of the `docs/` folder, as well as the `README.md` and `CONTRIBUTING.md` files. Documentation inside the `docs/` folder is built and hosted on our static documentation site, [docs.tagstud.io](https://docs.tagstud.io/). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im in favor of sharing one way to install a tool if there is consensus to use it. I use poetry daily, there are many things I don't like about it, but it makes the interface we use the same for all developers, no matter what platform you are on.
Currently the recommended way to install poetry is by using
pipx
this is a tool that is recommended for python devs to have, but it is yet another install process to document.Im happy write the changes needed if that is something you would like me to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not clear to me what changes you are actually suggesting here. @eivl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pipx install poetry
is the command to install poetry. the docs has multiple other ways to install it, but I'm in favor of front loading the information instead of back loading it with more links to click on.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so just adding
pipx install poetry
in CONTRIBUTING.md with some text?