Skip to content

Commit

Permalink
Generate whole WHEEL file
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Mar 8, 2024
1 parent 3edece9 commit 8d7abbc
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 38 deletions.
6 changes: 2 additions & 4 deletions build-wheels-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ mkdir -p openturns.libs
cp -v ../../../etc/openturns/openturns.conf openturns.libs

# write metadata
python ${SCRIPTPATH}/write_RECORD.py openturns ${VERSION}
sed -i "/Tag:/d" openturns-${VERSION}.dist-info/WHEEL
echo "Tag: ${TAG}" >> openturns-${VERSION}.dist-info/WHEEL
python ${SCRIPTPATH}/write_distinfo.py openturns ${VERSION} ${TAG}

# create archive
zip -r openturns-${VERSION}-${TAG}.whl openturns openturns.libs openturns-${VERSION}.dist-info
Expand Down Expand Up @@ -91,7 +89,7 @@ do
rm -rf ${pkgname}/__pycache__

# write metadata
python ${SCRIPTPATH}/write_RECORD.py ${pkgname} ${pkgver}
python ${SCRIPTPATH}/write_distinfo.py ${pkgname} ${pkgver} ${TAG}

# copy libs
mkdir ${pkgname}.libs
Expand Down
4 changes: 1 addition & 3 deletions build-wheels-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ mkdir -p openturns.libs
cp -v ../../../etc/openturns/openturns.conf openturns.libs

# write metadata
python${PYVER} ${SCRIPTPATH}/write_RECORD.py openturns ${VERSION}
sed -i "" "/Tag:/d" openturns-${VERSION}.dist-info/WHEEL
echo "Tag: ${TAG}" >> openturns-${VERSION}.dist-info/WHEEL
python${PYVER} ${SCRIPTPATH}/write_distinfo.py openturns ${VERSION} ${TAG}

# create archive
zip -r openturns-${VERSION}-${TAG}.whl openturns openturns.libs openturns-${VERSION}.dist-info
Expand Down
4 changes: 1 addition & 3 deletions build-wheels-mingw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ rm ${PREFIX}/Lib/site-packages/openturns/{libboost,python,libgraphblas}*.dll
cd ${PREFIX}/Lib/site-packages/

# write metadata
python /io/write_RECORD.py openturns ${VERSION}
sed -i "/Tag:/d" openturns-${VERSION}.dist-info/WHEEL
echo "Tag: ${TAG}" >> openturns-${VERSION}.dist-info/WHEEL
python /io/write_distinfo.py openturns ${VERSION} ${TAG}

# create archive
zip -r openturns-${VERSION}-${TAG}.whl openturns openturns-${VERSION}.dist-info
Expand Down
28 changes: 0 additions & 28 deletions write_RECORD.py

This file was deleted.

32 changes: 32 additions & 0 deletions write_distinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python

import os
import hashlib
import base64
import sys

if len(sys.argv) != 4:
raise ValueError("no name/version/tag")
name, version, tag = sys.argv[1:]

path = os.path.join(f"{name}-{version}.dist-info", "RECORD")
with open(path, "w") as record:
for subdir in [name, f"{name}-{version}.dist-info"]:
for fn in os.listdir(subdir):
fpath = os.path.join(subdir, fn)
if os.path.isfile(fpath):
if fn == "RECORD":
record.write(f"{fpath},,\n")
else:
data = open(fpath, "rb").read()
digest = hashlib.sha256(data).digest()
checksum = base64.urlsafe_b64encode(digest).decode()
size = len(data)
record.write(f"{fpath},sha256={checksum},{size}\n")

path = os.path.join(f"{name}-{version}.dist-info", "WHEEL")
with open(path, "w") as wheel:
wheel.write("Wheel-Version: 1.0\n")
wheel.write("Generator: custom\n")
wheel.write("Root-Is-Purelib: false\n")
wheel.write(f"Tag: {tag}\n")

0 comments on commit 8d7abbc

Please sign in to comment.