Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d8d3c82

Browse files
adam-grant-hendryLee-W
authored andcommitted
feat(scripts): remove venv/bin/
Commit `d936262e` switched the `test` script to use `cz` instead of `commitizen`, but forgot the prefix to the command is `poetry run python -m`, which looks for a python module. `cz` is not a module: it is an entry point script (specified in the `pyproject.toml` table `[tool.poetry.scripts]`). Switching `$PREFIX` to `venv/bin/` creates two problems: - The subdirectory `venv` creates differs depending on OS. On Linux/MacOS, the subdirectory containing copies/symlinks to Python binaries is `bin`, but on Windows it is `Scripts`. Similiarly, the `site-packages` directory on Linux/MacOS is `lib/pythonX.Y/site-packages`, but on Windows it is `Lib\site-packages`. See: https://docs.python.org/3/library/venv.html#module-venv - Since `commitizen` isn't the entry-point script, but rather `cz`, the command `venv/bin/commitizen` will fail on Linux/MacOS and Windows. Poetry will check to see if it is currently running inside a virtual environment, and if it is, it will use it directly without creating a new one. If it isn't, it will use one that it has already created or create a brand new one for you. See: https://python-poetry.org/docs/managing-environments/ A better solution than switching the prefix would be to activate the virtual environment. However, users can create virtual environments with any name they choose (`venv/`, `.venv/`, or otherwise). In addition, they can specify whether or not `poetry` should create a virtual environment in the project folder `virtualenvs.in-project`), or at all (`virtualenvs.create`). Since switching to `venv/bin` only affects developers running scripts locally (the GitHub Actions CI scripts run `poetry install` and let it manage the virtual environment), it's best to remove changing the `$PREFIX` and instead add instructions to `README`/`CONTRIBUTING`/etc. to tell users to configure `poetry` and activate their virtual environment appropriately if running these scripts locally.
1 parent dd74977 commit d8d3c82

File tree

2 files changed

+1
-30
lines changed

2 files changed

+1
-30
lines changed

scripts/format

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,6 @@ set -e
33

44
export PREFIX="poetry run python -m "
55

6-
if [ -d 'venv' ] ; then
7-
case $(uname -s) in
8-
Linux|FreeBSD|OpenBSD|NetBSD|Darwin)
9-
export PREFIX="venv/bin/"
10-
;;
11-
*MINGW*)
12-
export PREFIX="venv/Scripts/"
13-
;;
14-
*)
15-
exit 1
16-
;;
17-
esac
18-
fi
19-
206
set -x
217

228
${PREFIX}isort commitizen tests

scripts/test

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,10 @@ set -e
33

44
export PREFIX="poetry run python -m "
55

6-
if [ -d 'venv' ] ; then
7-
case $(uname -s) in
8-
Linux|FreeBSD|OpenBSD|NetBSD|Darwin)
9-
export PREFIX="venv/bin/"
10-
;;
11-
*MINGW*)
12-
export PREFIX="venv/Scripts/"
13-
;;
14-
*)
15-
echo "ERROR: Script 'test' encountered unsupported operating system $(uname -s)"
16-
exit 1
17-
;;
18-
esac
19-
fi
20-
216
${PREFIX}pytest -n 3 --cov-report term-missing --cov-report=xml:coverage.xml --cov=commitizen tests/
227
${PREFIX}black commitizen tests --check
238
${PREFIX}isort --check-only commitizen tests
249
${PREFIX}flake8 commitizen/ tests/
2510
${PREFIX}mypy commitizen/ tests/
2611
${PREFIX}pydocstyle --convention=google --add-ignore=D1,D415 --match-dir='^(?![.]|venv).*'
27-
${PREFIX}cz check --rev-range origin/master..
12+
${PREFIX}commitizen check --rev-range origin/master..

0 commit comments

Comments
 (0)