@@ -55,28 +55,6 @@ def get_pre_installed_header_include() -> list[str]:
55
55
return []
56
56
57
57
58
- def get_conda_include () -> list [str ]:
59
- """
60
- Get conda include path, if we are inside conda environment
61
-
62
- Returns:
63
- either empty list or a list of header paths
64
- """
65
- include_paths = []
66
- # in the conda build system the system root is defined in CONDA_PREFIX or BUILD_PREFIX
67
- for prefix in ["CONDA_PREFIX" , "BUILD_PREFIX" ]:
68
- if prefix in os .environ :
69
- conda_path = os .environ [prefix ]
70
- if if_win :
71
- # windows has Library folder prefix
72
- include_paths .append (os .path .join (conda_path , "Library" , "include" ))
73
- include_paths .append (os .path .join (conda_path , "Library" , "include" , "eigen3" ))
74
- else :
75
- include_paths .append (os .path .join (conda_path , "include" ))
76
- include_paths .append (os .path .join (conda_path , "include" , "eigen3" ))
77
- return include_paths
78
-
79
-
80
58
# custom class for ctypes
81
59
class CTypesExtension (Extension ):
82
60
pass
@@ -150,6 +128,23 @@ def generate_build_ext(pkg_dir: Path, pkg_name: str):
150
128
Returns:
151
129
152
130
"""
131
+ pkg_bin_dir = pkg_dir / "src" / pkg_name
132
+ # remove old extension build
133
+ build_dir = pkg_dir / "build"
134
+ if build_dir .exists ():
135
+ shutil .rmtree (build_dir )
136
+ # remove binary
137
+ bin_files = list (chain (pkg_bin_dir .rglob ("*.so" ), pkg_bin_dir .rglob ("*.dll" ), pkg_bin_dir .rglob ("*.dylib" )))
138
+ for bin_file in bin_files :
139
+ print (f"Remove binary file: { bin_file } " )
140
+ bin_file .unlink ()
141
+
142
+ # By setting POWER_GRID_MODEL_NO_BINARY_BUILD we do not build the extension.
143
+ # This is usually set in conda-build recipe, so conda build process only wraps the pure Python package.
144
+ # As a user or developer, DO NOT set this environment variable unless you really know what you are doing.
145
+ if "POWER_GRID_MODEL_NO_BINARY_BUILD" in os .environ :
146
+ return {}
147
+
153
148
# fetch dependent headers
154
149
pgm = Path ("power_grid_model" )
155
150
pgm_c = Path ("power_grid_model_c" )
@@ -161,7 +156,6 @@ def generate_build_ext(pkg_dir: Path, pkg_name: str):
161
156
]
162
157
include_dirs += get_required_dependency_include ()
163
158
include_dirs += get_pre_installed_header_include ()
164
- include_dirs += get_conda_include ()
165
159
# compiler and link flag
166
160
cflags : list [str ] = []
167
161
lflags : list [str ] = []
@@ -179,17 +173,6 @@ def generate_build_ext(pkg_dir: Path, pkg_name: str):
179
173
define_macros = [
180
174
("EIGEN_MPL2_ONLY" , "1" ), # only MPL-2 part of eigen3
181
175
]
182
- pkg_bin_dir = pkg_dir / "src" / pkg_name
183
-
184
- # remove old extension build
185
- build_dir = pkg_dir / "build"
186
- if build_dir .exists ():
187
- shutil .rmtree (build_dir )
188
- # remove binary
189
- bin_files = list (chain (pkg_bin_dir .rglob ("*.so" ), pkg_bin_dir .rglob ("*.dll" )))
190
- for bin_file in bin_files :
191
- print (f"Remove binary file: { bin_file } " )
192
- bin_file .unlink ()
193
176
194
177
# build steps for Windows and Linux
195
178
# different treat for windows and linux
0 commit comments