|
| 1 | + |
1 | 2 | # setup.py |
2 | | -import sys, subprocess, shutil |
| 3 | +import subprocess, shutil |
3 | 4 | from pathlib import Path |
4 | 5 | from setuptools import setup |
5 | 6 | from setuptools.command.build_py import build_py as _build_py |
|
8 | 9 | class BinaryDistWheel(bdist_wheel): |
9 | 10 | def finalize_options(self): |
10 | 11 | super().finalize_options() |
11 | | - self.root_is_pure = False # wheel is platform-specific |
| 12 | + self.root_is_pure = False # platform-specific wheel |
12 | 13 |
|
13 | 14 | class build_py(_build_py): |
14 | 15 | def run(self): |
| 16 | + # Build python modules into build_lib first |
15 | 17 | super().run() |
16 | 18 |
|
17 | | - project_root = Path(__file__).resolve().parent |
18 | | - mstplib_dir = project_root / "misty" / "mstplib" |
19 | | - if not (mstplib_dir / "Makefile").exists(): |
20 | | - raise RuntimeError(f"Makefile not found in {mstplib_dir}") |
21 | | - |
22 | | - # 1) Compile using your Makefile target |
23 | | - print(f"[misty] make clean_build in {mstplib_dir}") |
24 | | - subprocess.check_call(["make", "clean_build"], cwd=str(mstplib_dir)) |
| 19 | + root = Path(__file__).resolve().parent |
| 20 | + src_dir = root / "src" # <-- your flat C src dir |
| 21 | + so_path = src_dir / "build" / "libmstp_agent.so" |
25 | 22 |
|
26 | | - # 2) We build a single canonical filename on all platforms |
27 | | - found = mstplib_dir / "libmstp_agent.so" |
28 | | - if not found.exists(): |
29 | | - raise RuntimeError("Expected misty/mstplib/libmstp_agent.so after build") |
| 23 | + # Compile the shared library into src/build/ |
| 24 | + print(f"[misty] make clean_build in {src_dir}") |
| 25 | + subprocess.check_call(["make", "clean_build"], cwd=str(src_dir)) |
30 | 26 |
|
| 27 | + if not so_path.exists(): |
| 28 | + raise RuntimeError(f"Expected {so_path} after build") |
31 | 29 |
|
32 | | - # 3) Copy into the built package so it lands in the wheel |
| 30 | + # Copy the .so into the package in the build tree so it lands in the wheel |
33 | 31 | pkg_out = Path(self.build_lib) / "misty" / "mstplib" |
34 | 32 | pkg_out.mkdir(parents=True, exist_ok=True) |
35 | | - shutil.copy2(found, pkg_out / found.name) |
36 | | - print(f"[misty] bundled {found.name} -> {pkg_out}") |
37 | | - |
| 33 | + shutil.copy2(so_path, pkg_out / "libmstp_agent.so") |
| 34 | + print(f"[misty] bundled libmstp_agent.so -> {pkg_out}") |
38 | 35 |
|
39 | 36 | def setup_packages(): |
40 | 37 | setup( |
41 | 38 | name="misty", |
42 | | - version="0.0.15", # bump |
| 39 | + version="0.0.16", # bump when publishing |
43 | 40 | description="MSTP support for bacpypes", |
44 | | - long_description=( |
45 | | - "The misty package helps build bacpypes Applications that work on MS/TP Networks. " |
46 | | - "BIP (BACnet/IP) applications can be easily ported to use misty." |
47 | | - ), |
| 41 | + long_description="The misty package helps build bacpypes Applications that work on MS/TP Networks.", |
48 | 42 | license="GNU General Public License v2.0", |
49 | 43 | author="Riptide, Inc", |
50 | 44 | author_email="raghavan@riptideio.com", |
51 | 45 | url="https://github.com/riptideio/misty", |
52 | 46 | packages=["misty", "misty.mstplib"], |
53 | 47 | package_dir={"misty": "misty"}, |
54 | 48 | cmdclass={"bdist_wheel": BinaryDistWheel, "build_py": build_py}, |
| 49 | + include_package_data=False, # MANIFEST.in will NOT affect wheel contents |
| 50 | + # package_data not required because we copy the .so into build_lib above |
55 | 51 | install_requires=["bacpypes>=0.18.0", "six>=1.15.0"], |
56 | | - scripts=[], |
57 | | - |
58 | | - include_package_data=False, # MANIFEST.in will NOT affect the wheel |
59 | | - package_data={"misty": ["mstplib/libmstp_agent.so"]}, |
60 | | - zip_safe=False |
| 52 | + zip_safe=False, |
61 | 53 | ) |
62 | 54 |
|
63 | 55 | if __name__ == "__main__": |
|
0 commit comments