-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetup.py
More file actions
105 lines (88 loc) · 3.36 KB
/
setup.py
File metadata and controls
105 lines (88 loc) · 3.36 KB
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
import os
import subprocess
import sys
import platform
from pathlib import Path
import setuptools
from setuptools import setup
from setuptools.command.build_ext import build_ext
from setuptools_rust import Binding, RustExtension, Strip
if "RUSTFLAGS" not in os.environ:
machine = platform.machine()
if machine == "x86_64":
print("Enabling x86-64-v3 optimizations (AVX2/FMA)")
os.environ["RUSTFLAGS"] = "-C target-cpu=x86-64-v3"
class BuildCtypesExt(build_ext):
def run(self):
super().run()
self.build_custom_cpp()
def build_custom_cpp(self):
compiler = "g++"
if hasattr(self, 'compiler') and self.compiler:
if hasattr(self.compiler, 'compiler_cxx'):
compiler = self.compiler.compiler_cxx[0]
lib_dir = Path(self.build_lib)
output_path = lib_dir / "pixelflux" / "screen_capture_module.so"
output_path.parent.mkdir(parents=True, exist_ok=True)
sources = [
'pixelflux/screen_capture_module.cpp',
'pixelflux/include/xxhash.c'
]
include_dirs = ['pixelflux/include']
library_dirs = []
if os.environ.get("CIBUILDWHEEL"):
include_dirs.append('/usr/local/include')
library_dirs.append('/usr/local/lib')
libraries = ['X11', 'Xext', 'Xfixes', 'jpeg', 'x264', 'yuv', 'dl', 'avcodec', 'avutil']
extra_compile_args = ['-std=c++17', '-Wno-unused-function', '-fPIC', '-O3', '-flto', '-shared']
command = [compiler] + extra_compile_args + ['-o', str(output_path)]
for inc in include_dirs: command.append(f'-I{inc}')
for lib in library_dirs: command.append(f'-L{lib}')
command.extend(sources)
for lib in libraries: command.append(f'-l{lib}')
print(f"Building C++ module: {' '.join(command)}")
try:
subprocess.check_call(command)
except subprocess.CalledProcessError as e:
print(f"C++ build failed with exit code {e.returncode}")
sys.exit(1)
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
install_requires = []
is_alpine = os.path.exists("/etc/alpine-release")
if not is_alpine:
install_requires.append("nvidia-cuda-nvrtc")
setup(
name="pixelflux",
install_requires=install_requires,
version="1.6.2",
author="Linuxserver.io",
author_email="pypi@linuxserver.io",
description="A performant web native pixel delivery pipeline for diverse sources, blending VNC-inspired parallel processing of pixel buffers with flexible modern encoding formats.",
long_description=long_description,
long_description_content_type="text/markdown",
license="MPL-2.0",
url="https://github.com/linuxserver/pixelflux",
packages=setuptools.find_packages(),
rust_extensions=[
RustExtension(
"pixelflux.pixelflux_wayland",
"pixelflux_wayland/Cargo.toml",
binding=Binding.PyO3,
debug=False,
strip=Strip.All
)
],
cmdclass={
"build_ext": BuildCtypesExt,
},
package_data={
"pixelflux": ["screen_capture_module.so"],
},
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: POSIX :: Linux",
],
python_requires=">=3.6",
zip_safe=False,
)