Embedding & Extending Python &other scripting languages

Mike Meyer mwm at mired.org
Thu Apr 21 01:50:00 EDT 2005


Tommy Nordgren <tommy.nordgren at chello.se> writes:

> I'm interested in doing a rather ambitious project concerning compiler
> construction tools. 
> My tools will parse specification files containing for example lalr
> parser specifications.
> The specifications will contain embedded semantic actions which i want to
> allow writing in any object-oriented language.
> The specifications will name a scripting language and a target language 
> module . Then my tool will create an embedded interpreter for the 
> scripting language, which will load a target language module written in 
> the scripting language, and use it to generate code in the target 
> language.
>
> I want to provide my system as open source.
>
> Now my basic problem is how to find what scripting languages are 
> installed on a users system, and generate the necessary makefiles 
> automatically. I will be using swig for interface creation.
> I want to support at least perl and python, with target language support 
> for at least java and c++ initially.

Ouch. Nasty problem. You can find out what scripting languages are
installed on a Unixish system by doing "which <name>" in a shell
script. "<name>" varies depending on the language in question. I.e.:

guru% which python
/usr/opt/bin/python
guru% which ruby
/usr/opt/bin/ruby
guru% which perl
/usr/opt/bin/perl
guru% which tclsh
/usr/opt/bin/tclsh

for python, ruby, perl and tcl.

For Windows, you can probably grovel similar information out of the
Registry. I'll leave details up to someone unfortunate enough to have
to work with Windows.

FWIW, you probably ought to verify that java and C++ are installed as
well. End-users systems - specifically Windows, but some Linux/Unix
distributions don't include either.

Finally, checking just that just interpreter exists may not be
sufficient for all Unix-like systems. Some systems, for various
nonsensical reasons, split packages up into two halves. One half will
install the interpreter, and the other half will install the include
files and etc. that you need to build extensions. You may need those
as well.

   <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list