Skip to content

Commit daf94bc

Browse files
committed
Fix build_ext configuration and include path issues
1 parent 28d32a0 commit daf94bc

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

setup.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import versioneer
88
import sysconfig
99

10-
# Get the Python include path dynamically
10+
# Get the Python include and library paths dynamically
1111
python_include_path = sysconfig.get_path('include')
1212
python_lib_path = sysconfig.get_config_var('LIBDIR')
1313

@@ -86,10 +86,16 @@ def finalize_options(self):
8686
grpo_module = Extension(
8787
'optimrl.c_src.libgrpo',
8888
sources=['optimrl/c_src/grpo.c'],
89-
include_dirs=['optimrl/c_src',python_include_path],
89+
include_dirs=[
90+
'optimrl/c_src',
91+
python_include_path
92+
],
93+
library_dirs=[
94+
python_lib_path # Include the Python library path dynamically
95+
],
9096
libraries=['m'] if platform.system() != 'Windows' else [],
9197
extra_compile_args=['-O3', '-fPIC'] if platform.system() != 'Windows' else ['/O2'],
92-
extra_link_args=[] if platform.system() != 'Windows' else ['/EXPORT:PyInit_libgrpo']
98+
extra_link_args=['-L' + python_lib_path] if platform.system() != 'Windows' else ['/EXPORT:PyInit_libgrpo']
9399
)
94100

95101
# Read the README file

0 commit comments

Comments
 (0)