Mark Rose | 2 Jan 2003 22:38

Automake+libtool to build extensions?

Does anyone have advice for setting up automake and/or
libtool to build python extensions using SWIG?  I have
a project that uses automake/conf, and now want to add
some python wrappers.  The best I could come up with is
to use the all-local target to write the make script
for the wrappers by hand.  This is a bit inelegant, and 
doesn't capitalize on automake's dependency tracking.  
I know how to do dependency tracking by hand (even for 
swig interface files), but adding doing so would seem 
like even more of a hack.  

Any clean/bulletproof solutions?  

Thanks,

Mark

_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

William S Fulton | 3 Jan 2003 00:40
Picon
Favicon
Gravatar

Re: Automake+libtool to build extensions?

Mark Rose wrote:
> Does anyone have advice for setting up automake and/or
> libtool to build python extensions using SWIG?  I have
> a project that uses automake/conf, and now want to add
> some python wrappers.  The best I could come up with is
> to use the all-local target to write the make script
> for the wrappers by hand.  This is a bit inelegant, and 
> doesn't capitalize on automake's dependency tracking.  
> I know how to do dependency tracking by hand (even for 
> swig interface files), but adding doing so would seem 
> like even more of a hack.  
> 
> Any clean/bulletproof solutions?  
> 

Well, can't say I've tried this, but I'd just add in the SWIG invocation 
by hand like this:

lib_LTLIBRARIES = libfoo.la
libfoo_la_SOURCES  = not_swiggenerated.c swiggenerated_wrap.c

swiggenerated_wrap.c: swiggenerated.i some_header.h
          swig -python swiggenerated.i

The above uses the _LTLIBRARIES primary to get Automake to use Libtool. 
You'll also need to add the _wrap.c file to the BUILT_SOURCES target, 
see the manual. Automake should then generate the _wrap.c file before 
doing anything else. The dependency tracking should then work out the 
dependencies (header files) that the _wrap.c file depends on for 
compiling the _wrap.c file. You will need to manully add in extra 
(Continue reading)

magnus persson | 3 Jan 2003 10:17
Picon
Favicon

how to generate a java-interface in a package.

I would like to have my c-methods appearing under a
package in java. (in java 1.4 you cannot import from
the top-level-namespace (no namespace)).

in c:
void calc(int a) { }

the java-conversion-code should be something like:
package com;
public class test {
 void calc(int arg) { 
   jni-stuff...
 }
}

should be usable from java as:

import com.*;
public class mainprogram {
 public static int main(String[]arg) {
  void test.calc(4);
 }
}

how do i do this with swig ?
i have tried the module-directive, but then the
generated java-files won't compile.

I have a lot of methods (600) to parse, so i don't
wan't to write a module-interface-declaration for
(Continue reading)

William S Fulton | 3 Jan 2003 11:21
Picon
Favicon
Gravatar

Re: how to generate a java-interface in a package.

magnus persson wrote:
> I would like to have my c-methods appearing under a
> package in java. (in java 1.4 you cannot import from
> the top-level-namespace (no namespace)).

Use the -package SWIG commandline option.

Cheers
William

_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

Sebastian Huber | 3 Jan 2003 13:21
Picon

Re: Automake+libtool to build extensions?

Hallo,
I attached two example files for your aclocal.m4 and one Makefile.am example.

This is needed in a configure.ac file:
SWIG_PROG(1.3.14)
SWIG_ENABLE_CXX
SWIG_PYTHON
AC_PROG_LN_S
AC_PROG_CXX
AC_PROG_LIBTOOL

On Thursday 02 January 2003 22:38, Mark Rose wrote:
> Does anyone have advice for setting up automake and/or
> libtool to build python extensions using SWIG?  I have
> a project that uses automake/conf, and now want to add
> some python wrappers.  The best I could come up with is
> to use the all-local target to write the make script
> for the wrappers by hand.  This is a bit inelegant, and
> doesn't capitalize on automake's dependency tracking.
> I know how to do dependency tracking by hand (even for
> swig interface files), but adding doing so would seem
> like even more of a hack.
>
> Any clean/bulletproof solutions?

It is not absolutly bulletproof, because a 'make distcheck' works only after a 
'make all' . Automake 1.7.1 is required due to a bug fix in py-compile. And 
on SuSE 8.0 modules which use exceptions don't work.

Ciao
(Continue reading)

Jefferson Harlough | 4 Jan 2003 16:14
Picon
Favicon

Ferite support?

  Is anyone currently working on adding support for the Ferite 
(http://www.ferite.org/) scripting language to SWIG?

    Thanks.

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail

_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

David Beazley | 4 Jan 2003 16:26
Favicon

Ferite support?

Jefferson Harlough writes:
 >   Is anyone currently working on adding support for the Ferite 
 > (http://www.ferite.org/) scripting language to SWIG?
 > 

Not that I know of.

Cheers,

Dave
_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

Soulfly | 5 Jan 2003 19:45
Picon
Favicon

C header file

I plan to use SWIG to generate an Python interface for a number of c++
datatypes/functions and have a few questions:

1. Is it possible to wrap an struct of function pointers without the need to
manually make a function for each? The wrap function should test the
pointers for NULL before using them and raise appropriate python exception.

eg
struct funcs {
    int (*pfnTest)(int,char *);
    ...
};
struct funcs myfuncs=get_them_all_from_somewhere();

2. I also want to access the generated wrapper interface from c++. Is there
an easy way to generate header files from the xxx_wrap.cpp -files ?

3.Is there a speacial reason SWIG generates a .py-file for wrapper classes
instead of creating them through Python C/API ?

/Torgil

_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

marco | 7 Jan 2003 03:00
Picon
Favicon

void* and Python


Hello,

I'm trying to wrap a DBMS C API to Python. Part of the interface is
already working but I've problems with this function:

int cli_column(int          statement,
		char const* column_name,
		int         var_type,
		int*        var_len,
		void*       var_ptr);

It binds a column of a database table to the 'var_ptr' variable.

I've found in the Swig documentation something about typemaps and void
pointers (coupled with size_t or int* variables like var_len) but I
don't know how to treat the void pointer and, at the same time, making
var_ptr a returned value. I would like to be able to do something like
this in Python:

.
.
statement=cli_statement(session,'select name,address from persons')
var_ptr_name=cli_column(statement,'name',cli_ascii)
.
.

Could anybody give me a hint?

thanks in advance,
(Continue reading)

Andres Corrada-Emmanuel | 7 Jan 2003 22:50
Picon

How to cast a base class pointer to a derived class

Hello,

I seem to recall, but cannot find now, that SWIG allows you to specify
what class instances can be treated interchangeably. I have a class
instance that is returned as a base class pointer but I need to call
derived class methods on it.

Something like:

foo = object returned as BaseClass
foo.methodInDerivedClass()

So SWIG complains with something like "Expected _p_DerivedClass".

Andres Corrada-Emmanuel
Senior Research Fellow
Center for Intelligent Information Retrieval
University of Massachusetts, Amherst

_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig


Gmane