Skip to content

Commit

Permalink
Improve when and how Makefile suggests virtual env
Browse files Browse the repository at this point in the history
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.)
  • Loading branch information
EliahKagan committed Sep 13, 2023
1 parent b1c61d9 commit cc202cc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ release: clean
force_release: clean
# IF we're in a virtual environment, add build tools
test -z "$$VIRTUAL_ENV" || pip install -U build twine
python3 -m build --sdist --wheel || echo "Use a virtual-env with 'python -m venv env && source env/bin/activate' instead"

# Build the sdist and wheel that will be uploaded to PyPI.
python3 -m build --sdist --wheel || \
test -z "$$VIRTUAL_ENV" && \
echo "Use a virtual-env with 'python -m venv env && source env/bin/activate' instead" && \
false

# Upload to PyPI and push the tag.
twine upload dist/*
git push --tags origin main

0 comments on commit cc202cc

Please sign in to comment.