← Back to team overview

kicad-developers team mailing list archive

RE: How to compile with Python support?

 

>Well, that's true on the Python calling C++ thing, but that will require
>me a lot of work for the C++ calling python thing ... (yes that is a two
>way binding ...)
> On this big project , I had the C++ code and I couldn’t modify, just adapt my
> SWIG .i code to make the binding.
> So I created a directory with my .i file and added a “make wrapper” to the
> makefile.
> Good point also with swig is the ability to map a C++ object to python one like
> C++ vector to python list etc…(with some work  )
> On my project, I had all C++ things, template metaprogramming etc… and I was
> able to support all C++ functions.
> 
>That's what SWIG is made for ;)
> I’m not telling you to change,
Well, I am maybe saying it ...
> I just give you the information from what was my
> experience with SWIG.
> Bad points where:
> - Hard to learn at the beginning (but when you know how to do a thing it becomes
> quite easy)
> 
>I can handle that
> - Hard to find info in the docs.
> 
>I can handle that too (code is the best doc :) )
> - .i files are nearly a copy of .h files (but who cares, .h files evolves? Just
> copy the added methods in .i files)
> 


>well, I was thinking of writing a parser for that reason ... with
>special macros such as __SWIG_EXPORT ...

I don’t understand this last point, why do you need a parser??????
To make the wrapper c++ to python? 


> - A new dependency for the project…
> 
>Boost is a dependency already, and that's quite hard to build on windows
>(as JP. Charras told me).

>other bad points includes :

>- Drastically increase the compile time (something like x2 or x3 ... man
>SWIG is slow !)

True J


>- May proove really painfull to use on the C++ calling other language
>thing (although I read a thread explaining bits of it ...)
>- Increase complexity of the code (you got to know what you are doing
>... and few devs know SWIG), that point can be solved with some macro magic



I’m not OK with what you said on code complexity. If you use SWIG well you’ll use .i files that are mainly a copy f your headers. And in THESE .i file you specify what you want to wrap or not.

So if you want to provide a python wrapper, your devs will not have to knowabout SWIG. I’ve wrapped a big library WITHOUT modyfing line of C++ code. Only .i file where created in a separate directory.

For the two way binding, what do you want to do ? I’ve done in my project a python scrpit launcher called from c++. Is it suffciient for your needs?

If you want some .i example I can try to hepl you little with what I ‘ve seen from my previous project.

Can you explain the parser story, I really don’t undersatnd it’s usage with SWIG ?_?

If you want a little help for this I can share my XP with you.

Cheers ,

Laurent



 ------=_NextPart_000_001D_01C88ECE.162093A0 Content-Type: text/html;
charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"; xmlns="http://www.w3.org/TR/REC-html40";>

<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
code
{mso-style-priority:99;
font-family:"Courier New";}
pre
{mso-style-priority:99;
mso-style-link:"Préformaté HTML Car";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
tt
{mso-style-priority:99;
font-family:"Courier New";}
span.left
{mso-style-name:left;}
span.bld
{mso-style-name:bld;}
p.ad, li.ad, div.ad
{mso-style-name:ad;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
p.ad1, li.ad1, div.ad1
{mso-style-name:ad1;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
p.ad2, li.ad2, div.ad2
{mso-style-name:ad2;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
p.ad3, li.ad3, div.ad3
{mso-style-name:ad3;
mso-margin-top-alt:auto;
margin-right:0cm;
margin-bottom:7.5pt;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.PrformatHTMLCar
{mso-style-name:"Préformaté HTML Car";
mso-style-priority:99;
mso-style-link:"Préformaté HTML";
font-family:Consolas;}
p.bld1, li.bld1, div.bld1
{mso-style-name:bld1;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";
font-weight:bold;}
p.replbq, li.replbq, div.replbq
{mso-style-name:replbq;
margin:3.0pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
p.left1, li.left1, div.left1
{mso-style-name:left1;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
p.ct, li.ct, div.ct
{mso-style-name:ct;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
p.cat, li.cat, div.cat
{mso-style-name:cat;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
p.ad4, li.ad4, div.ad4
{mso-style-name:ad4;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
p.ad5, li.ad5, div.ad5
{mso-style-name:ad5;
mso-margin-top-alt:auto;
margin-right:0cm;
margin-bottom:7.5pt;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
p.left2, li.left2, div.left2
{mso-style-name:left2;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
p.ct1, li.ct1, div.ct1
{mso-style-name:ct1;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
text-align:right;
font-size:12.0pt;
font-family:"Times New Roman","serif";
color:#FF7900;
font-weight:bold;}
p.cat1, li.cat1, div.cat1
{mso-style-name:cat1;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";
font-weight:bold;}
p.ad6, li.ad6, div.ad6
{mso-style-name:ad6;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.EmailStyle39
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page Section1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>

<body bgcolor=white lang=FR link=blue vlink=purple>

<div class=Section1>

<div id=ygrp-mlmsg>

<div id=ygrp-msg>

<div id=ygrp-text>

<p style='margin-bottom:12.0pt'><span lang=EN-US style='color:#1F497D'>&gt;</span><span
lang=EN-US>Well, that's true on the Python calling C++ thing, but that will
require<br>
<span style='color:#1F497D'>&gt;</span>me a lot of work for the C++ calling
python thing ... (yes that is a two<br>
<span style='color:#1F497D'>&gt;</span>way binding ...)<br>
&gt; On this big project , I had the C++ code and I couldn’t modify, just adapt
my<br>
&gt; SWIG .i code to make the binding.<br>
</span>&gt; So I created a directory with my .i file and added a “make wrapper”
to the<br>
&gt; makefile.<br>
&gt; Good point also with swig is the ability to map a C++ object to pythonone
like<br>
&gt; C++ vector to python list etc…(with some work &amp;#61514; )<br>
&gt; On my project, I had all C++ things, template metaprogramming etc… and I
was<br>
&gt; able to support all C++ functions.<br>
<span lang=EN-US>&gt; <br>
<span style='color:#1F497D'>&gt;</span>That's what SWIG is made for ;)<br>
&gt; I’m not telling you to change,<br>
Well, I am maybe saying it ...<br>
</span>&gt; I just give you the information from what was my<br>
&gt; experience with SWIG.<br>
<span lang=EN-US>&gt; Bad points where:<br>
&gt; - Hard to learn at the beginning (but when you know how to do a thing it
becomes<br>
&gt; quite easy)<br>
&gt; <br>
<span style='color:#1F497D'>&gt;</span>I can handle that<br>
&gt; - Hard to find info in the docs.<br>
&gt; <br>
<span style='color:#1F497D'>&gt;</span>I can handle that too (code is thebest
doc :) )<br>
&gt; - .i files are nearly a copy of .h files (but who cares, .h files evolves?
Just<br>
&gt; copy the added methods in .i files)<br>
&gt; <br>
<br>
<span style='color:#1F497D'><o:p></o:p></span></span></p>

<p style='margin-bottom:12.0pt'><span lang=EN-US style='font-size:11.0pt;
font-family:"Calibri","sans-serif";color:#1F497D'>&gt;</span><span lang=EN-US>well,
I was thinking of writing a parser for that reason ... with<br>
<span style='color:#1F497D'>&gt;</span>special macros such as __SWIG_EXPORT ...</span><span
lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p></o:p></span></p>

<p style='margin-bottom:12.0pt'><span lang=EN-US style='font-size:11.0pt;
font-family:"Calibri","sans-serif";color:#1F497D'>I don’t understand this last
point, why do you need a parser??????<br>
To make the wrapper c++ to python? <o:p></o:p></span></p>

<p style='margin-bottom:12.0pt'><span lang=EN-US><br>
&gt; - A new dependency for the project…<br>
&gt; <br>
<span style='color:#1F497D'>&gt;</span>Boost is a dependency already, and
that's quite hard to build on windows<br>
<span style='color:#1F497D'>&gt;</span>(as JP. </span>Charras told me).<br>
<br>
<span lang=EN-US style='color:#1F497D'>&gt;</span><span lang=EN-US>other bad
points includes :<br>
<br>
<span style='color:#1F497D'>&gt;</span>- Drastically increase the compiletime
(something like x2 or x3 ... man<br>
<span style='color:#1F497D'>&gt;</span>SWIG is slow !)<span style='color:#1F497D'><o:p></o:p></span></span></p>

<p style='margin-bottom:12.0pt'><span lang=EN-US style='font-size:11.0pt;
font-family:"Calibri","sans-serif";color:#1F497D'>True </span><span lang=EN-US
style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>J</span><span
lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p></o:p></span></p>

<p style='margin-bottom:12.0pt'><span lang=EN-US><br>
<span style='color:#1F497D'>&gt;</span>- May proove really painfull to use on
the C++ calling other language<br>
<span style='color:#1F497D'>&gt;</span>thing (although I read a thread
explaining bits of it ...)<br>
<span style='color:#1F497D'>&gt;</span>- Increase complexity of the code (you
got to know what you are doing<br>
<span style='color:#1F497D'>&gt;</span>... and few devs know SWIG), that point
can be solved with some macro magic<br>
<br>
</span><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p></o:p></span></p>

<p style='margin-bottom:12.0pt'><span lang=EN-US style='font-size:11.0pt;
font-family:"Calibri","sans-serif";color:#1F497D'>I’m not OK with what you said
on code complexity. If you use SWIG well you’ll use .i files that are mainly a
copy f your headers. And in THESE .i file you specify what you want to wrapor
not.<o:p></o:p></span></p>

<p style='margin-bottom:12.0pt'><span lang=EN-US style='font-size:11.0pt;
font-family:"Calibri","sans-serif";color:#1F497D'>So if you want to providea
python wrapper, your devs will not have to know about SWIG. I’ve wrapped a big
library WITHOUT modyfing  line of C++ code. Only .i file where createdin a
separate directory.<o:p></o:p></span></p>

<p style='margin-bottom:12.0pt'><span lang=EN-US style='font-size:11.0pt;
font-family:"Calibri","sans-serif";color:#1F497D'>For the two way binding, what
do you want to do ? I’ve done in my project a python scrpit launcher called
from c++. Is it suffciient for your needs?<o:p></o:p></span></p>

<p style='margin-bottom:12.0pt'><span lang=EN-US style='font-size:11.0pt;
font-family:"Calibri","sans-serif";color:#1F497D'>If you want some .i example I
can try to hepl you little with what I ‘ve seen from my previous project.<o:p></o:p></span></p>

<p style='margin-bottom:12.0pt'><span lang=EN-US style='font-size:11.0pt;
font-family:"Calibri","sans-serif";color:#1F497D'>Can you explain the parser
story, I really don’t undersatnd it’s usage with SWIG ?_?<o:p></o:p></span></p>

<p style='margin-bottom:12.0pt'><span lang=EN-US style='font-size:11.0pt;
font-family:"Calibri","sans-serif";color:#1F497D'>If you want a little helpfor
this I can share my XP with you.<o:p></o:p></span></p>

<p style='margin-bottom:12.0pt'><span lang=EN-US style='font-size:11.0pt;
font-family:"Calibri","sans-serif";color:#1F497D'>Cheers ,<o:p></o:p></span></p>

<p style='margin-bottom:12.0pt'><span lang=EN-US style='font-size:11.0pt;
font-family:"Calibri","sans-serif";color:#1F497D'>Laurent</span><span
lang=EN-US><br>
<br>
</span><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p></o:p></span></p>

</div>

</div>

</div>

</div>

</body>

</html>
 ------=_NextPart_000_001D_01C88ECE.162093A0--




Follow ups

References