Skip to content

LorenEteval/hysteria2-python

Repository files navigation

hysteria2-python

Deploy PyPI

Python bindings for hysteria2.

Install

Core Building Tools

You have to install the following tools to be able to install this package successfully.

Note: hysteria2 v2.0.3+ requires at least go 1.21, which means hysteria2-python will also need go 1.21+ to be able to build and install successfully since v2.0.3.

  • go in your PATH. go 1.20.0 and above is recommended. To check go is ready, type go version. Also, if google service is blocked in your region(such as Mainland China), you have to configure your GOPROXY to be able to pull go packages. For Chinese users, refer to goproxy.cn for more information.

  • cmake in your PATH. To check cmake is ready, type cmake --version.

  • A working GNU C++ compiler(i.e. GNU C++ toolchains). To check GNU C++ compiler is ready, type g++ --version. These tools should have been installed in Linux or macOS by default. If you don't have GNU C++ toolchains(especially for Windows users) anyway:

    • For Linux users: type sudo apt update && sudo apt install g++ and that should work out fine.
    • For Windows users: install MinGW-w64 or Cygwin and make sure you have add them to PATH.

Install Package

pip install hysteria2

API

>>> import hysteria2
>>> help(hysteria2) 
Help on package hysteria2:                                                                                                                                                                                    

NAME
    hysteria2

PACKAGE CONTENTS
    hysteria2

FUNCTIONS
    startFromJSON(...) method of builtins.PyCapsule instance
        startFromJSON(json: str) -> None

        Start Hysteria2 client with JSON

Source Code Modification

This repository, including the package that distributes to pypi, contains hysteria source code that's been modified to build the binding and specific API. If without explicitly remark, the version of this package corresponds to the version of the origin source code tag, so the binding will have full features as the original go distribution will have. And due to its backward compatibility, there's no plan to generate bindings for older release of hysteria.

To make installation of this package easier, I didn't add the original hysteria source code as a submodule. To track what modifications have been made to the source code, you can compare it with the same version under Python binding and corresponding go repository.

Tested Platform

hysteria2-python works on all major platform with all Python version(Python 3).

Below are tested build in github actions.

Platform Python 3.7-Python 3.11
ubuntu 20.04 ✔️
ubuntu 22.04 ✔️
windows-2019 ✔️
windows-2022 ✔️
macos-11 ✔️
macos-12 ✔️
macos-13 ✔️

License

The license for this project follows its original go repository hysteria and is under MIT License.