pybindgen under Windows XP and Visual Studio 2009

Bug #519456 reported by T Powers
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PyBindGen
Fix Released
Undecided
Unassigned

Bug Description

Using Windows XP, I tried to follow the README "To install PyBindGen,
issue the following commands" instructions but didn't get very far?

 waf configure

seems to work fine (although I have multiple python versions and it
only seems o find one and not the one I want. For this issue I presume
I have to trudge throught the waf docs). However the last line is:

 'configure' finished successfully (59.937s)
   error: No such command '&'

It does that for EVERY waf command I issue from the command line?

It also says:

 Checking for program python2.5-config : not found
 Checking for program python-config-2.5 : not found

But I don't know if that is a problem or not?

 waf

doesn't seem to do anything?

 waf check

returns this mess:

  Waf: Entering directory `F:\pybindgen-0.14.0\build'
  [1/7] cxx: tests\foo.cc -> build\default\tests\foo_4.o
  [2/7] command (${PYTHON}): tests\test-generation.py -> build\default\tests\test.cc
  F:\pybindgen-0.14.0\pybindgen\cppclass_typehandlers.py:1088: UserWarning: Returning shared pointers is dangerous! The C++ API should be redesigned to avoid this situation.
    warnings.warn("Returning shared pointers is dangerous!"
  F:\pybindgen-0.14.0\pybindgen\module.py:167: DeprecationWarning: Duplicate call to write_preamble detected. Note that there has been an API change in PyBindGen and directly calling write_preamble should no longer be done as it is done by PyBindGen itself.
    utils.write_preamble(code_sink)
  [3/7] command (${PYTHON}): tests\foomodulegen.py -> build\default\tests\foomodule.cc
  foo.cc
  f:\pybindgen-0.14.0\tests\foo.h(482) : error C2146: syntax error : missing ';' before identifier 'FlowId'
  f:\pybindgen-0.14.0\tests\foo.h(482) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  f:\pybindgen-0.14.0\tests\foo.h(482) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  f:\pybindgen-0.14.0\tests\foo.h(483) : error C2146: syntax error : missing ';' before identifier 'get_flow_id'
  f:\pybindgen-0.14.0\tests\foo.h(483) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  f:\pybindgen-0.14.0\tests\foo.h(483) : error C2086: 'int xpto::FlowId' : redefinition
  f:\pybindgen-0.14.0\tests\foo.h(482) : see declaration of 'xpto::FlowId'
  f:\pybindgen-0.14.0\tests\foo.h(483) : error C2146: syntax error : missing ')' before identifier 'flowId'
  f:\pybindgen-0.14.0\tests\foo.h(483) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  f:\pybindgen-0.14.0\tests\foo.h(483) : error C2059: syntax error : ')'
  f:\pybindgen-0.14.0\tests\foo.h(724) : error C2146: syntax error : missing ';' before identifier 'word'
  f:\pybindgen-0.14.0\tests\foo.h(724) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  f:\pybindgen-0.14.0\tests\foo.h(724) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  f:\pybindgen-0.14.0\tests\foo.h(727) : error C2146: syntax error : missing ';' before identifier 'low'
  f:\pybindgen-0.14.0\tests\foo.h(727) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  f:\pybindgen-0.14.0\tests\foo.h(727) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  f:\pybindgen-0.14.0\tests\foo.h(727) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  f:\pybindgen-0.14.0\tests\foo.h(840) : error C2065: 'uint32_t' : undeclared identifier
  f:\pybindgen-0.14.0\tests\foo.h(931) : warning C4244: '+=' : conversion from 'double' to 'int', possible loss of data
  f:\pybindgen-0.14.0\tests\foo.h(932) : warning C4244: '+=' : conversion from 'double' to 'int', possible loss of data
  f:\pybindgen-0.14.0\tests\foo.h(1075) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
  f:\pybindgen-0.14.0\tests\foo.h(1076) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
  f:\pybindgen-0.14.0\tests\foo.h(1081) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
  f:\pybindgen-0.14.0\tests\foo.h(1084) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
  f:\pybindgen-0.14.0\tests\foo.h(1085) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
  ..\tests\foo.cc(442) : error C2065: 'uint32_t' : undeclared identifier
  ..\tests\foo.cc(444) : error C2079: 'get_set' uses undefined class 'std::set'
  ..\tests\foo.cc(445) : error C2065: 'uint32_t' : undeclared identifier
  ..\tests\foo.cc(445) : error C2133: 'rv' : unknown size
  ..\tests\foo.cc(445) : error C2512: 'std::set' : no appropriate default constructor available
  ..\tests\foo.cc(446) : error C2661: 'std::set<_Kty,_Pr,_Alloc>::set' : no overloaded function takes 1 arguments
  ..\tests\foo.cc(452) : error C2146: syntax error : missing ';' before identifier 'get_flow_id'
  ..\tests\foo.cc(452) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  ..\tests\foo.cc(452) : error C2086: 'int xpto::FlowId' : redefinition
   f:\pybindgen-0.14.0\tests\foo.h(482) : see declaration of 'xpto::FlowId'
  ..\tests\foo.cc(452) : error C2146: syntax error : missing ')' before identifier 'flowId'
  ..\tests\foo.cc(452) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  ..\tests\foo.cc(452) : error C2374: 'xpto::get_flow_id' : redefinition; multiple initialization
   f:\pybindgen-0.14.0\tests\foo.h(483) : see declaration of 'xpto::get_flow_id'
  ..\tests\foo.cc(452) : error C2059: syntax error : ')'
  ..\tests\foo.cc(453) : error C2143: syntax error : missing ';' before '{'
  ..\tests\foo.cc(453) : error C2447: '{' : missing function header (old-style formal list?)
  ..\tests\foo.cc(459) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
  ..\tests\foo.cc(471) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
  ..\tests\foo.cc(483) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
  ..\tests\foo.cc(495) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
  ..\tests\foo.cc(505) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)

  exception CannotBeConstructed cannot be constructed (no reason) in wrapper <pybindgen.function.Function object at 0x00EBD790>
  exception CannotBeConstructed cannot be constructed (no reason) in wrapper public: CannotBeConstructed CannotBeConstructed::get_value ();
  F:\pybindgen-0.14.0\pybindgen\cppclass_typehandlers.py:1088: UserWarning: Returning shared pointers is dangerous! The C++ API should be redesigned to avoid this situation.
    warnings.warn("Returning shared pointers is dangerous!"
  Waf: Leaving directory `F:\pybindgen-0.14.0\build'
  Build failed
  -> missing file: 'F:\\pybindgen-0.14.0\\build\\default\\tests\\foo_4.o'
  gccxml not available; skipping the C hello demo

Where most of the problems seems to involve uint32_t?

This can be solved by telling people they have to download pstdint.h
from http://www.azillionmonkeys.com/qed/pstdint.h, renaming it to
stdint.h, and copying it to their C:\Program Files\Microsoft Visual
Studio 9.0\VC\include directory. Of course the appropriate files then
need to #include <stdint.h>

Once I added #include <stdint.h> to foo.h, then things seemed to work
other then lots of warnings about risky type conversions and lots of
the following:

  f:\pybindgen-0.14.0\tests\foo.h(1076) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)

 waf --examples

doesn't seem to do anything??

 waf install

Installs to python25 but I really want to install to python26?

I took a look at the tutorial files in first-example.zip, but those
are specifically targeted at gcc. Nothing there for Visual Studio 2008
users.

Related branches

Revision history for this message
Gustavo Carneiro (gjc) wrote :

There seem to be several issues and questions being reported in a single bug report:

1. MSVC does not have <stdint.h>
  -> I will add your instructions, check for the include, and include it in the unit test header.

2. Yes, 'waf' does not do anything, because Python code does not need to be compiled, and bytecode compilation is a post-install thing (runs on waf install)

3. On waf check, the pybindgen warnings are normal, but the compilation warnings are not expected. Although I have not tested in MSVC in a very long time, so I am not surprised. That specific warning that remained after you resolved the stdint issue seems to be a MSVC shortcoming [1]; I am not going to cripple my code just to please MSVC, sorry.

4. Regarding the installation to the wrong python version, WAF decides to install python files to the default python site-packages. "Default python" means whatever python is found in PATH first by trying to run the 'python' system command. If you want to install to a different python, you need to set the PYTHON environment variable to the exe of the python you wish to select. My batch skills are rusty, but I would guess something like "set PYTHON=C:\python26", before running waf configure. If you have problems, just manually copy the tree, as is mentioned in the README.

[1] https://issues.apache.org/activemq/browse/AMQCPP-19?focusedCommentId=37615&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_37615

Revision history for this message
T Powers (tomp-2010+launchpad) wrote :

Changing my PATH to have C:\python26\ instead of C:\Python25 didn't help waf use Python26. Must be some issue with waf. As you mentioned I eventually just manually copied the pybindgen-0.14.0\pybindgen directory to C:\python\lib\site-packages.

Here's my instructions for building the first Tutorial example using Microsoft Visual Studio 2008 under Windows XP:

Open a Visual Studio 2008 Command Prompt or run C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat to make sure environment variables are set correctly for the MSVC tools.

Change to the first-example directory, make a Release subdirectory, and go to it by doing:

 cd first-example
 md Release
 cd Release

Build a Release version of MyModule.pyd by doing:

 cl /LD /O2 /MD /EHsc /W3 /I C:\python26\include /D WIN32 /D NDEBUG /D _CONSOLE ..\my-module.c ..\my-module-binding.c /link /OUT:MyModule.pyd /IMPLIB:MyModule.lib /LIBPATH:"C:\python26\libs"

which creates:

 my-module-binding.obj
 my-module.obj
 MyModule.exp
 MyModule.lib
 MyModule.pyd
 MyModule.pyd.manifest

(If you want to debug your extensions you'll have to first create a debug version of Python yourself by compiling the Python sources. I'm pretty sure you can't mix a Debug version of your extension with a Release version of Python?)

Continue on with the Tutorial to use MyModule from the Python Interpreter.

(This example is perhaps a bit confusing since for simplicity, you are linking the Python binding directly with the example c module. In my case I link my C code into a separate static library which I will then link with the generated bindings to create a .pyd file.)

Revision history for this message
Gustavo Carneiro (gjc) wrote :

I think this is fixed now. There are several problems reported here. Some I can't reproduce (e.g. No such command '&'). Some (installation) just need documentation (README). The stdint.h is fixed by including a copy of pstdint.h and using it when needed.
I think this bug report can be closed now. If you find anything else, please open a separate bug report for each separate issue, else it's confusing! Thanks.

Changed in pybindgen:
status: New → Fix Committed
Gustavo Carneiro (gjc)
Changed in pybindgen:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.