-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathsetup.py
More file actions
68 lines (57 loc) · 1.89 KB
/
setup.py
File metadata and controls
68 lines (57 loc) · 1.89 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
"""
Setup script to install the FastFEC python package
"""
import os
import shutil
import subprocess
import sys
from glob import glob
from setuptools import setup
# get current directory
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
PARENT_DIR = os.path.dirname(CURRENT_DIR)
with open(os.path.join(PARENT_DIR, "README.md"), "r") as f:
readme = f.read()
with open(os.path.join(PARENT_DIR, "VERSION"), "r") as f:
version = f.read().strip()
def compile_library():
subprocess.call(
[sys.executable, "-m", "ziglang", "build", "-Dlib-only=true"], cwd=PARENT_DIR
)
compile_library()
library_dir = os.path.join(PARENT_DIR, "zig-out/lib")
# Collect compiled library files (extension .dylib|.so|.dll)
raw_library_files = (
glob(os.path.join(library_dir, "*.dylib"))
+ glob(os.path.join(library_dir, "*.so"))
+ glob(os.path.join(library_dir, "*.dll"))
)
# Copy them into the Python project src directory and get their relative paths
library_files = [
os.path.basename(shutil.copy(library_file, os.path.join(CURRENT_DIR, "src")))
for library_file in raw_library_files
]
# Force building a non-pure lib wheel
# From https://stackoverflow.com/a/45150383
try:
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
class bdist_wheel(_bdist_wheel):
def finalize_options(self):
_bdist_wheel.finalize_options(self)
self.root_is_pure = False
except ImportError:
bdist_wheel = None
setup(
name="fastfec",
version=version,
description="An extremely fast FEC filing parser written in C",
long_description=readme,
long_description_content_type="text/markdown",
author="Washington Post News Engineering",
license="MIT",
url="https://github.com/washingtonpost/FastFEC",
packages=["fastfec"],
package_data={"fastfec": library_files},
package_dir={"": "src"},
cmdclass={"bdist_wheel": bdist_wheel},
)