mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
Added the Linux wheel
make_wheel.py --linux packs bakashrot.py with the Linux client library only (named BakaShrot_Client.dll, as the repository does on Linux), libsodium coming from the system (libsodium23), glibc 2.34+, tagged linux_x86_64. Refuses a library from the other platform. The Windows wheel is byte-identical to before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,14 +9,20 @@ Windows 10 or later, 64-bit Python 3.8+.
|
|||||||
|
|
||||||
|
|
||||||
## Linux
|
## Linux
|
||||||
There is no Linux wheel yet.
|
The Linux wheel (`bakashrot-<version>-py3-none-linux_x86_64.whl`) holds only the client library,
|
||||||
|
libsodium comes from the system: `apt install libsodium23` on Debian and Ubuntu. \
|
||||||
|
Linux x86-64 with glibc 2.34+ (Debian 12, Ubuntu 22.04 or later), 64-bit Python 3.8+.
|
||||||
|
|
||||||
The Windows wheel bundles `libsodium.dll` next to the client DLL. \
|
It's tagged `linux_x86_64`, not `manylinux`: manylinux doesn't allow depending on libsodium,
|
||||||
On Linux, libsodium shouldn't be bundled like that, but come from a package instead:
|
so it goes on Gitea, not PyPI.
|
||||||
* The distribution's, like the Docker image does (`apt install libsodium23`), the wheel only holding the client's `.so`.
|
|
||||||
* Or a Python package that provides it, as a dependency of the wheel.
|
|
||||||
|
|
||||||
Until then, build the client yourself (see [CLAUDE.md](../../CLAUDE.md)) and point `BAKASHROT_DLL` at it.
|
Building it: compile the client in the Docker compiler image (Debian 13, so glibc 2.34 is enough),
|
||||||
|
named `BakaShrot_Client.dll` as the repository does on Linux, then `make_wheel.py --linux`:
|
||||||
|
```shell
|
||||||
|
docker run --rm -v "$PWD":/src:ro -v "$PWD/dist":/out -w /src git.nibblepoker.lu/packages/purebasic:6.41-linux3-trixie-slim \
|
||||||
|
sh -c 'apt-get update -qq && apt-get install -y -qq libsodium-dev >/dev/null && pbcompilerc -t --optimizer Client/BakaShrot_Client.pbi -so /out/BakaShrot_Client.dll'
|
||||||
|
python3 Interactors/Python/make_wheel.py dist dist --linux
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
|
|||||||
@@ -1,23 +1,31 @@
|
|||||||
"""Builds the bakashrot wheel: bakashrot.py with the DLLs it needs, so that
|
"""Builds the bakashrot wheel: bakashrot.py with the client library it
|
||||||
`pip install` is all a Python app needs, nothing to compile.
|
needs, so that `pip install` is all a Python app needs, nothing to compile.
|
||||||
|
|
||||||
python make_wheel.py <BinDir> [OutDir]
|
python make_wheel.py <BinDir> [OutDir] [--linux]
|
||||||
|
|
||||||
BinDir holds BakaShrot_Client.dll and libsodium.dll (a release folder, or
|
BinDir holds BakaShrot_Client.dll and libsodium.dll (a release folder, or
|
||||||
Build\\). OutDir defaults to the current directory. Release.ps1 runs it.
|
Build\\). OutDir defaults to the current directory. Release.ps1 runs it.
|
||||||
Prints the wheel's path.
|
Prints the wheel's path.
|
||||||
|
|
||||||
Licenses: BakaShrot is CC0-1.0, libsodium ISC, which asks for its notice
|
--linux: the Linux wheel instead, from a Linux build's BakaShrot_Client.dll
|
||||||
in every copy: both are in the wheel's dist-info/licenses/ (LICENSE, and
|
(the .so, named as on Windows: bakashrot.py and the tools look for that
|
||||||
Libs/libsodium/LICENSE), the metadata says "CC0-1.0 AND ISC".
|
name). libsodium isn't in it: it comes from the system (Debian/Ubuntu:
|
||||||
vcruntime140.dll, which libsodium.dll needs, isn't in it: every CPython on
|
libsodium23), and the wheel needs glibc 2.34+. Tagged linux_x86_64, not
|
||||||
Windows has loaded its own already, and that's the one used.
|
manylinux: manylinux doesn't allow depending on libsodium. Build the .so on
|
||||||
|
an old enough glibc (the Docker compiler image, Debian 13, needs 2.34).
|
||||||
|
|
||||||
The wheel is bakashrot-<version>-py3-none-win_amd64.whl, the version being
|
Licenses: BakaShrot is CC0-1.0, libsodium ISC, which asks for its notice
|
||||||
bakashrot.py's __version__. Inside it, bakashrot.py is bakashrot/__init__.py,
|
in every copy: both are in the Windows wheel's dist-info/licenses/ (LICENSE,
|
||||||
the DLLs next to it, where bakashrot.py looks first. Only the standard
|
and Libs/libsodium/LICENSE), the metadata says "CC0-1.0 AND ISC". The Linux
|
||||||
library: no setuptools, no build step, and the same inputs give the same
|
wheel only has LICENSE, "CC0-1.0", libsodium not being in it.
|
||||||
wheel (fixed timestamps).
|
vcruntime140.dll, which libsodium.dll needs, isn't in the Windows wheel:
|
||||||
|
every CPython on Windows has loaded its own already, and that's the one used.
|
||||||
|
|
||||||
|
The wheel is bakashrot-<version>-py3-none-win_amd64.whl (or
|
||||||
|
-linux_x86_64.whl), the version being bakashrot.py's __version__. Inside
|
||||||
|
it, bakashrot.py is bakashrot/__init__.py, the libraries next to it, where
|
||||||
|
bakashrot.py looks first. Only the standard library: no setuptools, no
|
||||||
|
build step, and the same inputs give the same wheel (fixed timestamps).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
@@ -31,16 +39,31 @@ HERE = os.path.dirname(os.path.abspath(__file__))
|
|||||||
ROOT = os.path.normpath(os.path.join(HERE, "..", ".."))
|
ROOT = os.path.normpath(os.path.join(HERE, "..", ".."))
|
||||||
|
|
||||||
NAME = "bakashrot"
|
NAME = "bakashrot"
|
||||||
TAG = "py3-none-win_amd64"
|
|
||||||
DLLS = ["BakaShrot_Client.dll", "libsodium.dll"]
|
|
||||||
# In the wheel's dist-info/licenses/, from the repository's root.
|
|
||||||
LICENSES = {"LICENSE": "LICENSE", "libsodium/LICENSE": "Libs/libsodium/LICENSE"}
|
|
||||||
LICENSE_EXPRESSION = "CC0-1.0 AND ISC"
|
|
||||||
# Zip entries' timestamp, so the wheel only changes when its content does.
|
# Zip entries' timestamp, so the wheel only changes when its content does.
|
||||||
FIXED_TIME = (2026, 1, 1, 0, 0, 0)
|
FIXED_TIME = (2026, 1, 1, 0, 0, 0)
|
||||||
|
|
||||||
SUMMARY = "Python client for BakaShrot servers, with the client DLL included"
|
USAGE_EXAMPLE = """\
|
||||||
DESCRIPTION = """\
|
```python
|
||||||
|
from bakashrot import Client
|
||||||
|
|
||||||
|
with Client.from_ini("client.ini") as client:
|
||||||
|
message_id = client.push({"temperature": 21.5})
|
||||||
|
for message in client.get_messages("logs", "kitchen", after=0).messages:
|
||||||
|
print(message.id, message.data)
|
||||||
|
```
|
||||||
|
|
||||||
|
See the module's docstring (`help(bakashrot)`) for the rest.
|
||||||
|
"""
|
||||||
|
|
||||||
|
WINDOWS = {
|
||||||
|
"tag": "py3-none-win_amd64",
|
||||||
|
"libraries": ["BakaShrot_Client.dll", "libsodium.dll"],
|
||||||
|
# In the wheel's dist-info/licenses/, from the repository's root.
|
||||||
|
"licenses": {"LICENSE": "LICENSE", "libsodium/LICENSE": "Libs/libsodium/LICENSE"},
|
||||||
|
"license_expression": "CC0-1.0 AND ISC",
|
||||||
|
"classifier": "Operating System :: Microsoft :: Windows :: Windows 10",
|
||||||
|
"summary": "Python client for BakaShrot servers, with the client DLL included",
|
||||||
|
"description": """\
|
||||||
# bakashrot
|
# bakashrot
|
||||||
|
|
||||||
Python client for [BakaShrot](https://github.com/aziascreations/BakaShrot)
|
Python client for [BakaShrot](https://github.com/aziascreations/BakaShrot)
|
||||||
@@ -54,17 +77,32 @@ BakaShrot is CC0-1.0 (public domain). The included libsodium is Frank
|
|||||||
Denis's, under the ISC license: its notice is in this package's
|
Denis's, under the ISC license: its notice is in this package's
|
||||||
`licenses/libsodium/LICENSE`.
|
`licenses/libsodium/LICENSE`.
|
||||||
|
|
||||||
```python
|
""" + USAGE_EXAMPLE,
|
||||||
from bakashrot import Client
|
}
|
||||||
|
|
||||||
with Client.from_ini("client.ini") as client:
|
LINUX = {
|
||||||
message_id = client.push({"temperature": 21.5})
|
"tag": "py3-none-linux_x86_64",
|
||||||
for message in client.get_messages("logs", "kitchen", after=0).messages:
|
"libraries": ["BakaShrot_Client.dll"],
|
||||||
print(message.id, message.data)
|
"licenses": {"LICENSE": "LICENSE"},
|
||||||
```
|
"license_expression": "CC0-1.0",
|
||||||
|
"classifier": "Operating System :: POSIX :: Linux",
|
||||||
|
"summary": "Python client for BakaShrot servers, with the client library included",
|
||||||
|
"description": """\
|
||||||
|
# bakashrot
|
||||||
|
|
||||||
See the module's docstring (`help(bakashrot)`) for the rest.
|
Python client for [BakaShrot](https://github.com/aziascreations/BakaShrot)
|
||||||
"""
|
servers: push messages and attachments, read them back, resolve names, query.
|
||||||
|
|
||||||
|
Includes the client library (`BakaShrot_Client.dll`, a Linux shared object
|
||||||
|
named as on Windows). Needs libsodium from the system, nothing else to build:
|
||||||
|
`apt install libsodium23` on Debian and Ubuntu. Linux x86-64 with glibc 2.34+
|
||||||
|
(Debian 12, Ubuntu 22.04 or later), 64-bit Python 3.8+. The server must speak
|
||||||
|
the same protocol: use the release this package comes from.
|
||||||
|
|
||||||
|
BakaShrot is CC0-1.0 (public domain).
|
||||||
|
|
||||||
|
""" + USAGE_EXAMPLE,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def read_version(module_path):
|
def read_version(module_path):
|
||||||
@@ -81,10 +119,16 @@ def record_line(path, data):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) not in (2, 3):
|
args = sys.argv[1:]
|
||||||
|
platform = WINDOWS
|
||||||
|
if "--linux" in args:
|
||||||
|
args.remove("--linux")
|
||||||
|
platform = LINUX
|
||||||
|
if len(args) not in (1, 2):
|
||||||
sys.exit(__doc__)
|
sys.exit(__doc__)
|
||||||
bin_dir = sys.argv[1]
|
bin_dir = args[0]
|
||||||
out_dir = sys.argv[2] if len(sys.argv) == 3 else os.getcwd()
|
out_dir = args[1] if len(args) == 2 else os.getcwd()
|
||||||
|
tag = platform["tag"]
|
||||||
|
|
||||||
module_path = os.path.join(HERE, "bakashrot.py")
|
module_path = os.path.join(HERE, "bakashrot.py")
|
||||||
version = read_version(module_path)
|
version = read_version(module_path)
|
||||||
@@ -93,12 +137,19 @@ def main():
|
|||||||
files = [] # (path in the wheel, bytes)
|
files = [] # (path in the wheel, bytes)
|
||||||
with open(module_path, "rb") as file:
|
with open(module_path, "rb") as file:
|
||||||
files.append((f"{NAME}/__init__.py", file.read()))
|
files.append((f"{NAME}/__init__.py", file.read()))
|
||||||
for dll in DLLS:
|
for library in platform["libraries"]:
|
||||||
path = os.path.join(bin_dir, dll)
|
path = os.path.join(bin_dir, library)
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
sys.exit(f"Missing {path}")
|
sys.exit(f"Missing {path}")
|
||||||
with open(path, "rb") as file:
|
with open(path, "rb") as file:
|
||||||
files.append((f"{NAME}/{dll}", file.read()))
|
data = file.read()
|
||||||
|
# A Windows DLL starts with "MZ", a Linux .so with "\x7fELF": a
|
||||||
|
# library from the other platform would only fail once imported.
|
||||||
|
if platform is LINUX and not data.startswith(b"\x7fELF"):
|
||||||
|
sys.exit(f"{path} isn't a Linux shared object (build it on Linux, or drop --linux)")
|
||||||
|
if platform is WINDOWS and data.startswith(b"\x7fELF"):
|
||||||
|
sys.exit(f"{path} is a Linux shared object (add --linux)")
|
||||||
|
files.append((f"{NAME}/{library}", data))
|
||||||
|
|
||||||
# Metadata 2.4 (PEP 639): an SPDX expression and the license files,
|
# Metadata 2.4 (PEP 639): an SPDX expression and the license files,
|
||||||
# without license classifiers (not allowed with an expression).
|
# without license classifiers (not allowed with an expression).
|
||||||
@@ -106,28 +157,28 @@ def main():
|
|||||||
"Metadata-Version: 2.4",
|
"Metadata-Version: 2.4",
|
||||||
f"Name: {NAME}",
|
f"Name: {NAME}",
|
||||||
f"Version: {version}",
|
f"Version: {version}",
|
||||||
f"Summary: {SUMMARY}",
|
f"Summary: {platform['summary']}",
|
||||||
"Author: Herwin Bozet (NibblePoker)",
|
"Author: Herwin Bozet (NibblePoker)",
|
||||||
f"License-Expression: {LICENSE_EXPRESSION}",
|
f"License-Expression: {platform['license_expression']}",
|
||||||
] + [f"License-File: {name}" for name in LICENSES] + [
|
] + [f"License-File: {name}" for name in platform["licenses"]] + [
|
||||||
"Project-URL: GitHub, https://github.com/aziascreations/BakaShrot",
|
"Project-URL: GitHub, https://github.com/aziascreations/BakaShrot",
|
||||||
"Project-URL: Gitea, https://git.nibblepoker.lu/aziascreations/BakaShrot",
|
"Project-URL: Gitea, https://git.nibblepoker.lu/aziascreations/BakaShrot",
|
||||||
"Classifier: Operating System :: Microsoft :: Windows :: Windows 10",
|
f"Classifier: {platform['classifier']}",
|
||||||
"Classifier: Programming Language :: Python :: 3",
|
"Classifier: Programming Language :: Python :: 3",
|
||||||
"Requires-Python: >=3.8",
|
"Requires-Python: >=3.8",
|
||||||
"Description-Content-Type: text/markdown",
|
"Description-Content-Type: text/markdown",
|
||||||
"",
|
"",
|
||||||
DESCRIPTION,
|
platform["description"],
|
||||||
]).encode("utf-8")
|
]).encode("utf-8")
|
||||||
files.append((f"{dist_info}/METADATA", metadata))
|
files.append((f"{dist_info}/METADATA", metadata))
|
||||||
files.append((f"{dist_info}/WHEEL", "\n".join([
|
files.append((f"{dist_info}/WHEEL", "\n".join([
|
||||||
"Wheel-Version: 1.0",
|
"Wheel-Version: 1.0",
|
||||||
"Generator: BakaShrot make_wheel.py",
|
"Generator: BakaShrot make_wheel.py",
|
||||||
"Root-Is-Purelib: false",
|
"Root-Is-Purelib: false",
|
||||||
f"Tag: {TAG}",
|
f"Tag: {tag}",
|
||||||
"",
|
"",
|
||||||
]).encode("utf-8")))
|
]).encode("utf-8")))
|
||||||
for name, source in LICENSES.items():
|
for name, source in platform["licenses"].items():
|
||||||
path = os.path.join(ROOT, source)
|
path = os.path.join(ROOT, source)
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
sys.exit(f"Missing {path}")
|
sys.exit(f"Missing {path}")
|
||||||
@@ -138,12 +189,13 @@ def main():
|
|||||||
files.append((f"{dist_info}/RECORD", record.encode("utf-8")))
|
files.append((f"{dist_info}/RECORD", record.encode("utf-8")))
|
||||||
|
|
||||||
os.makedirs(out_dir, exist_ok=True)
|
os.makedirs(out_dir, exist_ok=True)
|
||||||
wheel_path = os.path.join(out_dir, f"{NAME}-{version}-{TAG}.whl")
|
wheel_path = os.path.join(out_dir, f"{NAME}-{version}-{tag}.whl")
|
||||||
with zipfile.ZipFile(wheel_path, "w", zipfile.ZIP_DEFLATED) as wheel:
|
with zipfile.ZipFile(wheel_path, "w", zipfile.ZIP_DEFLATED) as wheel:
|
||||||
for path, data in files:
|
for path, data in files:
|
||||||
info = zipfile.ZipInfo(path, FIXED_TIME)
|
info = zipfile.ZipInfo(path, FIXED_TIME)
|
||||||
info.compress_type = zipfile.ZIP_DEFLATED
|
info.compress_type = zipfile.ZIP_DEFLATED
|
||||||
info.external_attr = 0o644 << 16
|
# The shared object must stay executable for some loaders.
|
||||||
|
info.external_attr = (0o755 if path.endswith(".dll") and platform is LINUX else 0o644) << 16
|
||||||
wheel.writestr(info, data)
|
wheel.writestr(info, data)
|
||||||
print(wheel_path)
|
print(wheel_path)
|
||||||
|
|
||||||
|
|||||||
@@ -867,7 +867,13 @@ network**, not exposed to the internet. So:
|
|||||||
18. ~~**Linux is untested**~~ Done (2026-11-10): every suite passes, see
|
18. ~~**Linux is untested**~~ Done (2026-11-10): every suite passes, see
|
||||||
`Done: Linux, Docker images`.
|
`Done: Linux, Docker images`.
|
||||||
19. **Console commands can't be scripted** (see 1).
|
19. **Console commands can't be scripted** (see 1).
|
||||||
20. **No Linux wheel.** The Windows one bundles `libsodium.dll` next to the
|
20. ~~**No Linux wheel.**~~ Done (2026-11-11, uncommitted):
|
||||||
|
`make_wheel.py --linux`, the client `.so` only (built in the Docker
|
||||||
|
compiler image, needs glibc 2.34+), libsodium from the system
|
||||||
|
(`libsodium23`), tagged `linux_x86_64`. Installed by pip on Python 3.13
|
||||||
|
(Debian 13) and 3.8 (Debian 12), talks to the `0.0.1` server image;
|
||||||
|
`twine check` passes; uploaded to Gitea's PyPI registry (0.0.1). The
|
||||||
|
Windows wheel is byte-identical to before. Was: the Windows one bundles `libsodium.dll` next to the
|
||||||
client DLL; on Linux, find a way not to bundle libsodium like that,
|
client DLL; on Linux, find a way not to bundle libsodium like that,
|
||||||
maybe through a package: the distribution's (`libsodium23`, as the
|
maybe through a package: the distribution's (`libsodium23`, as the
|
||||||
Docker image does, the wheel then holding only the client `.so`), or
|
Docker image does, the wheel then holding only the client `.so`), or
|
||||||
|
|||||||
Reference in New Issue
Block a user