Skip to content

Commit 860772e

Browse files
committed
feat: musl binaries
1 parent 00178e1 commit 860772e

File tree

6 files changed

+107
-107
lines changed

6 files changed

+107
-107
lines changed

.github/workflows/musltest.yml

Lines changed: 0 additions & 82 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,67 @@ jobs:
295295
with:
296296
name: Darwin
297297
path: LIBS/*
298-
298+
musl:
299+
runs-on: ubuntu-latest
300+
strategy:
301+
matrix:
302+
include:
303+
- arch: x86
304+
goarch: 386
305+
- arch: aarch64
306+
goarch: arm64
307+
- arch: x86_64
308+
goarch: amd64
309+
- arch: armv7
310+
goarch: arm
311+
- arch: ppc64le
312+
goarch: ppc64le
313+
- arch: s390x
314+
goarch: s390x
315+
steps:
316+
- uses: actions/checkout@v2
317+
- name: Setup latest Alpine Linux
318+
uses: jirutka/setup-alpine@v1
319+
with:
320+
alpine-version: 'latest'
321+
arch: ${{ matrix.arch }}
322+
chroot: true
323+
packages: |
324+
linux-headers
325+
python3-dev
326+
go
327+
python3
328+
uv
329+
musl
330+
musl-dev
331+
musl-utils
332+
git
333+
gcc
334+
py3-pillow
335+
build-base
336+
zlib-dev
337+
jpeg-dev
338+
freetype-dev
339+
lcms2-dev
340+
- name: Run script inside Alpine chroot as the default user (unprivileged)
341+
run: |
342+
export CGO_ENABLED=1
343+
export GOARCH=${{ matrix.goarch }}
344+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
345+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
346+
ls -la # as you would expect, you're in your workspace directory
347+
uv sync
348+
uv sync --dev
349+
uv run task version --set-url "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" info
350+
bash bump_version.sh
351+
uv run task build goneonize
352+
uv build
353+
uv run task repack
354+
export UV_PUBLISH_TOKEN=${UV_PUBLISH_TOKEN}
355+
if [[ $UV_PUBLISH_TOKEN ]];then
356+
uv publish
357+
fi
358+
shell: alpine.sh {0}
299359
release:
300360
runs-on: ubuntu-latest
301361
needs: [android, zig, linux, darwin]
@@ -335,4 +395,3 @@ jobs:
335395
if [[ $UV_PUBLISH_TOKEN ]];then
336396
uv build && uv publish
337397
fi
338-

examples/basic.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
DeviceListMetadata,
2121
)
2222
from neonize.types import MessageServerID
23-
from neonize.utils import log, build_jid
23+
from neonize.utils import log, build_jid
2424
from neonize.utils.enum import ReceiptType
2525

2626
sys.path.insert(0, os.getcwd())
@@ -63,7 +63,9 @@ def handler(client: NewClient, message: MessageEv):
6363
print(message.Message)
6464
match text:
6565
case "up-sw":
66-
client.send_video(build_jid("status@broadcast"),))
66+
client.send_video(
67+
build_jid("status@broadcast"), "https://download.samplelib.com/mp4/sample-5s.mp4"
68+
)
6769
case "ping":
6870
client.reply_message("pong", message)
6971
case "_test_link_preview":

neonize/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
from .utils.ffmpeg import FFmpeg
33
from .utils.iofile import TemporaryFile
44
from .events import Event
5-
__version__ = '0.3.10.4'
6-
__all__ = ('NewClient', 'FFmpeg', 'TemporaryFile', 'Event')
5+
6+
__version__ = "0.3.10.4"
7+
__all__ = ("NewClient", "FFmpeg", "TemporaryFile", "Event")

neonize/download.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,40 @@
33
import requests
44
from pathlib import Path
55
from tqdm import tqdm
6-
__GONEONIZE_VERSION__ = '0.3.10.4'
7-
__GIT_RELEASE_URL__ = 'https://github.com/krypton-byte/neonize'
6+
7+
__GONEONIZE_VERSION__ = "0.3.10.4"
8+
__GIT_RELEASE_URL__ = "https://github.com/krypton-byte/neonize"
9+
810

911
class UnsupportedPlatform(Exception):
1012
pass
1113

14+
1215
def __download(url: str, fname: str, chunk_size=1024):
1316
resp = requests.get(url, stream=True)
1417
if resp.status_code != 200:
1518
resp.close()
1619
raise UnsupportedPlatform(generated_name())
17-
total = int(resp.headers.get('content-length', 0))
18-
with open(fname, 'wb') as file, tqdm(desc=Path(fname).name, total=total, unit='iB', unit_scale=True, unit_divisor=1024) as bar:
20+
total = int(resp.headers.get("content-length", 0))
21+
with (
22+
open(fname, "wb") as file,
23+
tqdm(
24+
desc=Path(fname).name, total=total, unit="iB", unit_scale=True, unit_divisor=1024
25+
) as bar,
26+
):
1927
for data in resp.iter_content(chunk_size=chunk_size):
2028
size = file.write(data)
2129
bar.update(size)
2230
bar.n = total
2331
bar.close()
2432

33+
2534
def download():
26-
__download(f'{__GIT_RELEASE_URL__}/releases/download/{__GONEONIZE_VERSION__}/{generated_name()}', f'{os.path.dirname(__file__)}/{generated_name()}')
27-
if __name__ == '__main__':
28-
download()
35+
__download(
36+
f"{__GIT_RELEASE_URL__}/releases/download/{__GONEONIZE_VERSION__}/{generated_name()}",
37+
f"{os.path.dirname(__file__)}/{generated_name()}",
38+
)
39+
40+
41+
if __name__ == "__main__":
42+
download()

tools/repack.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
import platform
77

88
WORKDIR = Path(__file__).parent.parent
9-
fname = "-".join(["neonize", os.popen("uv run task version neonize --pypi-format").read().strip().replace('post', '')])
9+
fname = "-".join(
10+
[
11+
"neonize",
12+
os.popen("uv run task version neonize --pypi-format").read().strip().replace("post", ""),
13+
]
14+
)
1015
wheel_name = fname + "-py3-none-any.whl"
1116
os_name = os.environ.get("GOOS") or platform.system().lower()
1217
arch_name = os.environ.get("GOARCH") or platform.machine().lower()
@@ -18,34 +23,35 @@
1823
import subprocess
1924
import os
2025

26+
2127
def check_libc():
2228
# Coba cek dengan ldd --version
2329
try:
24-
result = subprocess.run(['ldd', '--version'], capture_output=True, text=True)
30+
result = subprocess.run(["ldd", "--version"], capture_output=True, text=True)
2531
output = result.stdout.lower() + result.stderr.lower()
26-
if 'musl' in output:
27-
return 'musl libc'
28-
elif 'glibc' in output or 'gnu libc' in output:
29-
return 'glibc'
32+
if "musl" in output:
33+
return "musl libc"
34+
elif "glibc" in output or "gnu libc" in output:
35+
return "glibc"
3036
except Exception:
3137
pass
3238

3339
# Coba cek file libc.so.6 di /lib atau /lib64
34-
libc_paths = ['/lib/libc.so.6', '/lib64/libc.so.6']
40+
libc_paths = ["/lib/libc.so.6", "/lib64/libc.so.6"]
3541
for path in libc_paths:
3642
if os.path.isfile(path):
3743
try:
3844
result = subprocess.run([path], capture_output=True, text=True)
3945
output = result.stdout.lower() + result.stderr.lower()
40-
if 'musl' in output:
41-
return 'musl libc'
42-
elif 'glibc' in output or 'gnu libc' in output:
43-
return 'glibc'
46+
if "musl" in output:
47+
return "musl libc"
48+
elif "glibc" in output or "gnu libc" in output:
49+
return "glibc"
4450
except Exception:
4551
pass
4652

4753
# Jika belum ketahuan
48-
return 'Unknown libc type'
54+
return "Unknown libc type"
4955

5056

5157
class OS(Enum):

0 commit comments

Comments
 (0)