-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
67 lines (59 loc) · 2.1 KB
/
Copy pathsetup.py
File metadata and controls
67 lines (59 loc) · 2.1 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
import os
import shutil
from setuptools import setup
from pybind11.setup_helpers import Pybind11Extension, build_ext
from setuptools.command.build_ext import build_ext as build_ext_orig
# Define the C++ source files for the extension
sources = [
'bindings/metric_bindings.cpp',
'src/histogram.cpp',
'src/tpc_monitor.cpp',
'src/tpc_monitor_lbw.cpp',
'src/tpc_configs.cpp',
'src/daq_comp_monitor.cpp',
'src/tpc_readout_monitor.cpp',
'src/tpc_monitor_charge_event.cpp',
'src/tpc_monitor_light_event.cpp'
]
ext_modules = [
Pybind11Extension(
"datamon", # Name of the module in Python
sources,
include_dirs=['include', 'comm_codes'],
# Define the C++ standard to use
cxx_std=17,
define_macros=[('USE_PYTHON', '1')]
),
]
class CustomBuildExt(build_ext_orig):
"""A custom build_ext command to clean up previous builds."""
def run(self):
# --- Your Custom Cleaning Logic ---
print("🧹 Running custom clean step")
# List of directories to remove
directories_to_remove = ['./build', './dist']
for directory in directories_to_remove:
if os.path.exists(directory):
print(f" - Removing directory: {directory}")
shutil.rmtree(directory)
# We also need to find and remove the .egg-info directory
# It's usually in the project root
for item in os.listdir('.'):
if item.endswith('.egg-info'):
egg_info_dir = os.path.join('.', item)
print(f" - Removing directory: {egg_info_dir}")
shutil.rmtree(egg_info_dir)
# --- Call the original build_ext command ---
print("✨ Proceeding with the original build...")
super().run()
setup(
name='datamon',
version='0.1.0',
author='Your Name',
description='Python bindings for the data monitoring library',
ext_modules=ext_modules,
# The build_ext command from pybind11.setup_helpers handles compiler flags
cmdclass={"build_ext": CustomBuildExt},
zip_safe=False,
python_requires=">=3.7",
)