-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
113 lines (91 loc) · 2.68 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
from setuptools import setup, find_packages
from setuptools.command.install import install
import pathlib
import platform
import subprocess
PLATFORM = platform.system()
ROOT_DIR = pathlib.Path().resolve()
PACKAGE_NAME = 'hysteria2'
BINDING_NAME = 'hysteria2'
CMAKE_BUILD_CACHE = 'CMakeBuildCache'
def getHysteriaVersion():
return '2.5.2'
def runCommand(command):
subprocess.run(command, check=True)
def buildHysteria():
output = f'{BINDING_NAME}.lib' if PLATFORM == 'Windows' else f'{BINDING_NAME}.a'
runCommand(
[
'go',
'build',
'-C',
'hysteria2-go',
'-o',
f'{ROOT_DIR / "gobuild" / output}',
'-buildmode=c-archive',
'-trimpath',
'-ldflags',
'-s -w -buildid=',
'./app',
]
)
def buildBindings():
configureCache = [
'cmake',
'-S',
'.',
'-B',
CMAKE_BUILD_CACHE,
'-DCMAKE_BUILD_TYPE=Release',
]
if PLATFORM == 'Windows':
configureCache += ['-G', 'MinGW Makefiles']
runCommand(configureCache)
runCommand(
[
'cmake',
'--build',
CMAKE_BUILD_CACHE,
'--target',
BINDING_NAME,
]
)
class InstallHysteria(install):
def run(self):
buildHysteria()
buildBindings()
install.run(self)
with open('README.md', 'r', encoding='utf-8') as file:
long_description = file.read()
setup(
name=PACKAGE_NAME,
version=getHysteriaVersion(),
license='MIT',
description='Python bindings for hysteria2.',
long_description=long_description,
long_description_content_type='text/markdown',
author='Loren Eteval',
author_email='loren.eteval@proton.me',
url='https://github.com/LorenEteval/hysteria2-python',
cmdclass={'install': InstallHysteria},
packages=find_packages(),
include_package_data=True,
classifiers=[
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: MIT License',
'Intended Audience :: Developers',
'Programming Language :: C++',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Operating System :: OS Independent',
'Topic :: Internet',
'Topic :: Internet :: Proxy Servers',
],
zip_safe=False,
)