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.

classification
Title: distutils.command.build_ext.get_export_symbols should use the "PyInit" prefix rather then "init"
Type: Stage: resolved
Components: Distutils, Distutils2, Windows Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: alexis, amaury.forgeotdarc, eric.araujo, georg.brandl, ocean-city, tarek
Priority: normal Keywords: patch

Created on 2009-07-11 01:20 by ocean-city, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix_distutils_test.patch ocean-city, 2009-07-11 01:20
Messages (13)
msg90400 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2009-07-11 01:20
I got distutils error on Lib/distutils\tests\test_build_ext.py. I hope 
attached file will fix this issue. (This should complete r64127)

E:\python-dev\py3k>py3k Lib\distutils\tests\test_build_ext.py
test_build_ext (__main__.BuildExtTestCase) ... xxmodule.c
   Library c:\docume~1\whiter~1\locals~1\temp\tmpbj3fb0\Debug\docume~1
\whiter~1\l
ocals~1\temp\tmpbj3fb0\xx_d.lib とオブジェクト c:\docume~1\whiter~1\locals~1
\temp\tm
pbj3fb0\Debug\docume~1\whiter~1\locals~1\temp\tmpbj3fb0\xx_d.exp is now 
being created
ok
test_check_extensions_list (__main__.BuildExtTestCase) ... ok
test_compiler_deprecation_warning (__main__.BuildExtTestCase) ... ok
test_compiler_option (__main__.BuildExtTestCase) ... ok
test_ext_fullpath (__main__.BuildExtTestCase) ... ok
test_finalize_options (__main__.BuildExtTestCase) ... ok
test_get_outputs (__main__.BuildExtTestCase) ... foo.c
LINK : error LNK2001: External symbol "PyInit_foo" is not resolved
c:\docume~1\whiter~1\locals~1\temp\tmp1bfgxq\tempt\docume~1\whiter~1
\locals~1\te
mp\tmpnttk0b\foo_d.lib : fatal error LNK1120: External symbol 1 is not 
resolved
LINK : fatal error LNK1141: Got trouble in building export file
ERROR
test_get_source_files (__main__.BuildExtTestCase) ... ok
test_optional_extension (__main__.BuildExtTestCase) ... ok
test_solaris_enable_shared (__main__.BuildExtTestCase) ... ok
test_user_site (__main__.BuildExtTestCase) ... ok

======================================================================
ERROR: test_get_outputs (__main__.BuildExtTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "e:\python-dev\py3k\lib\distutils\msvccompiler.py", line 524, in 
link
    self.spawn([self.linker] + ld_args)
  File "e:\python-dev\py3k\lib\distutils\ccompiler.py", line 981, in 
spawn
    spawn(cmd, dry_run=self.dry_run)
  File "e:\python-dev\py3k\lib\distutils\spawn.py", line 36, in spawn
    _spawn_nt(cmd, search_path, dry_run=dry_run)
  File "e:\python-dev\py3k\lib\distutils\spawn.py", line 77, in 
_spawn_nt
    "command '%s' failed with exit status %d" % (cmd[0], rc))
distutils.errors.DistutilsExecError: command '"C:\Program 
Files\Microsoft Visual
 Studio\VC98\BIN\link.exe"' failed with exit status 1141

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Lib\distutils\tests\test_build_ext.py", line 323, in 
test_get_outputs
    cmd.run()
  File "e:\python-dev\py3k\lib\distutils\command\build_ext.py", line 
394, in run

    self.build_extensions()
  File "e:\python-dev\py3k\lib\distutils\command\build_ext.py", line 
503, in bui
ld_extensions
    self.build_extension(ext)
  File "e:\python-dev\py3k\lib\distutils\command\build_ext.py", line 
590, in bui
ld_extension
    target_lang=language)
  File "e:\python-dev\py3k\lib\distutils\ccompiler.py", line 791, in 
link_shared
_object
    extra_preargs, extra_postargs, build_temp, target_lang)
  File "e:\python-dev\py3k\lib\distutils\msvccompiler.py", line 526, in 
link
    raise LinkError(msg)
distutils.errors.LinkError: command '"C:\Program Files\Microsoft Visual 
Studio\V
C98\BIN\link.exe"' failed with exit status 1141

----------------------------------------------------------------------
Ran 11 tests in 1826.566s

FAILED (errors=1)
Traceback (most recent call last):
  File "Lib\distutils\tests\test_build_ext.py", line 432, in <module>
msg90408 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-07-11 09:59
Confirmed with vs2008. I wonder why the buildbots don't fail.
msg90411 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-07-11 10:31
Thanks for the patch, I'll integrate asap.

Notice that I run the tests under windows but without a full range of VC
versions, so I count a lot on the buildbots to show me these kind of
failures.
msg90414 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-07-11 10:47
Mmm, also notice that the current build_ext trunk uses "init"
 in the code, which means that the "PyInit" prefix was added on 
py3k but not backported in the trunk.

So i'll fix that too
msg90416 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-07-11 10:53
The bug also exists in 2.6 so I'm backporting the fix
msg90417 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-07-11 11:01
done in r73946, r73947 (2.6), r73948 (py3k), r73949 (3.1)

Thanks !

(also, the build_ext module is now perfectly similar between 2.x and 3.x)
msg90418 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2009-07-11 11:08
Well, I'm not sure but.... for example,
Modules/_randomemodule.c uses "init_random" on trunk. Is it OK to 
use "PyInit" on trunk too?
msg90419 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-07-11 11:51
What's the logic behind PyInit_ ? 

For instance Modules/_bsddb.c uses PyInit, so does Modules/zlibmodule.c
msg90420 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2009-07-11 11:58
bsddb seems to use #if directive to switch function name. 
("init_bsddb"  on trunk)

#if (PY_VERSION_HEX < 0x03000000)
DL_EXPORT(void) init_bsddb(void)
#else
PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
#endif

And zlibmodule.c, there is following line on line number 56.
#define PyInit_zlib initzlib
msg90429 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-07-11 16:58
The "PyInit_" prefix is only to be used in Python 3, it is part of PEP 3121.

Please revert changes to trunk/2.6 that assume the "PyInit_" name.
msg90430 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-07-11 17:25
Thanks for the explanation, I've reverted the change on 2.x.
msg136246 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-05-18 15:43
Packaging (due to merge with 3.3 shortly) uses init, not PyInit.  I’ll fix it.
msg136650 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-05-23 14:35
Fixed by Tarek in 406ba3cdebcb.
History
Date User Action Args
2022-04-11 14:56:50adminsetgithub: 50708
2011-05-23 14:35:58eric.araujosetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg136650

stage: resolved
2011-05-18 15:43:46eric.araujosetstatus: closed -> open

assignee: tarek -> eric.araujo
components: + Distutils2
versions: + Python 3.3
nosy: + eric.araujo, alexis

messages: + msg136246
2009-07-11 17:25:05tareksetstatus: open -> closed

messages: + msg90430
versions: - Python 2.6, Python 2.7
2009-07-11 16:58:58georg.brandlsetnosy: + georg.brandl
messages: + msg90429
2009-07-11 11:58:10ocean-citysetmessages: + msg90420
2009-07-11 11:51:28tareksetstatus: closed -> open

messages: + msg90419
2009-07-11 11:08:42ocean-citysetmessages: + msg90418
2009-07-11 11:01:56tareksetstatus: open -> closed

messages: + msg90417
2009-07-11 10:53:26tareksettitle: Lib/distutils\tests\test_build_ext.py fails on VC6 -> distutils.command.build_ext.get_export_symbols should use the "PyInit" prefix rather then "init"
messages: + msg90416
versions: + Python 2.6, Python 2.7
2009-07-11 10:47:35tareksetmessages: + msg90414
2009-07-11 10:31:36tareksetpriority: normal
resolution: accepted
messages: + msg90411
2009-07-11 09:59:26amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg90408
2009-07-11 01:20:08ocean-citycreate