-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
40 lines (30 loc) · 995 Bytes
/
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
# ---------------------------------------------------------------------
# Gufo Ping: ICMPv4/ICMPv6 ping implementation
# Python build
# ---------------------------------------------------------------------
# Copyright (C) 2022-23, Gufo Labs
# ---------------------------------------------------------------------
# Python modules
from typing import Optional, Sequence
import os
# Third-party modules
from setuptools import setup
from setuptools_rust import RustExtension
def _from_env(name: str) -> Optional[Sequence[str]]:
v = os.environ.get(name, "").strip()
if not v:
return None
return v.split()
def get_rustc_flags() -> Optional[Sequence[str]]:
return _from_env("BUILD_RUSTC_FLAGS")
def get_cargo_flags() -> Optional[Sequence[str]]:
return _from_env("BUILD_CARGO_FLAGS")
setup(
rust_extensions=[
RustExtension(
"gufo.ping._fast",
args=get_cargo_flags(),
rustc_flags=get_rustc_flags(),
)
],
)