11from setuptools import setup , find_packages , Extension
22from setuptools .command .build_ext import build_ext
3+ from wheel .bdist_wheel import bdist_wheel as _bdist_wheel
34import os
45import platform
56import shutil
67import versioneer
78
9+
810class CustomBuildExt (build_ext ):
911 """Custom build command to handle library file copying and platform-specific compilation."""
1012
@@ -60,6 +62,20 @@ def copy_extensions_to_package(self):
6062 print (f"Copied { built_lib } to { dest_path } " )
6163
6264
65+ class BDistWheel (_bdist_wheel ):
66+ """Custom bdist_wheel to ensure platform-specific tagging."""
67+
68+ def finalize_options (self ):
69+ super ().finalize_options ()
70+ self .root_is_pure = False # Indicate this is not a pure Python package
71+ if platform .system () == 'Linux' :
72+ self .plat_name = 'manylinux2014_x86_64' # Use a compliant platform tag
73+ elif platform .system () == 'Darwin' :
74+ self .plat_name = 'macosx_11_0_arm64' # Example for macOS
75+ elif platform .system () == 'Windows' :
76+ self .plat_name = 'win_amd64' # Example for Windows
77+
78+
6379# Define the extension module
6480grpo_module = Extension (
6581 'optimrl.c_src.libgrpo' ,
@@ -78,7 +94,8 @@ def copy_extensions_to_package(self):
7894 version = versioneer .get_version (),
7995 cmdclass = {
8096 ** versioneer .get_cmdclass (),
81- 'build_ext' : CustomBuildExt
97+ 'build_ext' : CustomBuildExt ,
98+ 'bdist_wheel' : BDistWheel
8299 },
83100 author = "Subashanan Nair" ,
84101@@ -99,6 +116,6 @@ def copy_extensions_to_package(self):
99116 python_requires = ">=3.8" ,
100117 include_package_data = True ,
101118 package_data = {
102- 'optimrl' : ['c_src/.dylib' , 'c_src/.so' , 'c_src/.dll' , 'c_src/ *.h' , 'c_src/*.c' ]
119+ 'optimrl' : ['c_src/*.h' , 'c_src/*.c' ]
103120 },
104121)
0 commit comments