New submission from Ronald Oussoren <[email protected]>:
Python supports having a C extension for the the __init__ of a package (instead
of having __init__.py). This works fine on Linux, but on Windows distutils
fails to build the C extension because it assumes the entry point is named
PyInit___init__ while importlib expects PyInit_*package* (for a package named
*package*).
When building the extension I get the following error:
LINK : error LNK2001: unresolved external symbol PyInit___init__
build\temp.win32-3.7\Release\__init__.cp37-win32.lib : fatal error LNK1120: 1
unresolved externals
The code below can be used to reproduce the issue.
Setup.py (extracted from a larger setup.py, but should work...):
from setuptools import setup, Extension
extension3 = Extension("ext_package.__init__", sources=["init.c"])
setup(
ext_modules=[extension3],
)
Source code for the module (init.c):
#include "Python.h"
static PyModuleDef mod_def = {
PyModuleDef_HEAD_INIT,
"ext_package.__init__",
NULL,
0,
NULL,
NULL,
NULL,
NULL,
NULL
};
PyObject* PyInit_ext_package(void)
{
return PyModule_Create(&mod_def);
}
P.S. I cannot easily debug this, I ran into this when testing one of my
projects on AppVeyor and don't have a local Windows machine.
----------
components: Distutils, Windows
messages: 334800
nosy: dstufft, eric.araujo, paul.moore, ronaldoussoren, steve.dower,
tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: distutils fails to build extension on windows when it is a
package.__init__
type: behavior
versions: Python 3.6, Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35893>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com