[C++-sig] Path problems! -

Nicolas Kowenski nicolas.kowenski at softogo.com
Mon Dec 13 19:31:38 CET 2004


Hello, i am trying to extend c++ class to python..
there are *2 ways to build my module*.. :
1- Run the python bin from my sources folder.

*cd  /home/dev/WireLessStudio/PythonWsUsrlib/src/
/home/dev/Python/Python-2.4/./python WS.py build*

Thats work... at least ther are no compilation errors. but does not work..:
 >>> import WS
usage:  [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or:  --help [cmd1 cmd2 ...]
   or:  --help-commands
   or:  cmd --help

error: no commands supplied
bash-2.05b$                  

2- The problem here, is the WS.cpp  include other headers located in
/home/dev/WireLessStudio/PythonWsUsrlib/src/  when i try to run these:

*cd /home/dev/Python/Python-2.4/
./python /home/dev/WireLessStudio/PythonWsUsrlib/src/WS.py build*

the gcc returned some errors. it cant found the included files in WS.cpp
and if I specify the path in WS.cpp like these:
#include </home/dev/WireLessStudio/PythonWsUsrlib/src/ WSApp.h> thats 
dont work, because WSApp.h calls other headers located in .../src/

If i move all (a lot)  the files to /home/dev/Python/Python-2.4/ i 
supouse thats works. but its very derty :'(

WS.py :
from distutils.core import setup, Extension

module3 = Extension('testclases1',
                    sources = ['WS.cpp'])

setup (name = 'PackageName',
       version = '1.0',
       description = 'probando claes en piton, gross',
       ext_modules = [module3])
WS.cpp:
#include "WSApp.h"
#include </home/dev/Python/Python-2.4/Include/Python.h>

WSApp app;



static PyObject *WStest_BC_AddBarcode(PyObject *self, PyObject *args)
{
    int sts;
    int nBarcodeType;
    int bExpand;
    int nDecode;
    int nMin;
    int nMax;
   
     if (!PyArg_ParseTuple(args, 
"ibiii",&nBarcodeType,&bExpand,&nDecode,&nMin,&nMax))  return NULL;
    sts = 
app.m_RFBarcode.AddBarcode(nBarcodeType,bExpand,nDecode,nMin,nMax);
    return Py_BuildValue("b", sts);
}

static PyMethodDef WStestMeth[] = {
    {"BC_AddBarcode", WStest_BC_AddBarcode, METH_VARARGS,"BC_AddBarcode"},
    {NULL, NULL, 0, NULL}        /* Sentinel */
};

PyMODINIT_FUNC initWStest(void)
{
    (void) Py_InitModule("WStest", WStestMeth);
}

int main(int argc, char *argv[])
{
  
    /* Pass argv[0] to the Python interpreter */
    Py_SetProgramName(argv[0]);

    /* Initialize the Python interpreter.  Required. */
    Py_Initialize();

    /* Add a static module */
    initWStest();
}


i try to invert the include order.. its the same.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20041213/ae4f3065/attachment.htm>


More information about the Cplusplus-sig mailing list