sing-box-python 1.13.18__cp38-cp38-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.
@@ -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,188 @@
1
+ Metadata-Version: 2.1
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
+
20
+ # sing-box-python
21
+
22
+ [![Build and publish Python distributions](https://github.com/LorenEteval/sing-box-python/actions/workflows/build-and-publish.yml/badge.svg?branch=main)](https://github.com/LorenEteval/sing-box-python/actions/workflows/build-and-publish.yml)
23
+
24
+ Python bindings for [sing-box](https://github.com/SagerNet/sing-box).
25
+
26
+ ## Install
27
+
28
+ Prebuilt binary wheels include the native Go and C++ binding, so a supported installation does not require Go, CMake,
29
+ or a C++ compiler.
30
+
31
+ ```
32
+ pip install sing-box-python
33
+ ```
34
+
35
+ Binary wheels are published for Linux x86-64 and ARM64, Windows x86-64 and ARM64, and macOS Intel and Apple Silicon.
36
+
37
+ ### Build from Source
38
+
39
+ A source distribution is also published as a fallback. If pip cannot find a compatible wheel, it may build the native
40
+ binding from source. A source build requires:
41
+
42
+ * [Go 1.24.7](https://go.dev/doc/install) in `PATH`.
43
+ * A working C and C++ compiler toolchain.
44
+ * MinGW-w64 on Windows x86-64, or LLVM-MinGW on Windows ARM64, with `gcc` and `g++` available in `PATH`.
45
+
46
+ The isolated Python build environment installs CMake, pybind11, setuptools, and wheel automatically. To build directly
47
+ from a repository checkout:
48
+
49
+ ```
50
+ pip install .
51
+ ```
52
+
53
+ The build downloads sing-box's checksum-pinned, platform-specific Cronet Go module automatically. Wheels contain an
54
+ isolated Cronet runtime (`libcronet.dylib`, `libcronet.so`, or `libcronet.dll`), loaded from an absolute package path
55
+ during import. On macOS the build converts the pinned static archive into a separate dynamic library so Chromium's
56
+ private C++ runtime cannot conflict with pybind11.
57
+
58
+ ## API
59
+
60
+ ```pycon
61
+ >>> import singbox
62
+ >>> help(singbox)
63
+ Help on package singbox:
64
+
65
+ NAME
66
+ singbox - Native Python bindings for starting and managing sing-box.
67
+
68
+ PACKAGE CONTENTS
69
+ _native
70
+
71
+ CLASSES
72
+ builtins.RuntimeError(builtins.Exception)
73
+ singbox._native.SingBoxError
74
+ pybind11_builtins.pybind11_object(builtins.object)
75
+ singbox._native.SingBox
76
+
77
+ class SingBox(pybind11_builtins.pybind11_object)
78
+ | An explicitly managed, non-blocking in-process sing-box instance.
79
+ |
80
+ | Unlike the module-level startFromJSON function, this class reports startup
81
+ | errors as Python exceptions and does not wait for operating-system signals.
82
+ | Call stop explicitly or use the instance as a context manager.
83
+ |
84
+ | Methods defined here:
85
+ |
86
+ | __enter__(...)
87
+ | __enter__(self: singbox._native.SingBox) -> singbox._native.SingBox
88
+ |
89
+ | Return this instance for use as a context manager.
90
+ |
91
+ | __exit__(...)
92
+ | __exit__(self: singbox._native.SingBox, arg0: object, arg1: object, arg2: object) -> None
93
+ |
94
+ | Stop the instance when leaving a context-manager block.
95
+ |
96
+ | __init__(...)
97
+ | __init__(self: singbox._native.SingBox) -> None
98
+ |
99
+ | Create a stopped sing-box instance.
100
+ |
101
+ | queryStats(...)
102
+ | queryStats(self: singbox._native.SingBox, patterns: collections.abc.Sequence[str] = [], reset: bool = False, regexp: bool = False) -> dict
103
+ |
104
+ | Return available runtime, Clash, and V2Ray statistics as a dictionary.
105
+ |
106
+ | patterns filters V2Ray counters. reset clears matched V2Ray counters after
107
+ | reading, and regexp interprets patterns as regular expressions. Clash and
108
+ | V2Ray sections are None when their corresponding sing-box services are not
109
+ | enabled by the configuration. Runtime memory counters are always present.
110
+ |
111
+ | startFromJSON(...)
112
+ | startFromJSON(self: singbox._native.SingBox, json: str) -> None
113
+ |
114
+ | Start this instance from a UTF-8 JSON configuration string.
115
+ |
116
+ | The call returns after the service starts. Invalid configuration, construction,
117
+ | or startup errors raise SingBoxError. Starting an already-running instance
118
+ | raises RuntimeError.
119
+ |
120
+ | stop(...)
121
+ | stop(self: singbox._native.SingBox) -> None
122
+ |
123
+ | Stop the instance and release its native resources; repeated calls are safe.
124
+ |
125
+ | Readonly properties defined here:
126
+ |
127
+ | handle
128
+ | Opaque numeric instance identifier, or 0 while stopped.
129
+ |
130
+ | running
131
+ | Whether this instance currently owns a running native service.
132
+
133
+ class SingBoxError(builtins.RuntimeError)
134
+ | An error reported by the managed sing-box native lifecycle API.
135
+
136
+ FUNCTIONS
137
+ startFromJSON(...) method of pybind11_builtins.pybind11_detail_function_record instance
138
+ startFromJSON(json: str) -> None
139
+
140
+ Start sing-box from JSON and block until SIGINT or SIGTERM is received.
141
+
142
+ This process-oriented entry point is intended to be the target of a
143
+ multiprocessing.Process. Configuration decoding or construction failures exit
144
+ the process with status 23. Service startup failures call os.Exit(-1), whose
145
+ observed status is platform-dependent. Use SingBox for exception-based,
146
+ non-blocking in-process lifecycle management.
147
+
148
+ DATA
149
+ __all__ = ['SingBox', 'SingBoxError', '__version__', 'startFromJSON']
150
+
151
+ VERSION
152
+ v1.13.18
153
+ ```
154
+
155
+ ## Source Code Modification
156
+
157
+ This repository, including the package that distributes to pypi,
158
+ contains [sing-box](https://github.com/SagerNet/sing-box) source code and the additional binding code required to build
159
+ the Python extension and its API.
160
+
161
+ To make installation of this package easier, the original [sing-box](https://github.com/SagerNet/sing-box) source code
162
+ is embedded instead of being added as a submodule. The official source files are unchanged. The binding is implemented
163
+ by the added `singbox-go/binding` package and the C++/Python packaging files in this repository. To track the difference,
164
+ compare `singbox-go` with the upstream commit while excluding the added `binding` directory.
165
+
166
+ ## Binary Wheel Platforms
167
+
168
+ The distributions are built and tested in [GitHub Actions](https://github.com/LorenEteval/sing-box-python/actions).
169
+
170
+ | Platform | Architecture | CPython |
171
+ |----------|--------------|---------|
172
+ | Linux | x86-64 | 3.8-3.14, 3.13t, 3.14t |
173
+ | Linux | ARM64 | 3.8-3.14, 3.13t, 3.14t |
174
+ | Windows | x86-64 | 3.8-3.14, 3.13t, 3.14t |
175
+ | Windows | ARM64 | 3.9-3.14, 3.13t, 3.14t |
176
+ | macOS | Intel | 3.8-3.14, 3.13t, 3.14t |
177
+ | macOS | Apple Silicon | 3.8-3.14, 3.13t, 3.14t |
178
+
179
+ Naive outbound is included on all wheel platforms in the table. Cronet is bundled as an isolated shared runtime on
180
+ macOS, Linux, and Windows. The macOS runtime is produced from the pinned static archive during the wheel build. The
181
+ Cronet artifact comes from the platform module and exact version already pinned by sing-box v1.13.18's `go.mod` and
182
+ verified by `go.sum`; the workflow does not build an unrelated Cronet revision.
183
+ Custom source builds can override the complete sing-box tag list with the `SINGBOX_BUILD_TAGS` environment variable.
184
+
185
+ ## License
186
+
187
+ The license for this project follows its original Go repository [sing-box](https://github.com/SagerNet/sing-box)
188
+ and is under [GNU GPL v3 or later](https://github.com/LorenEteval/sing-box-python/blob/main/LICENSE).
@@ -0,0 +1,10 @@
1
+ singbox/__init__.py,sha256=3Ov17SdLJ6wU_MCYiHPXKao-Ynt1w32a6OyT6NR4Umg,911
2
+ singbox/_native.cp38-win_amd64.pyd,sha256=bThhDfUHANuOqjIJgE7GWoBf9pNt_8QGBJaziyaXd6Q,60207616
3
+ singbox/_native.pyi,sha256=T9u_5p7QRJVEMiymiHM03HrLF40ruRGYQVUn7WszaJc,672
4
+ singbox/libcronet.dll,sha256=JX-WYRn_ypHXos4RCktmi4ZdiL8u1TOf0GpWRLDQKCM,9528832
5
+ singbox/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ sing_box_python-1.13.18.dist-info/LICENSE,sha256=uzgFhitYOu5zrW94BexjR0ejclemN6MGmFeEPwXqWJw,808
7
+ sing_box_python-1.13.18.dist-info/METADATA,sha256=lXGFmMEjqQnxQ628b2X9es1OCks7gxtO1kDan3AhOi4,8063
8
+ sing_box_python-1.13.18.dist-info/WHEEL,sha256=TFndZn0SXD1XqMUEIKDojL47weLF1ldHBOPnF9B_sLo,99
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,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.3.4)
3
+ Root-Is-Purelib: false
4
+ Tag: cp38-cp38-win_amd64
5
+
@@ -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