-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
32 lines (26 loc) · 893 Bytes
/
setup.py
File metadata and controls
32 lines (26 loc) · 893 Bytes
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
from setuptools import setup
from pathlib import Path
import os
def find_python_files(directory: str) -> list[str]:
python_files: list[str] = []
for file in Path(directory).rglob("*.py"):
python_files.append(str(file))
return python_files
# OPTIONALLY USE MYPYC COMPILATION
ext_modules = []
if os.environ.get("XULBUX_USE_MYPYC", "1") == "1":
try:
from mypyc.build import mypycify
print("\nCompiling with mypyc...\n")
source_files = find_python_files("src/xulbux")
ext_modules = mypycify(source_files)
except (ImportError, Exception) as e:
fmt_error = "\n ".join(str(e).splitlines())
print(
f"\n[WARNING] mypyc compilation disabled (not available or failed):\n {fmt_error}\n"
"\nInstalling as pure Python package...\n"
)
setup(
name="xulbux",
ext_modules=ext_modules,
)