Skip to content

[updates] specify python version #2933

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ coverage/
venv/
/pyvenv.cfg
/pip-selfcheck.json
.python-version

# Node
node_modules/
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11.6
Copy link
Contributor

@m4ra m4ra Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I use pyenv for versions, and pyenv for virtualenv, so this file points to the name of my pyenv's virtualenv, e.g named root which is located in .pyenv/versions/(venv) and that's why cannot be deleted with the make clean command. Hence, I don't think the solution here is inclusive enough approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you say a little more? The make install command uses python3 -m venv $(VIRTUAL_ENV); so our clean script deletes this venv. What additional behavior would you expect?

11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ VIRTUAL_ENV ?= venv
NODE_BIN = node_modules/.bin
SOURCE_DIRS = adhocracy-plus apps tests
ARGUMENTS=$(filter-out $(firstword $(MAKECMDGOALS)), $(MAKECMDGOALS))
PYTHON_MIN_VERSION = 3.11
PYTHON_MAX_VERSION = 3.13

# for mac os gsed is needed (brew install gnu-sed and brew install gsed)
SED = sed
Expand Down Expand Up @@ -57,9 +59,16 @@ help:

.PHONY: install
install:
if [ ! -f $(VIRTUAL_ENV)/bin/python3 ]; then python3 -m venv $(VIRTUAL_ENV); fi
@python_version=`$(VIRTUAL_ENV)/bin/python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))'`; \
if echo "$$python_version" | awk -F. -v min="$(PYTHON_MIN_VERSION)" -v max="$(PYTHON_MAX_VERSION)" \
'{ if ($$1 == 3 && $$2 >= min && $$2 < max) print "yes" }' | grep -q yes; then \
echo "Python version $$python_version is compatible"; \
else \
echo "Warning: Python version $$python_version detected. This project requires Python >= $(PYTHON_MIN_VERSION) and < $(PYTHON_MAX_VERSION)"; \
fi
npm install --no-save
npm run build
if [ ! -f $(VIRTUAL_ENV)/bin/python3 ]; then python3 -m venv $(VIRTUAL_ENV); fi
$(VIRTUAL_ENV)/bin/python -m pip install --upgrade -r requirements/dev.txt
$(VIRTUAL_ENV)/bin/python manage.py migrate

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ adhocracy+ is designed to make online participation easy and accessible to every
### Requirements

* nodejs (+ npm)
* python 3.x (+ venv + pip)
* python>=3.11,<3.13
* We recommend using pyenv or similar to run a supported python version.
* The latest supported version is listed in `.python-version`, which pyenv will automatically follow.
* libpq (only if postgres should be used)
* sqlite3 [with JSON1 enabled](https://code.djangoproject.com/wiki/JSON1Extension)
* redis (in production, not needed for development)
* pillow-heif (required for macOS M1 Monterey and newer versions)
* libmagic (macOS users will need to install, for example with `brew install libmagic`)

### Installation

Expand Down
8 changes: 8 additions & 0 deletions changelog/0001.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Added

- Specify python version in new .python-version file, which pyenv ingests

### Changed

- README mentions supported python versions
- `make install` will now output a warning if the dev user is running a non-supported python version
Loading