Skip to content

Commit abc7cc3

Browse files
docs: improve python and venv setup instructions in CONTRIBUTING.md (#791)
* docs: refer to pyenv in CONTRIBUTING.md This commit was made in order to account for users who may already have a Python installation that isn't 3.12. A good real world scenario where this may be a problem is users running on rolling release Linux distributions, such as Arch Linux which provides bleeding edge updates in a weekly basis. Continuing with Arch Linux as an example, it provides Python 3.13, which the current version of TagStudio doesn't seem to work with, an issue I encountered myself this morning. In some systems like Windows, this may not matter, but it is an issue nonetheless, and users using a package manager centric system can't be expected to downgrade/upgrade their Python version for TagStudio, as this may cause issues in their system. The easiest way to solve this is with pyenv, which enables users to install other Python versions independent from each other, aside from the system install, and allows specifying a version to use for a directory (And its subdirectories), the current terminal session, or the entire system if desired. Here is a short, technical and objective summary of the changes: - Updated `.gitignore` to to ignore `.python-version` which pyenv uses. - Updated CONTRIBUTING.md to refer to pyenv for versioning issues. - pyenv is listed as a prerequisite, specifying in parenthesis that it's only for when your Python install isn't 3.12. - The "Creating a Python Virtual Environment" section now has an additional step at the beginning, to check that the current Python installation is 3.12. - As part of this added step, there are steps to use pyenv to install Python 3.12 separately from the existing Python installation, and activate it for the TagStudio root folder, in case it's not the appropriate version. - The numbering of the other steps was offset accordingly. - The "Manually Launching (Outside of an IDE)" section now refers to the above first step, should the user encounter some kind of error. * docs: refer to alternate shells in CONTRIBUTING.md Some users may not be using the default shell for their system, and Linux users are the most likely to do this, though this can be seen in macOS as well. People will often use shells like fish which is not POSIX compliant but works very well and has great auto-completion, it's very user friendly. The reason why I care about this is that the instructions specify to use .venv/bin/activate which is a bash script and will not run on fish or csh, and if you take a look at the script, indeed it says it will only run with bash. Python will provide alternate scripts for other shells, and at least on my system (CachyOS), those are scripts for Powershell, bash, fish and csh. People using these alternate shells, who don't know this may be confused when running the script referenced in CONTRIBUTING.md and seeing it fail completely. The only real change in this commit was adding under the "Linux/macOS" command in step 3 (step 2 prior to my last commit) of the "Creating a Python Virtual Environment" section, a short instruction to switch to the default shell, or use the appropriate script for the user's preferred shell if any (Since, at least on my system, there aren't scripts for every shell, for example there is no activate.zsh file). * fix: modal windows now have the Qt.Dialog flag Set the Qt.Dialog flag for modal windows, such as "Add Field" so that they will be seen as dialogs in the backend. This change is unlikely to be at all noticeable in systems like Windows, but for users running tiling window managers like bspwm or Sway, this will prevent these modal windows from being tiled alongside the main window, instead they will be floating on top, which is the expected behaviour seen on floating window managers, like the ones used by Windows and macOS. Added self.setWindowFlag(Qt.Dialog, on=True) # type: ignore to the following files: - tagstudio/src/qt/modals/add_field.py - tagstudio/src/qt/modals/delete_unlinked.py - tagstudio/src/qt/modals/drop_import.py - tagstudio/src/qt/modals/file_extension.py - tagstudio/src/qt/modals/fix_dupes.py - tagstudio/src/qt/modals/fix_unlinked.py - tagstudio/src/qt/modals/folders_to_tags.py - tagstudio/src/qt/modals/mirror_entities.py - tagstudio/src/qt/widgets/paged_panel/paged_panel.py - tagstudio/src/qt/widgets/panel.py - tagstudio/src/qt/widgets/progress.py Note that without adding # type: ignore, MyPy *will* give out an error, presumably because PySide6 is missing type hints for several things, and this may *or* may not be a justifiable use of # type: ignore, which throws the MyPy type checking for that line out the window. Ref: #392, #464 * fix: I forgot to run ruff format * revert: changes to docs and gitignore This revert is for moving the referenced changes to their own pull request. Refs: 15f4f38, a25ef8c * docs: other shells and pyenv in CONTRIBUTING.md This commit changes CONTRIBUTING.md to refer to pyenv in the case of issues with Python versions, as well as downloading the correct version off of the Python website alternatively. It also now elaborates on the process of running the Python virtual environment on Linux and macOS, by referencing activation scripts for alternative shells such as fish and CSH. The table added to CONTRIBUTING.md is taken from the official Python documentation: https://docs.python.org/3.12/library/venv.html * revert: accidental inclution of #464 Refs: a51550f, 5854ccc
1 parent a3df70b commit abc7cc3

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ profile_default/
8888
ipython_config.py
8989

9090
# pyenv
91-
# For a library or package, you might want to ignore these files since the code is
92-
# intended to run in multiple environments; otherwise, check them in:
93-
# .python-version
91+
.python-version
9492

9593
# pipenv
9694
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.

CONTRIBUTING.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,30 @@ If you wish to launch the source version of TagStudio outside of your IDE:
4444
> [!TIP]
4545
> 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._
4646
47-
1. In the root repository directory, create a python virtual environment:
47+
1. Make sure you're using the correct Python version:
48+
- 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:
49+
1. Follow pyenv's [install instructions](https://github.com/pyenv/pyenv/?tab=readme-ov-file#installation) for your system.
50+
2. Install the appropriate Python version with pyenv by running `pyenv install 3.12` (This will **not** mess with your existing Python installation).
51+
3. Navigate to the repository root folder in your terminal and run `pyenv local 3.12`.
52+
- You could alternatively use `pyenv shell 3.12` or `pyenv global 3.12` instead to set the Python version for the current terminal session or the entire system respectively, however using `local` is recommended.
53+
54+
2. In the root repository directory, create a python virtual environment:
4855
`python3 -m venv .venv`
49-
2. Activate your environment:
56+
3. Activate your environment:
5057

5158
- Windows w/Powershell: `.venv\Scripts\Activate.ps1`
5259
- Windows w/Command Prompt: `.venv\Scripts\activate.bat`
5360
- Linux/macOS: `source .venv/bin/activate`
61+
Depending on your system, the regular activation script *might* not work on alternative shells. In this case, refer to the table below for supported shells:
62+
|Shell |Script |
63+
|-------:|:------------------------|
64+
|Bash/ZSH|`.venv/bin/activate` |
65+
|Fish |`.venv/bin/activate.fish`|
66+
|CSH/TCSH|`.venv/bin/activate.csh` |
67+
|PWSH |`.venv/bin/activate.ps1` |
68+
5469

55-
3. Install the required packages:
70+
4. Install the required packages:
5671

5772
- `pip install -r requirements.txt`
5873
- If developing (includes Ruff and Mypy): `pip install -r requirements-dev.txt`
@@ -61,6 +76,8 @@ _Learn more about setting up a virtual environment [here](https://docs.python.or
6176

6277
### Manually Launching (Outside of an IDE)
6378

79+
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).
80+
6481
- **Windows** (start_win.bat)
6582

6683
- To launch TagStudio, launch the `start_win.bat` file. You can modify this .bat file or create a shortcut and add one or more additional arguments if desired.

0 commit comments

Comments
 (0)