Skip to content

Commit 93cf826

Browse files
committed
build: only run the version-getter when needed
1 parent 5f65b21 commit 93cf826

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Makefile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
# For opening files in a browser. Use like: $(BROWSER)relative/path/to/file.html
1313
BROWSER := python -m webbrowser file://$(CURDIR)/
1414

15-
# This runs a Python command for every make invocation, but it's fast enough.
16-
# Is there a way to do it only when needed?
17-
VERSION := $(shell python -c "import build.util as bu; print(bu.project_wheel_metadata('.')['Version'])")
18-
export VERSION
15+
# A command to get the current version. A little slow, but only run when needed.
16+
VERSION := $$(python -c "import build.util as bu; print(bu.project_wheel_metadata('.')['Version'])")
1917

2018
.PHONY: help clean sterile
2119

@@ -108,15 +106,15 @@ testpypi: ## upload the distrubutions to PyPI's testing server.
108106
python -m twine upload --verbose --repository testpypi dist/*
109107

110108
tag: ## make a git tag with the version number
111-
git tag -s -m "Version $$VERSION" $$VERSION
109+
git tag -s -m "Version $(VERSION)" $(VERSION)
112110
git push --all
113111

114112
gh_release: ## make a GitHub release
115113
python -m scriv github-release --all --fail-if-warn --check-links
116114

117115
comment_text:
118116
@echo "Use this to comment on issues and pull requests:"
119-
@echo "This is now released as part of [scriv $$VERSION](https://pypi.org/project/scriv/$$VERSION)."
117+
@echo "This is now released as part of [scriv $(VERSION)](https://pypi.org/project/scriv/$(VERSION))."
120118

121119

122120
.PHONY: release check_release _check_credentials _check_manifest _check_tree _check_version _check_scriv _check_links
@@ -142,7 +140,7 @@ _check_tree:
142140
fi
143141

144142
_check_version:
145-
@if [[ $$(git tags | grep -q -w $$VERSION && echo "x") == "x" ]]; then \
143+
@if [[ $$(git tags | grep -q -w $(VERSION) && echo "x") == "x" ]]; then \
146144
echo 'A git tag for this version exists! Did you forget to bump the version in src/scriv/__init__.py?'; \
147145
exit 1; \
148146
fi

0 commit comments

Comments
 (0)