sing-box-python 1.13.18__cp313-cp313-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sing_box_python-1.13.18.dist-info/METADATA +196 -0
- sing_box_python-1.13.18.dist-info/RECORD +10 -0
- sing_box_python-1.13.18.dist-info/WHEEL +5 -0
- sing_box_python-1.13.18.dist-info/licenses/LICENSE +17 -0
- sing_box_python-1.13.18.dist-info/top_level.txt +1 -0
- singbox/__init__.py +31 -0
- singbox/_native.cp313-win_amd64.pyd +0 -0
- singbox/_native.pyi +24 -0
- singbox/libcronet.dll +0 -0
- singbox/py.typed +0 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sing-box-python
|
|
3
|
+
Version: 1.13.18
|
|
4
|
+
Summary: Python binding for sing-box
|
|
5
|
+
License: GPL-3.0-or-later
|
|
6
|
+
Project-URL: Source, https://github.com/LorenEteval/sing-box-python
|
|
7
|
+
Project-URL: sing-box, https://github.com/SagerNet/sing-box
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Programming Language :: C++
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
15
|
+
Classifier: Topic :: Internet :: Proxy Servers
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Dynamic: classifier
|
|
20
|
+
Dynamic: description
|
|
21
|
+
Dynamic: description-content-type
|
|
22
|
+
Dynamic: license
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
Dynamic: project-url
|
|
25
|
+
Dynamic: requires-python
|
|
26
|
+
Dynamic: summary
|
|
27
|
+
|
|
28
|
+
# sing-box-python
|
|
29
|
+
|
|
30
|
+
[](https://github.com/LorenEteval/sing-box-python/actions/workflows/build-and-publish.yml)
|
|
31
|
+
|
|
32
|
+
Python bindings for [sing-box](https://github.com/SagerNet/sing-box).
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
Prebuilt binary wheels include the native Go and C++ binding, so a supported installation does not require Go, CMake,
|
|
37
|
+
or a C++ compiler.
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
pip install sing-box-python
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Binary wheels are published for Linux x86-64 and ARM64, Windows x86-64 and ARM64, and macOS Intel and Apple Silicon.
|
|
44
|
+
|
|
45
|
+
### Build from Source
|
|
46
|
+
|
|
47
|
+
A source distribution is also published as a fallback. If pip cannot find a compatible wheel, it may build the native
|
|
48
|
+
binding from source. A source build requires:
|
|
49
|
+
|
|
50
|
+
* [Go 1.24.7](https://go.dev/doc/install) in `PATH`.
|
|
51
|
+
* A working C and C++ compiler toolchain.
|
|
52
|
+
* MinGW-w64 on Windows x86-64, or LLVM-MinGW on Windows ARM64, with `gcc` and `g++` available in `PATH`.
|
|
53
|
+
|
|
54
|
+
The isolated Python build environment installs CMake, pybind11, setuptools, and wheel automatically. To build directly
|
|
55
|
+
from a repository checkout:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
pip install .
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The build downloads sing-box's checksum-pinned, platform-specific Cronet Go module automatically. Wheels contain an
|
|
62
|
+
isolated Cronet runtime (`libcronet.dylib`, `libcronet.so`, or `libcronet.dll`), loaded from an absolute package path
|
|
63
|
+
during import. On macOS the build converts the pinned static archive into a separate dynamic library so Chromium's
|
|
64
|
+
private C++ runtime cannot conflict with pybind11.
|
|
65
|
+
|
|
66
|
+
## API
|
|
67
|
+
|
|
68
|
+
```pycon
|
|
69
|
+
>>> import singbox
|
|
70
|
+
>>> help(singbox)
|
|
71
|
+
Help on package singbox:
|
|
72
|
+
|
|
73
|
+
NAME
|
|
74
|
+
singbox - Native Python bindings for starting and managing sing-box.
|
|
75
|
+
|
|
76
|
+
PACKAGE CONTENTS
|
|
77
|
+
_native
|
|
78
|
+
|
|
79
|
+
CLASSES
|
|
80
|
+
builtins.RuntimeError(builtins.Exception)
|
|
81
|
+
singbox._native.SingBoxError
|
|
82
|
+
pybind11_builtins.pybind11_object(builtins.object)
|
|
83
|
+
singbox._native.SingBox
|
|
84
|
+
|
|
85
|
+
class SingBox(pybind11_builtins.pybind11_object)
|
|
86
|
+
| An explicitly managed, non-blocking in-process sing-box instance.
|
|
87
|
+
|
|
|
88
|
+
| Unlike the module-level startFromJSON function, this class reports startup
|
|
89
|
+
| errors as Python exceptions and does not wait for operating-system signals.
|
|
90
|
+
| Call stop explicitly or use the instance as a context manager.
|
|
91
|
+
|
|
|
92
|
+
| Methods defined here:
|
|
93
|
+
|
|
|
94
|
+
| __enter__(...)
|
|
95
|
+
| __enter__(self: singbox._native.SingBox) -> singbox._native.SingBox
|
|
96
|
+
|
|
|
97
|
+
| Return this instance for use as a context manager.
|
|
98
|
+
|
|
|
99
|
+
| __exit__(...)
|
|
100
|
+
| __exit__(self: singbox._native.SingBox, arg0: object, arg1: object, arg2: object) -> None
|
|
101
|
+
|
|
|
102
|
+
| Stop the instance when leaving a context-manager block.
|
|
103
|
+
|
|
|
104
|
+
| __init__(...)
|
|
105
|
+
| __init__(self: singbox._native.SingBox) -> None
|
|
106
|
+
|
|
|
107
|
+
| Create a stopped sing-box instance.
|
|
108
|
+
|
|
|
109
|
+
| queryStats(...)
|
|
110
|
+
| queryStats(self: singbox._native.SingBox, patterns: collections.abc.Sequence[str] = [], reset: bool = False, regexp: bool = False) -> dict
|
|
111
|
+
|
|
|
112
|
+
| Return available runtime, Clash, and V2Ray statistics as a dictionary.
|
|
113
|
+
|
|
|
114
|
+
| patterns filters V2Ray counters. reset clears matched V2Ray counters after
|
|
115
|
+
| reading, and regexp interprets patterns as regular expressions. Clash and
|
|
116
|
+
| V2Ray sections are None when their corresponding sing-box services are not
|
|
117
|
+
| enabled by the configuration. Runtime memory counters are always present.
|
|
118
|
+
|
|
|
119
|
+
| startFromJSON(...)
|
|
120
|
+
| startFromJSON(self: singbox._native.SingBox, json: str) -> None
|
|
121
|
+
|
|
|
122
|
+
| Start this instance from a UTF-8 JSON configuration string.
|
|
123
|
+
|
|
|
124
|
+
| The call returns after the service starts. Invalid configuration, construction,
|
|
125
|
+
| or startup errors raise SingBoxError. Starting an already-running instance
|
|
126
|
+
| raises RuntimeError.
|
|
127
|
+
|
|
|
128
|
+
| stop(...)
|
|
129
|
+
| stop(self: singbox._native.SingBox) -> None
|
|
130
|
+
|
|
|
131
|
+
| Stop the instance and release its native resources; repeated calls are safe.
|
|
132
|
+
|
|
|
133
|
+
| Readonly properties defined here:
|
|
134
|
+
|
|
|
135
|
+
| handle
|
|
136
|
+
| Opaque numeric instance identifier, or 0 while stopped.
|
|
137
|
+
|
|
|
138
|
+
| running
|
|
139
|
+
| Whether this instance currently owns a running native service.
|
|
140
|
+
|
|
141
|
+
class SingBoxError(builtins.RuntimeError)
|
|
142
|
+
| An error reported by the managed sing-box native lifecycle API.
|
|
143
|
+
|
|
144
|
+
FUNCTIONS
|
|
145
|
+
startFromJSON(...) method of pybind11_builtins.pybind11_detail_function_record instance
|
|
146
|
+
startFromJSON(json: str) -> None
|
|
147
|
+
|
|
148
|
+
Start sing-box from JSON and block until SIGINT or SIGTERM is received.
|
|
149
|
+
|
|
150
|
+
This process-oriented entry point is intended to be the target of a
|
|
151
|
+
multiprocessing.Process. Configuration decoding or construction failures exit
|
|
152
|
+
the process with status 23. Service startup failures call os.Exit(-1), whose
|
|
153
|
+
observed status is platform-dependent. Use SingBox for exception-based,
|
|
154
|
+
non-blocking in-process lifecycle management.
|
|
155
|
+
|
|
156
|
+
DATA
|
|
157
|
+
__all__ = ['SingBox', 'SingBoxError', '__version__', 'startFromJSON']
|
|
158
|
+
|
|
159
|
+
VERSION
|
|
160
|
+
v1.13.18
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Source Code Modification
|
|
164
|
+
|
|
165
|
+
This repository, including the package that distributes to pypi,
|
|
166
|
+
contains [sing-box](https://github.com/SagerNet/sing-box) source code and the additional binding code required to build
|
|
167
|
+
the Python extension and its API.
|
|
168
|
+
|
|
169
|
+
To make installation of this package easier, the original [sing-box](https://github.com/SagerNet/sing-box) source code
|
|
170
|
+
is embedded instead of being added as a submodule. The official source files are unchanged. The binding is implemented
|
|
171
|
+
by the added `singbox-go/binding` package and the C++/Python packaging files in this repository. To track the difference,
|
|
172
|
+
compare `singbox-go` with the upstream commit while excluding the added `binding` directory.
|
|
173
|
+
|
|
174
|
+
## Binary Wheel Platforms
|
|
175
|
+
|
|
176
|
+
The distributions are built and tested in [GitHub Actions](https://github.com/LorenEteval/sing-box-python/actions).
|
|
177
|
+
|
|
178
|
+
| Platform | Architecture | CPython |
|
|
179
|
+
|----------|--------------|---------|
|
|
180
|
+
| Linux | x86-64 | 3.8-3.14, 3.13t, 3.14t |
|
|
181
|
+
| Linux | ARM64 | 3.8-3.14, 3.13t, 3.14t |
|
|
182
|
+
| Windows | x86-64 | 3.8-3.14, 3.13t, 3.14t |
|
|
183
|
+
| Windows | ARM64 | 3.9-3.14, 3.13t, 3.14t |
|
|
184
|
+
| macOS | Intel | 3.8-3.14, 3.13t, 3.14t |
|
|
185
|
+
| macOS | Apple Silicon | 3.8-3.14, 3.13t, 3.14t |
|
|
186
|
+
|
|
187
|
+
Naive outbound is included on all wheel platforms in the table. Cronet is bundled as an isolated shared runtime on
|
|
188
|
+
macOS, Linux, and Windows. The macOS runtime is produced from the pinned static archive during the wheel build. The
|
|
189
|
+
Cronet artifact comes from the platform module and exact version already pinned by sing-box v1.13.18's `go.mod` and
|
|
190
|
+
verified by `go.sum`; the workflow does not build an unrelated Cronet revision.
|
|
191
|
+
Custom source builds can override the complete sing-box tag list with the `SINGBOX_BUILD_TAGS` environment variable.
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
The license for this project follows its original Go repository [sing-box](https://github.com/SagerNet/sing-box)
|
|
196
|
+
and is under [GNU GPL v3 or later](https://github.com/LorenEteval/sing-box-python/blob/main/LICENSE).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
sing_box_python-1.13.18.dist-info/licenses/LICENSE,sha256=uzgFhitYOu5zrW94BexjR0ejclemN6MGmFeEPwXqWJw,808
|
|
2
|
+
singbox/__init__.py,sha256=3Ov17SdLJ6wU_MCYiHPXKao-Ynt1w32a6OyT6NR4Umg,911
|
|
3
|
+
singbox/_native.cp313-win_amd64.pyd,sha256=JaLcLXIMm92Ufx9zcJCdbb6TdAN5RBiCy9dq83tIiFU,60217344
|
|
4
|
+
singbox/_native.pyi,sha256=T9u_5p7QRJVEMiymiHM03HrLF40ruRGYQVUn7WszaJc,672
|
|
5
|
+
singbox/libcronet.dll,sha256=JX-WYRn_ypHXos4RCktmi4ZdiL8u1TOf0GpWRLDQKCM,9528832
|
|
6
|
+
singbox/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
sing_box_python-1.13.18.dist-info/METADATA,sha256=vABrunCVtJt3KeH_LMnRxVrPXncmi24oU10gGFS7quM,8248
|
|
8
|
+
sing_box_python-1.13.18.dist-info/WHEEL,sha256=0LUNoHxLvcpw9db_x0XozE5jW73-_GOAO7fDDJ4Xt4Q,101
|
|
9
|
+
sing_box_python-1.13.18.dist-info/top_level.txt,sha256=Fnr72E7XDvIS6X0EVgT-uPHy38L9LthQv3vakhSOiXo,8
|
|
10
|
+
sing_box_python-1.13.18.dist-info/RECORD,,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Copyright (C) 2022 by nekohasekai <contact-sagernet@sekai.icu>
|
|
2
|
+
|
|
3
|
+
This program is free software: you can redistribute it and/or modify
|
|
4
|
+
it under the terms of the GNU General Public License as published by
|
|
5
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
(at your option) any later version.
|
|
7
|
+
|
|
8
|
+
This program is distributed in the hope that it will be useful,
|
|
9
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
GNU General Public License for more details.
|
|
12
|
+
|
|
13
|
+
You should have received a copy of the GNU General Public License
|
|
14
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
In addition, no derivative work may use the name or imply association
|
|
17
|
+
with this application without prior consent.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
singbox
|
singbox/__init__.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Native Python bindings for starting and managing sing-box."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path as _Path
|
|
4
|
+
|
|
5
|
+
from . import _native as _native
|
|
6
|
+
|
|
7
|
+
if hasattr(_native, "_loadCronetLibrary"):
|
|
8
|
+
_cronet_candidates = (
|
|
9
|
+
_Path(__file__).with_name("libcronet.dll"),
|
|
10
|
+
_Path(__file__).with_name("libcronet.dylib"),
|
|
11
|
+
_Path(__file__).with_name("libcronet.so"),
|
|
12
|
+
)
|
|
13
|
+
_cronet_path = next(
|
|
14
|
+
(candidate for candidate in _cronet_candidates if candidate.is_file()),
|
|
15
|
+
None,
|
|
16
|
+
)
|
|
17
|
+
if _cronet_path is None:
|
|
18
|
+
raise ImportError("the wheel-bundled Cronet runtime is missing")
|
|
19
|
+
_native._loadCronetLibrary(str(_cronet_path.resolve()))
|
|
20
|
+
|
|
21
|
+
SingBox = _native.SingBox
|
|
22
|
+
SingBoxError = _native.SingBoxError
|
|
23
|
+
__version__ = _native.__version__
|
|
24
|
+
startFromJSON = _native.startFromJSON
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"SingBox",
|
|
28
|
+
"SingBoxError",
|
|
29
|
+
"__version__",
|
|
30
|
+
"startFromJSON",
|
|
31
|
+
]
|
|
Binary file
|
singbox/_native.pyi
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from typing import Any, Sequence
|
|
2
|
+
|
|
3
|
+
class SingBoxError(RuntimeError): ...
|
|
4
|
+
|
|
5
|
+
class SingBox:
|
|
6
|
+
def __init__(self) -> None: ...
|
|
7
|
+
def startFromJSON(self, json: str) -> None: ...
|
|
8
|
+
def stop(self) -> None: ...
|
|
9
|
+
def queryStats(
|
|
10
|
+
self,
|
|
11
|
+
patterns: Sequence[str] = ...,
|
|
12
|
+
reset: bool = ...,
|
|
13
|
+
regexp: bool = ...,
|
|
14
|
+
) -> dict[str, Any]: ...
|
|
15
|
+
@property
|
|
16
|
+
def running(self) -> bool: ...
|
|
17
|
+
@property
|
|
18
|
+
def handle(self) -> int: ...
|
|
19
|
+
def __enter__(self) -> SingBox: ...
|
|
20
|
+
def __exit__(self, exc_type: object, exc: object, traceback: object) -> None: ...
|
|
21
|
+
|
|
22
|
+
def startFromJSON(json: str) -> None: ...
|
|
23
|
+
|
|
24
|
+
__version__: str
|
singbox/libcronet.dll
ADDED
|
Binary file
|
singbox/py.typed
ADDED
|
File without changes
|