Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cc202cc

Browse files
committed
Improve when and how Makefile suggests virtual env
The avoids showing the message when the build command was already run in a virtual environment. It also keeps the command failing, so the subsequent twine command is not attempted. (Just adding "|| echo ..." caused the command to succeed, because "echo ..." itself succeeds except in the rare case it cannot write to standard output.)
1 parent b1c61d9 commit cc202cc

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ release: clean
2121
force_release: clean
2222
# IF we're in a virtual environment, add build tools
2323
test -z "$$VIRTUAL_ENV" || pip install -U build twine
24-
python3 -m build --sdist --wheel || echo "Use a virtual-env with 'python -m venv env && source env/bin/activate' instead"
24+
25+
# Build the sdist and wheel that will be uploaded to PyPI.
26+
python3 -m build --sdist --wheel || \
27+
test -z "$$VIRTUAL_ENV" && \
28+
echo "Use a virtual-env with 'python -m venv env && source env/bin/activate' instead" && \
29+
false
30+
31+
# Upload to PyPI and push the tag.
2532
twine upload dist/*
2633
git push --tags origin main

0 commit comments

Comments
 (0)