Commits

Tarek Ziadé committed 724cafa

fixed #6459: distutils.command.build_ext.get_export_symbols now uses 'PyInit'

Comments (0)

Files changed (2)

command/build_ext.py

     def get_export_symbols(self, ext):
         """Return the list of symbols that a shared extension has to
         export.  This either uses 'ext.export_symbols' or, if it's not
-        provided, "init" + module_name.  Only relevant on Windows, where
-        the .pyd file (DLL) must export the module "init" function.
+        provided, "PyInit_" + module_name.  Only relevant on Windows, where
+        the .pyd file (DLL) must export the module "PyInit_" function.
         """
-        initfunc_name = "init" + ext.name.split('.')[-1]
+        initfunc_name = "PyInit_" + ext.name.split('.')[-1]
         if initfunc_name not in ext.export_symbols:
             ext.export_symbols.append(initfunc_name)
         return ext.export_symbols

tests/test_build_ext.py

     def test_get_outputs(self):
         tmp_dir = self.mkdtemp()
         c_file = os.path.join(tmp_dir, 'foo.c')
-        self.write_file(c_file, 'void initfoo(void) {};\n')
+        self.write_file(c_file, 'void PyInit_foo(void) {};\n')
         ext = Extension('foo', [c_file], optional=False)
         dist = Distribution({'name': 'xx',
                              'ext_modules': [ext]})