-
Notifications
You must be signed in to change notification settings - Fork 14
/
setup.py
91 lines (84 loc) · 2.53 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
import json
import logging
import os
import platform
from subprocess import run
from pathlib import Path
from setuptools import setup
from pybind11.setup_helpers import Pybind11Extension, build_ext
include_dirs = [
"src",
os.path.join("vroom", "src"),
os.path.join("vroom", "include"),
os.path.join("vroom", "include", "cxxopts", "include"),
]
libraries = []
library_dirs = []
if platform.system() == "Windows":
extra_compile_args = [
"-DNOGDI",
"-DNOMINMAX",
"-DWIN32_LEAN_AND_MEAN",
"-DASIO_STANDALONE",
"-DUSE_PYTHON_BINDINGS",
"-DUSE_ROUTING=true"
]
extra_link_args = []
else: # anything *nix
extra_compile_args = [
"-MMD",
"-MP",
"-Wextra",
"-Wpedantic",
"-Wall",
"-O3",
"-DASIO_STANDALONE",
"-DNDEBUG",
"-DUSE_PYTHON_BINDINGS",
"-DUSE_ROUTING=true"
]
extra_link_args = [
"-lpthread",
"-lssl",
"-lcrypto",
]
if platform.system() == "Darwin":
# Homebrew puts include folders in weird places.
prefix = run(["brew", "--prefix"], capture_output=True).stdout.decode("utf-8")[:-1]
include_dirs.append(f"{prefix}/opt/[email protected]/include")
include_dirs.append(f"{prefix}/include")
extra_link_args.insert(0, f"-L{prefix}/lib")
extra_link_args.insert(0, f"-L{prefix}/opt/[email protected]/lib")
extra_link_args.append(f"-Wl,-ld_classic")
# try conan dependency resolution
conanfile = tuple(Path(__file__).parent.resolve().rglob("conanbuildinfo.json"))
if conanfile:
logging.info("Using conan to resolve dependencies.")
with conanfile[0].open() as f:
conan_deps = json.load(f)["dependencies"]
for dep in conan_deps:
include_dirs.extend(dep["include_paths"])
libraries.extend(dep["libs"])
libraries.extend(dep["system_libs"])
library_dirs.extend(dep["lib_paths"])
else:
logging.warning("Conan not installed and/or no conan build detected. Assuming dependencies are installed.")
ext_modules = [
Pybind11Extension(
"_vroom",
[os.path.join("src", "_vroom.cpp")],
library_dirs=library_dirs,
libraries=libraries,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
cxx_std=20
),
]
setup(
cmdclass={"build_ext": build_ext},
ext_modules=ext_modules,
ext_package="vroom",
include_dirs=include_dirs,
use_scm_version=True,
entry_points={"console_scripts": ["vroom=vroom:main"]},
)