Skip to content

Commit 953738f

Browse files
committed
feat: standalone binary releases, auto-install sing-box from GitHub, install scripts, fix sb2p alias, bump to 0.3.2
1 parent c567592 commit 953738f

8 files changed

Lines changed: 384 additions & 9 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
run: |
4747
python -m pytest tests/tun_test.py::TestTunConfig --tb=short --disable-warnings -v
4848
- name: Run TUN live test (Linux)
49-
if: runner.os == 'Linux' && env.TEST_SINGBOX_LINK != ''
49+
if: runner.os == 'Linux' && env.TEST_SINGBOX_LINK != ''
5050
run: |
5151
sudo -E env "PATH=$PATH" "TEST_SINGBOX_LINK=$TEST_SINGBOX_LINK" "$pythonLocation/bin/python" -m pytest tests/tun_test.py::TestTunLiveSystemVpn --tb=short --disable-warnings -v
5252
- name: Run TUN live test (Windows)

.github/workflows/release.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Release Binaries
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
name: Build ${{ matrix.os }}
11+
runs-on: ${{ matrix.runs-on }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- os: linux-amd64
17+
runs-on: ubuntu-22.04
18+
artifact: sb2p-linux-amd64
19+
ext: ""
20+
- os: windows-amd64
21+
runs-on: windows-latest
22+
artifact: sb2p-windows-amd64.exe
23+
ext: ".exe"
24+
- os: macos-amd64
25+
runs-on: macos-13
26+
artifact: sb2p-macos-amd64
27+
ext: ""
28+
- os: macos-arm64
29+
runs-on: macos-14
30+
artifact: sb2p-macos-arm64
31+
ext: ""
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Set up Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: "3.11"
40+
41+
- name: Install build dependencies
42+
shell: bash
43+
run: |
44+
python -m pip install --upgrade pip
45+
python -m pip install nuitka ordered-set zstandard
46+
python -m pip install -e ".[cli]"
47+
48+
- name: Install C compiler (Linux)
49+
if: runner.os == 'Linux'
50+
run: sudo apt-get update && sudo apt-get install -y gcc patchelf
51+
52+
- name: Build binary
53+
shell: bash
54+
run: |
55+
python -m nuitka \
56+
--onefile \
57+
--output-filename="sb2p${{ matrix.ext }}" \
58+
--output-dir=dist \
59+
--remove-output \
60+
--assume-yes-for-downloads \
61+
--python-flag=no_docstrings \
62+
--python-flag=-OO \
63+
--include-package=singbox2proxy \
64+
--include-module=qrcode \
65+
--include-module=psutil \
66+
--nofollow-import-to=tkinter \
67+
--nofollow-import-to=unittest \
68+
--nofollow-import-to=test \
69+
--nofollow-import-to=distutils \
70+
--nofollow-import-to=setuptools \
71+
--nofollow-import-to=pydoc \
72+
--nofollow-import-to=xmlrpc \
73+
--nofollow-import-to=doctest \
74+
--nofollow-import-to=pdb \
75+
--nofollow-import-to=lib2to3 \
76+
--nofollow-import-to=ensurepip \
77+
singbox2proxy/__main__.py
78+
79+
- name: Compress with UPX (Linux)
80+
if: runner.os == 'Linux'
81+
run: |
82+
sudo apt-get install -y upx-ucl || sudo apt-get install -y upx
83+
upx --best --lzma "dist/sb2p" || true
84+
85+
- name: Compress with UPX (Windows)
86+
if: runner.os == 'Windows'
87+
shell: pwsh
88+
run: |
89+
Invoke-WebRequest -Uri "https://github.com/upx/upx/releases/download/v4.2.4/upx-4.2.4-win64.zip" -OutFile upx.zip
90+
Expand-Archive upx.zip -DestinationPath upx
91+
./upx/upx-4.2.4-win64/upx.exe --best --lzma "dist/sb2p.exe" || echo "UPX compression skipped"
92+
93+
- name: Rename artifact
94+
shell: bash
95+
run: mv "dist/sb2p${{ matrix.ext }}" "dist/${{ matrix.artifact }}"
96+
97+
- name: Smoke test (non-Windows)
98+
if: runner.os != 'Windows'
99+
shell: bash
100+
run: |
101+
chmod +x "dist/${{ matrix.artifact }}"
102+
"dist/${{ matrix.artifact }}" --version
103+
104+
- name: Smoke test (Windows)
105+
if: runner.os == 'Windows'
106+
shell: pwsh
107+
run: |
108+
& "dist/${{ matrix.artifact }}" --version
109+
110+
- name: Upload artifact
111+
uses: actions/upload-artifact@v4
112+
with:
113+
name: ${{ matrix.artifact }}
114+
path: dist/${{ matrix.artifact }}
115+
116+
- name: Upload to release
117+
if: github.event_name == 'release'
118+
uses: softprops/action-gh-release@v2
119+
with:
120+
files: dist/${{ matrix.artifact }}

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ keywords = [
3636
]
3737
dependencies = []
3838

39+
[project.optional-dependencies]
40+
cli = ["qrcode", "psutil"]
41+
http = ["requests"]
42+
fast = ["curl-cffi"]
43+
socks = ["pysocks"]
44+
all = ["qrcode", "psutil", "requests", "curl-cffi", "pysocks"]
45+
3946
[project.scripts]
4047
singbox2proxy = "singbox2proxy.__main__:main"
4148
sb2p = "singbox2proxy.__main__:main"

readme.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,37 @@ This module supports these sing-box protocols:
3131

3232
### Installation
3333

34-
with pip
34+
#### Quick Install (no Python required)
35+
36+
**Linux / macOS:**
37+
```shell
38+
curl -fsSL https://raw.githubusercontent.com/nichind/singbox2proxy/main/scripts/install.sh | sh
39+
```
40+
41+
**Windows (PowerShell):**
42+
```powershell
43+
irm https://raw.githubusercontent.com/nichind/singbox2proxy/main/scripts/install.ps1 | iex
44+
```
45+
46+
By default this downloads a standalone binary. To install via Python/pip instead:
47+
```shell
48+
# Linux/macOS
49+
curl -fsSL https://raw.githubusercontent.com/nichind/singbox2proxy/main/scripts/install.sh | sh -s -- --python
50+
51+
# Windows
52+
& ([scriptblock]::Create((irm https://raw.githubusercontent.com/nichind/singbox2proxy/main/scripts/install.ps1))) -Mode python
53+
```
54+
55+
Both `sb2p` and `singbox2proxy` commands are created automatically.
56+
57+
#### Standalone Binary (no Python, no pip)
58+
59+
Download a pre-built binary from [Releases](https://github.com/nichind/singbox2proxy/releases) — just download, put anywhere in PATH, and use:
60+
```shell
61+
sb2p "vless://..."
62+
```
63+
64+
#### With pip
3565

3666
```shell
3767
pip install singbox2proxy

sb2p/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# sb2p
2+
3+
This is an alias package for **[singbox2proxy](https://github.com/nichind/singbox2proxy)**.
4+
5+
```shell
6+
pip install sb2p
7+
```
8+
9+
is equivalent to:
10+
11+
```shell
12+
pip install singbox2proxy
13+
```
14+
15+
Both provide the `sb2p` and `singbox2proxy` CLI commands.
16+
17+
## Usage
18+
19+
```shell
20+
sb2p "vless://..."
21+
sb2p "vmess://..." --tun
22+
sb2p --check proxies.txt
23+
```
24+
25+
For full documentation, see the [main project](https://github.com/nichind/singbox2proxy).

sb2p/pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "sb2p"
7-
version = "0.3.0"
7+
version = "0.3.2"
88
authors = [{name = "nichind", email = "nichind@proton.me"}]
99
description = "Alias for singbox2proxy — pip install sb2p"
10+
readme = "readme.md"
1011
requires-python = ">=3.9"
1112
license = {text = "MIT"}
1213
keywords = ["sing-box", "proxy", "sb2p", "singbox2proxy"]
13-
dependencies = ["singbox2proxy==0.3.0"]
14+
dependencies = ["singbox2proxy"]
1415

1516
[project.scripts]
1617
sb2p = "singbox2proxy.__main__:main"

singbox2proxy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .client import SingBoxClient, default_request_module # noqa: F401
44
from .parsers import parse_link # noqa: F401
55

6-
VERSION = "0.3.1"
6+
VERSION = "0.3.2"
77

88
__all__ = [
99
"SingBoxCore",

0 commit comments

Comments
 (0)