@@ -6,6 +6,9 @@ SHELL := bash
6
6
# Set the package's name and version for use throughout the Makefile.
7
7
PACKAGE_NAME := package
8
8
PACKAGE_VERSION := $(shell python -c $$'try: import $(PACKAGE_NAME ) ; print($(PACKAGE_NAME ) .__version__) ;\nexcept: print("unknown");')
9
+ ARCH := $(shell uname -m) # E.g., arm64 or x86_64.
10
+ OS := $(shell uname | tr '[:upper:]' '[:lower:]') # E.g., linux or darwin.
11
+
9
12
10
13
# This variable contains the first goal that matches any of the listed goals
11
14
# here, else it contains an empty string. The net effect is to filter out
@@ -107,7 +110,7 @@ upgrade-quiet:
107
110
# Generate a Software Bill of Materials (SBOM).
108
111
.PHONY : sbom
109
112
sbom : requirements
110
- cyclonedx-py requirements --output-format json --outfile dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -sbom.json
113
+ cyclonedx-py requirements --output-format json --outfile dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -$( OS ) - $( ARCH ) - sbom.json
111
114
112
115
# Generate a requirements.txt file containing version and integrity hashes for all
113
116
# packages currently installed in the virtual environment. There's no easy way to
@@ -129,14 +132,14 @@ requirements.txt: pyproject.toml
129
132
[[ $$ 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; \
130
133
done
131
134
echo -e -n " $( PACKAGE_NAME) ==$( PACKAGE_VERSION) " >> requirements.txt
132
- if [ -f dist/$( PACKAGE_NAME) -$( PACKAGE_VERSION) .tar.gz ]; then \
133
- echo -e -n " \\\\ \n $$ (python -m pip hash --algorithm sha256 dist/$( PACKAGE_NAME) -$( PACKAGE_VERSION) .tar.gz | grep '^\-\-hash')" >> requirements.txt; \
135
+ if [ -f dist/$( PACKAGE_NAME) -$( PACKAGE_VERSION) - $( OS ) - $( ARCH ) .tar.gz ]; then \
136
+ echo -e -n " \\\\ \n $$ (python -m pip hash --algorithm sha256 dist/$( PACKAGE_NAME) -$( PACKAGE_VERSION) - $( OS ) - $( ARCH ) .tar.gz | grep '^\-\-hash')" >> requirements.txt; \
134
137
fi
135
- if [ -f dist/$( PACKAGE_NAME) -$( PACKAGE_VERSION) -py3-none-any .whl ]; then \
136
- echo -e -n " \\\\ \n $$ (python -m pip hash --algorithm sha256 dist/$( PACKAGE_NAME) -$( PACKAGE_VERSION) -py3-none-any .whl | grep '^\-\-hash')" >> requirements.txt; \
138
+ if [ -f dist/$( PACKAGE_NAME) -$( PACKAGE_VERSION) -py3-$( OS ) - $( ARCH ) .whl ]; then \
139
+ echo -e -n " \\\\ \n $$ (python -m pip hash --algorithm sha256 dist/$( PACKAGE_NAME) -$( PACKAGE_VERSION) -py3-$( OS ) - $( ARCH ) .whl | grep '^\-\-hash')" >> requirements.txt; \
137
140
fi
138
141
echo " " >> requirements.txt
139
- cp requirements.txt dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -requirements.txt
142
+ cp requirements.txt dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -$( OS ) - $( ARCH ) - requirements.txt
140
143
141
144
# Audit the currently installed packages. Skip packages that are installed in
142
145
# editable mode (like the one in development here) because they may not have
@@ -175,17 +178,19 @@ test:
175
178
# When building these artifacts, we need the environment variable SOURCE_DATE_EPOCH
176
179
# set to the build date/epoch. For more details, see: https://flit.pypa.io/en/latest/reproducible.html
177
180
.PHONY : dist
178
- 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 ) -build-epoch.txt
179
- dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -py3-none-any .whl : check test
181
+ dist : dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -py3-$( OS ) - $( ARCH ) .whl dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) - $( OS ) - $( ARCH ) .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
182
+ dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -py3-$( OS ) - $( ARCH ) .whl : check test
180
183
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH ) flit build --setup-py --format wheel
181
- dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) .tar.gz : check test
184
+ mv dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -py3-none-any.whl dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -py3-$(OS ) -$(ARCH ) .whl
185
+ dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -$(OS ) -$(ARCH ) .tar.gz : check test
182
186
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH ) flit build --setup-py --format sdist
187
+ mv dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) .tar.gz dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -$(OS ) -$(ARCH ) .tar.gz
183
188
dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -docs-html.zip : docs-html
184
189
python -m zipfile -c dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -docs-html.zip docs/_build/html/
185
190
dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -docs-md.zip : docs-md
186
191
python -m zipfile -c dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -docs-md.zip docs/_build/markdown/
187
- dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -build-epoch.txt :
188
- echo $(SOURCE_DATE_EPOCH ) > dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -build-epoch.txt
192
+ dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -$( OS ) - $( ARCH ) - build-epoch.txt :
193
+ echo $(SOURCE_DATE_EPOCH ) > dist/$(PACKAGE_NAME ) -$(PACKAGE_VERSION ) -$( PACKAGE_VERSION ) - $( OS ) - $( ARCH ) - build-epoch.txt
189
194
190
195
# Build the HTML and Markdown documentation from the package's source.
191
196
DOCS_SOURCE := $(shell git ls-files docs/source)
0 commit comments