@@ -7,6 +7,7 @@ SHELL := bash
7
7
PACKAGE_NAME := package
8
8
PACKAGE_VERSION := $(shell python -c $$'try: import $(PACKAGE_NAME ) ; print($(PACKAGE_NAME ) .__version__, end="") ;\nexcept: print("unknown");')
9
9
10
+ # Determine the OS and architecture.
10
11
OS_NAME := "$(shell uname) "
11
12
ifeq ($(OS_NAME ) , "Darwin")
12
13
OS := darwin
16
17
endif
17
18
endif
18
19
19
- ARCH := $(shell echo `uname -m` | xargs) # E.g., arm64 or x86_64.
20
+ ARCH := $(shell echo `uname -m` | xargs) # E.g., arm64 or x86_64.
21
+
22
+ # Construct full package identifier.
23
+ PACKAGE_FULL_NAME := $(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -$(OS ) -$(ARCH )
20
24
21
25
# This variable contains the first goal that matches any of the listed goals
22
26
# here, else it contains an empty string. The net effect is to filter out
@@ -118,7 +122,7 @@ upgrade-quiet:
118
122
# Generate a Software Bill of Materials (SBOM).
119
123
.PHONY : sbom
120
124
sbom : requirements
121
- cyclonedx-py requirements --output-format json --outfile dist/$(PACKAGE_NAME ) - $( PACKAGE_VERSION ) - $( OS ) - $( ARCH ) -sbom.json
125
+ cyclonedx-py requirements --output-format json --outfile dist/$(PACKAGE_FULL_NAME ) -sbom.json
122
126
123
127
# Generate a requirements.txt file containing version and integrity hashes for all
124
128
# packages currently installed in the virtual environment. There's no easy way to
@@ -140,14 +144,14 @@ requirements.txt: pyproject.toml
140
144
[[ $$ pkg =~ (.* )== (.* ) ]] && curl -s https://pypi.org/pypi/$$ {BASH_REMATCH[1]}/$$ {BASH_REMATCH[2]}/json | python -c " import json, sys; print(''.join(f''' \\\\ \n --hash=sha256:{pkg['digests']['sha256']}''' for pkg in json.load(sys.stdin)['urls']));" >> requirements.txt; \
141
145
done
142
146
echo -e -n " $( PACKAGE_NAME) ==$( PACKAGE_VERSION) " >> requirements.txt
143
- if [ -f dist/$( PACKAGE_NAME ) - $( PACKAGE_VERSION ) - $( OS ) - $( ARCH ) .tar.gz ]; then \
144
- echo -e -n " \\\\ \n $$ (python -m pip hash --algorithm sha256 dist/$( PACKAGE_NAME ) - $( PACKAGE_VERSION ) - $( OS ) - $( ARCH ) .tar.gz | grep '^\-\-hash')" >> requirements.txt; \
147
+ if [ -f dist/$( PACKAGE_FULL_NAME ) .tar.gz ]; then \
148
+ echo -e -n " \\\\ \n $$ (python -m pip hash --algorithm sha256 dist/$( PACKAGE_FULL_NAME ) .tar.gz | grep '^\-\-hash')" >> requirements.txt; \
145
149
fi
146
150
if [ -f dist/$( PACKAGE_NAME) -$( PACKAGE_VERSION) -py3-$( OS) -$( ARCH) .whl ]; then \
147
151
echo -e -n " \\\\ \n $$ (python -m pip hash --algorithm sha256 dist/$( PACKAGE_NAME) -$( PACKAGE_VERSION) -py3-$( OS) -$( ARCH) .whl | grep '^\-\-hash')" >> requirements.txt; \
148
152
fi
149
153
echo " " >> requirements.txt
150
- cp requirements.txt dist/$(PACKAGE_NAME ) - $( PACKAGE_VERSION ) - $( OS ) - $( ARCH ) -requirements.txt
154
+ cp requirements.txt dist/$(PACKAGE_FULL_NAME ) -requirements.txt
151
155
152
156
# Audit the currently installed packages. Skip packages that are installed in
153
157
# editable mode (like the one in development here) because they may not have
@@ -186,19 +190,19 @@ test:
186
190
# When building these artifacts, we need the environment variable SOURCE_DATE_EPOCH
187
191
# set to the build date/epoch. For more details, see: https://flit.pypa.io/en/latest/reproducible.html
188
192
.PHONY : dist
189
- dist : dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -py3-none-any.whl dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) .tar.gz dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -docs-html.zip dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -docs-md.zip dist/$(PACKAGE_NAME ) - $( PACKAGE_VERSION ) - $( OS ) - $( ARCH ) -build-epoch.txt
193
+ dist : dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -py3-none-any.whl dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) .tar.gz dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -docs-html.zip dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -docs-md.zip dist/$(PACKAGE_FULL_NAME ) -build-epoch.txt
190
194
dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -py3-none-any.whl :
191
195
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH ) flit build --setup-py --format wheel
192
196
mv dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -py3-none-any.whl dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -py3-$(OS ) -$(ARCH ) .whl
193
197
dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) .tar.gz :
194
198
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH ) flit build --setup-py --format sdist
195
- mv dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) .tar.gz dist/$(PACKAGE_NAME ) - $( PACKAGE_VERSION ) - $( OS ) - $( ARCH ) .tar.gz
199
+ mv dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) .tar.gz dist/$(PACKAGE_FULL_NAME ) .tar.gz
196
200
dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -docs-html.zip : docs-html
197
201
python -m zipfile -c dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -docs-html.zip docs/_build/html/
198
202
dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -docs-md.zip : docs-md
199
203
python -m zipfile -c dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -docs-md.zip docs/_build/markdown/
200
- dist/$(PACKAGE_NAME ) - $( PACKAGE_VERSION ) - $( OS ) - $( ARCH ) -build-epoch.txt :
201
- echo $(SOURCE_DATE_EPOCH ) > dist/$(PACKAGE_NAME ) - $( PACKAGE_VERSION ) - $( OS ) - $( ARCH ) -build-epoch.txt
204
+ dist/$(PACKAGE_FULL_NAME ) -build-epoch.txt :
205
+ echo $(SOURCE_DATE_EPOCH ) > dist/$(PACKAGE_FULL_NAME ) -build-epoch.txt
202
206
203
207
# Build the HTML and Markdown documentation from the package's source.
204
208
DOCS_SOURCE := $(shell git ls-files docs/source)
0 commit comments