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: Missing spaces in import.h?
Type: compile error Stage:
Components: Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Ziyuan.Lin, brett.cannon, python-dev, vstinner
Priority: normal Keywords:

Created on 2013-12-08 20:57 by Ziyuan.Lin, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (9)
msg205605 - (view) Author: Ziyuan Lin (Ziyuan.Lin) Date: 2013-12-08 20:57
In Include\import.h, line 89-97:

PyAPI_FUNC(PyObject *)_PyImport_FindBuiltin(
    const char *name            /* UTF-8 encoded string */
    );
PyAPI_FUNC(PyObject *)_PyImport_FindExtensionObject(PyObject *, PyObject *);
PyAPI_FUNC(int)_PyImport_FixupBuiltin(
    PyObject *mod,
    char *name                  /* UTF-8 encoded string */
    );
PyAPI_FUNC(int)_PyImport_FixupExtensionObject(PyObject*, PyObject *, PyObject *);


Shouldn't they be the following:

PyAPI_FUNC(PyObject *) _PyImport_FindBuiltin(
    const char *name            /* UTF-8 encoded string */
    );
PyAPI_FUNC(PyObject *) _PyImport_FindExtensionObject(PyObject *, PyObject *);
PyAPI_FUNC(int)_PyImport_FixupBuiltin(
    PyObject *mod,
    char *name                  /* UTF-8 encoded string */
    );
PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject*, PyObject *, PyObject *);
msg205610 - (view) Author: Ziyuan Lin (Ziyuan.Lin) Date: 2013-12-08 21:58
To see the errors, one can install PyCUDA and Theano, and run code at http://deeplearning.net/software/theano/tutorial/using_gpu.html#id1 :


import numpy, theano
import theano.misc.pycuda_init
from pycuda.compiler import SourceModule
import theano.sandbox.cuda as cuda

class PyCUDADoubleOp(theano.Op):
    def __eq__(self, other):
        return type(self) == type(other)
    def __hash__(self):
        return hash(type(self))
    def __str__(self):
        return self.__class__.__name__
    def make_node(self, inp):
        inp = cuda.basic_ops.gpu_contiguous(
           cuda.basic_ops.as_cuda_ndarray_variable(inp))
        assert inp.dtype == "float32"
        return theano.Apply(self, [inp], [inp.type()])
    def make_thunk(self, node, storage_map, _, _2):
        mod = SourceModule("""
    __global__ void my_fct(float * i0, float * o0, int size) {
    int i = blockIdx.x*blockDim.x + threadIdx.x;
    if(i<size){
        o0[i] = i0[i]*2;
    }
  }""")
        pycuda_fct = mod.get_function("my_fct")
        inputs = [ storage_map[v] for v in node.inputs]
        outputs = [ storage_map[v] for v in node.outputs]
        def thunk():
            z = outputs[0]
            if z[0] is None or z[0].shape!=inputs[0][0].shape:
                z[0] = cuda.CudaNdarray.zeros(inputs[0][0].shape)
            grid = (int(numpy.ceil(inputs[0][0].size / 512.)),1)
            pycuda_fct(inputs[0][0], z[0], numpy.intc(inputs[0][0].size),
                       block=(512,1,1), grid=grid)
        return thunk


The interpreter will complain errors like "c:\python33\include\import.h(97): error: explicit type is missing ("int" assumed)" (at least in my case)
msg205696 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-12-09 14:27
In case no one else sees it, Ziyuan is saying that there should be a space after the PyAPI_FUNC() uses.
msg205753 - (view) Author: Ziyuan Lin (Ziyuan.Lin) Date: 2013-12-09 23:55
Yes, although I left out the space after the third PyAPI_FUNC().
msg205754 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-12-10 00:21
New changeset 7b077c691fef by Victor Stinner in branch '3.3':
Issue #19932: Fix typo in import.h, missing whitespaces in function prototypes.
http://hg.python.org/cpython/rev/7b077c691fef

New changeset e017cd46009a by Victor Stinner in branch 'default':
(Merge 3.3) Issue #19932: Fix typo in import.h, missing whitespaces in function prototypes.
http://hg.python.org/cpython/rev/e017cd46009a
msg205756 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-12-10 00:24
New changeset eb1039fe090c by Victor Stinner in branch '2.7':
Issue #19932: Fix typo in import.h, missing whitespaces in function prototypes.
http://hg.python.org/cpython/rev/eb1039fe090c
msg205757 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-12-10 00:24
@Ziyuan Lin: The issue should now be fixed, can you please confirm?
msg205764 - (view) Author: Ziyuan Lin (Ziyuan.Lin) Date: 2013-12-10 01:35
I can't build the cpython with Visual Studio 2012 because of the following errors:


"D:\Repository\cpython\PCbuild\pcbuild.sln" (default target) (1) ->
"D:\Repository\cpython\PCbuild\_msi.vcxproj" (default target) (13) ->
(Link target) ->
  LINK : fatal error LNK1181: cannot open input file 'fci.lib' [D:\Repository\cpython\PCbuild\_ msi.vcxproj]

"D:\Repository\cpython\PCbuild\pcbuild.sln" (default target) (1) ->
"D:\Repository\cpython\PCbuild\_ssl.vcxproj" (default target) (17) ->
"D:\Repository\cpython\PCbuild\ssl.vcxproj" (default target) (18) ->
(Build target) ->
  C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073:
 The command "cd "D:\Repository\cpython\PCbuild\" [D:\Repository\cpython\PCbuild\ssl. vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073: " D:\Repository\cpython\PCbuild\amd64\python_d.exe" build_ssl.py Release x64 -a [D:\Rep ository\cpython\PCbuild\ssl.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073: "
 exited with code 1. [D:\Repository\cpython\PCbuild\ssl.vcxproj]


Anyway, I replaced Python33/Include/import.h with cpython/Include/import.h directly, and it works well with my sample code. Thank you.


By the way, here's a discussion about the "fci.lib" issue, which suggests replacing fci.lib with cabinet.lib: http://social.msdn.microsoft.com/Forums/vstudio/en-US/3b85f36e-dffe-4589-adc3-13673b349812/missing-fcilib-in-windows-sdk-80?forum=vcgeneral
msg205821 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-12-10 14:57
So it sounds like this specific issue is fixed. If you keep having build issues, Ziyuan, feel free to open another issue with the new problems.
History
Date User Action Args
2022-04-11 14:57:55adminsetgithub: 64131
2013-12-10 14:57:23brett.cannonsetstatus: open -> closed
resolution: fixed
messages: + msg205821
2013-12-10 01:35:39Ziyuan.Linsetmessages: + msg205764
2013-12-10 00:24:13vstinnersetmessages: + msg205757
2013-12-10 00:24:04python-devsetmessages: + msg205756
2013-12-10 00:21:26python-devsetnosy: + python-dev
messages: + msg205754
2013-12-09 23:55:45Ziyuan.Linsetmessages: + msg205753
2013-12-09 14:28:26vstinnersetnosy: + vstinner
2013-12-09 14:27:41brett.cannonsetnosy: + brett.cannon
messages: + msg205696
2013-12-08 21:58:51Ziyuan.Linsetmessages: + msg205610
2013-12-08 20:57:11Ziyuan.Lincreate