@@ -48,27 +48,41 @@ def build_extensions(self):
4848
4949 def copy_extensions_to_package (self ):
5050 """Copy the built extension to the package directory."""
51+ # for ext in self.extensions:
52+ # # Get the full path of the built library
53+ # built_lib = self.get_ext_fullpath(ext.name)
54+
55+ # # Determine the destination directory within the package
56+ # dest_dir = os.path.join('optimrl', 'c_src')
57+ # os.makedirs(dest_dir, exist_ok=True)
58+
59+ # # Get the filename only
60+ # filename = os.path.basename(built_lib)
61+
62+ # # Create platform-specific library name
63+ # if platform.system() == 'Darwin':
64+ # lib_name = 'libgrpo.dylib'
65+ # elif platform.system() == 'Linux':
66+ # lib_name = 'libgrpo.so'
67+ # else:
68+ # lib_name = 'libgrpo.dll'
69+
70+ # # Copy the file to the package directory with the correct name
71+ # dest_path = os.path.join(dest_dir, lib_name)
72+ # shutil.copy2(built_lib, dest_path)
73+ # print(f"Copied {built_lib} to {dest_path}")
5174 for ext in self .extensions :
52- # Get the full path of the built library
75+ # Get the full path of the built library
5376 built_lib = self .get_ext_fullpath (ext .name )
5477
5578 # Determine the destination directory within the package
5679 dest_dir = os .path .join ('optimrl' , 'c_src' )
5780 os .makedirs (dest_dir , exist_ok = True )
5881
59- # Get the filename only
82+ # Keep the existing file name (e.g., libgrpo.cp310-win_amd64.pyd)
6083 filename = os .path .basename (built_lib )
6184
62- # Create platform-specific library name
63- if platform .system () == 'Darwin' :
64- lib_name = 'libgrpo.dylib'
65- elif platform .system () == 'Linux' :
66- lib_name = 'libgrpo.so'
67- else :
68- lib_name = 'libgrpo.dll'
69-
70- # Copy the file to the package directory with the correct name
71- dest_path = os .path .join (dest_dir , lib_name )
85+ dest_path = os .path .join (dest_dir , filename )
7286 shutil .copy2 (built_lib , dest_path )
7387 print (f"Copied { built_lib } to { dest_path } " )
7488
@@ -87,22 +101,6 @@ def finalize_options(self):
87101 self .plat_name = 'win_amd64' # Example for Windows
88102
89103
90- # Define the extension module
91-
92- # grpo_module = Extension(
93- # 'optimrl.c_src.libgrpo',
94- # sources=['optimrl/c_src/grpo.c'],
95- # include_dirs=[
96- # 'optimrl/c_src',
97- # python_include_path
98- # ],
99- # library_dirs=[
100- # python_lib_path # Include the Python library path dynamically
101- # ],
102- # libraries=['m'] if platform.system() != 'Windows' else [],
103- # extra_compile_args=['-O3', '-fPIC'] if platform.system() != 'Windows' else ['/O2'],
104- # extra_link_args=['-L' + python_lib_path] if platform.system() != 'Windows' else ['/EXPORT:PyInit_libgrpo']
105- # )
106104grpo_module = Extension (
107105 'optimrl.c_src.libgrpo' ,
108106 sources = ['optimrl/c_src/grpo.c' ],
0 commit comments