This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ronaldoussoren
Recipients dstufft, eric.araujo, paul.moore, ronaldoussoren, steve.dower, tim.golden, zach.ware
Date 2019-02-03.21:10:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1549228211.63.0.529262209714.issue35893@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-02-03 21:10:15ronaldoussorensetrecipients: + ronaldoussoren, paul.moore, tim.golden, eric.araujo, zach.ware, steve.dower, dstufft
2019-02-03 21:10:11ronaldoussorensetmessageid: <1549228211.63.0.529262209714.issue35893@roundup.psfhosted.org>
2019-02-03 21:10:11ronaldoussorenlinkissue35893 messages
2019-02-03 21:10:11ronaldoussorencreate