Re: [Help Request] Embedding Python in a CPP Application Responsibly & Functionally

2023-01-26 Thread Dieter Maurer
John McCardle wrote at 2023-1-25 22:31 -0500: > ... >1) To get the compiled Python to run independently, I have to hack >LD_LIBRARY_PATH to get it to execute. `LD_LIBRARY_PATH=./Python-3.11.1 >./Python-3.11.1/python` . The need to set `LD_LIBRARY_PATH` usually can be avoided via a link time option

[Help Request] Embedding Python in a CPP Application Responsibly & Functionally

2023-01-25 Thread John McCardle
Greetings, I'm working on embedding a Python interpreter into a C++ application. My embedding example program is here, largely taken from Python docs: https://gist.github.com/jmccardle/f3f19d3753ae023aa52b927f0d181c43 I'm simply not interested in writing in Lua, so regardless of any particul

Re: Embedding Python crash on PyTuple_New

2021-11-24 Thread MRAB
On 2021-11-24 07:59, Arnaud Loonstra wrote: On 24-11-2021 01:46, MRAB wrote: On 2021-11-23 20:25, Arnaud Loonstra wrote: On 23-11-2021 18:31, MRAB wrote: On 2021-11-23 16:04, Arnaud Loonstra wrote: On 23-11-2021 16:37, MRAB wrote: On 2021-11-23 15:17, MRAB wrote: On 2021-11-23 14:44, Arnau

Re: Embedding Python crash on PyTuple_New

2021-11-24 Thread Arnaud Loonstra
On 24-11-2021 01:46, MRAB wrote: On 2021-11-23 20:25, Arnaud Loonstra wrote: On 23-11-2021 18:31, MRAB wrote: On 2021-11-23 16:04, Arnaud Loonstra wrote: On 23-11-2021 16:37, MRAB wrote: On 2021-11-23 15:17, MRAB wrote: On 2021-11-23 14:44, Arnaud Loonstra wrote: On 23-11-2021 15:34, MRAB

Re: Embedding Python crash on PyTuple_New

2021-11-23 Thread MRAB
On 2021-11-23 20:25, Arnaud Loonstra wrote: On 23-11-2021 18:31, MRAB wrote: On 2021-11-23 16:04, Arnaud Loonstra wrote: On 23-11-2021 16:37, MRAB wrote: On 2021-11-23 15:17, MRAB wrote: On 2021-11-23 14:44, Arnaud Loonstra wrote: On 23-11-2021 15:34, MRAB wrote: On 2021-11-23 12:07, Arnaud

Re: Embedding Python crash on PyTuple_New

2021-11-23 Thread Arnaud Loonstra
On 23-11-2021 18:31, MRAB wrote: On 2021-11-23 16:04, Arnaud Loonstra wrote: On 23-11-2021 16:37, MRAB wrote: On 2021-11-23 15:17, MRAB wrote: On 2021-11-23 14:44, Arnaud Loonstra wrote: On 23-11-2021 15:34, MRAB wrote: On 2021-11-23 12:07, Arnaud Loonstra wrote: Hi, I've got Python embedd

Re: Embedding Python crash on PyTuple_New

2021-11-23 Thread MRAB
On 2021-11-23 17:31, MRAB wrote: On 2021-11-23 16:04, Arnaud Loonstra wrote: [snip] I would turn my attention to s_py_zosc function but I'm not sure. Since the errors are GC related it could caused anywhere? Basically, yes, but I won't be surprised if it was due to too few INCREFs or too man

Re: Embedding Python crash on PyTuple_New

2021-11-23 Thread MRAB
On 2021-11-23 16:04, Arnaud Loonstra wrote: On 23-11-2021 16:37, MRAB wrote: On 2021-11-23 15:17, MRAB wrote: On 2021-11-23 14:44, Arnaud Loonstra wrote: On 23-11-2021 15:34, MRAB wrote: On 2021-11-23 12:07, Arnaud Loonstra wrote: Hi, I've got Python embedded successfully in a program up un

Re: Embedding Python crash on PyTuple_New

2021-11-23 Thread Arnaud Loonstra
On 23-11-2021 16:37, MRAB wrote: On 2021-11-23 15:17, MRAB wrote: On 2021-11-23 14:44, Arnaud Loonstra wrote: On 23-11-2021 15:34, MRAB wrote: On 2021-11-23 12:07, Arnaud Loonstra wrote: Hi, I've got Python embedded successfully in a program up until now as I'm now running into weird GC rela

Re: Embedding Python crash on PyTuple_New

2021-11-23 Thread MRAB
On 2021-11-23 15:17, MRAB wrote: On 2021-11-23 14:44, Arnaud Loonstra wrote: On 23-11-2021 15:34, MRAB wrote: On 2021-11-23 12:07, Arnaud Loonstra wrote: Hi, I've got Python embedded successfully in a program up until now as I'm now running into weird GC related segfaults. I'm currently tryin

Re: Embedding Python crash on PyTuple_New

2021-11-23 Thread MRAB
On 2021-11-23 14:44, Arnaud Loonstra wrote: On 23-11-2021 15:34, MRAB wrote: On 2021-11-23 12:07, Arnaud Loonstra wrote: Hi, I've got Python embedded successfully in a program up until now as I'm now running into weird GC related segfaults. I'm currently trying to debug this but my understandi

Re: Embedding Python crash on PyTuple_New

2021-11-23 Thread Arnaud Loonstra
On 23-11-2021 15:34, MRAB wrote: On 2021-11-23 12:07, Arnaud Loonstra wrote: Hi, I've got Python embedded successfully in a program up until now as I'm now running into weird GC related segfaults. I'm currently trying to debug this but my understanding of CPython limits me here. I'm creating a

Re: Embedding Python crash on PyTuple_New

2021-11-23 Thread MRAB
On 2021-11-23 12:07, Arnaud Loonstra wrote: Hi, I've got Python embedded successfully in a program up until now as I'm now running into weird GC related segfaults. I'm currently trying to debug this but my understanding of CPython limits me here. I'm creating a Tuple in C but it crashes on crea

Re: Embedding Python crash on PyTuple_New

2021-11-23 Thread Arnaud Loonstra
On 23-11-2021 13:07, Arnaud Loonstra wrote: Hi, I've got Python embedded successfully in a program up until now as I'm now running into weird GC related segfaults. I'm currently trying to debug this but my understanding of CPython limits me here. I'm creating a Tuple in C but it crashes on c

Embedding Python crash on PyTuple_New

2021-11-23 Thread Arnaud Loonstra
Hi, I've got Python embedded successfully in a program up until now as I'm now running into weird GC related segfaults. I'm currently trying to debug this but my understanding of CPython limits me here. I'm creating a Tuple in C but it crashes on creating it after a while. It doesn't make se

Re: Embedding Python

2021-06-02 Thread Chris Angelico
On Thu, Jun 3, 2021 at 4:05 AM Faraaz Mohammed wrote: > > On Tuesday, 1 July 2008 at 21:37:49 UTC+5:30, mk wrote: > > Carsten Haese wrote: > > > python_code is a C string containing the raw bytes from your pyc file. > > > Casting that to a PyObject pointer will not magically transform it into > >

Re: Embedding Python

2021-06-02 Thread Faraaz Mohammed
On Tuesday, 1 July 2008 at 21:37:49 UTC+5:30, mk wrote: > Carsten Haese wrote: > > python_code is a C string containing the raw bytes from your pyc file. > > Casting that to a PyObject pointer will not magically transform it into > > a Python code object. > well yeah, I kind of didn't think that

Re: Embedding Python in C

2019-07-24 Thread Jesse Ibarra
On Tuesday, July 23, 2019 at 2:20:45 PM UTC-6, Stefan Behnel wrote: > Jesse Ibarra schrieb am 22.07.19 um 18:12: > > On Saturday, July 20, 2019 at 1:11:51 PM UTC-6, Stefan Behnel wrote: > >> Jesse Ibarra schrieb am 20.07.19 um 04:12: > >>> Sorry, I am not understanding. Smalltlak VW 8.3 does not su

Re: Embedding Python in C

2019-07-23 Thread Stefan Behnel
Jesse Ibarra schrieb am 22.07.19 um 18:12: > On Saturday, July 20, 2019 at 1:11:51 PM UTC-6, Stefan Behnel wrote: >> Jesse Ibarra schrieb am 20.07.19 um 04:12: >>> Sorry, I am not understanding. Smalltlak VW 8.3 does not support Python. >>> I can only call Pyhton code through C/Python API. >> >> Ok

Re: Embedding Python in C

2019-07-22 Thread Jesse Ibarra
On Saturday, July 20, 2019 at 1:11:51 PM UTC-6, Stefan Behnel wrote: > Jesse Ibarra schrieb am 20.07.19 um 04:12: > > Sorry, I am not understanding. Smalltlak VW 8.3 does not support Python. > > I can only call Pyhton code through C/Python API. > > Ok, but that doesn't mean you need to write code

Re: Embedding Python in C

2019-07-20 Thread Stefan Behnel
Jesse Ibarra schrieb am 20.07.19 um 04:12: > Sorry, I am not understanding. Smalltlak VW 8.3 does not support Python. > I can only call Pyhton code through C/Python API. Ok, but that doesn't mean you need to write code that uses the C-API of Python. All you need to do is: 1) Start up a CPython ru

Re: Embedding Python in C

2019-07-19 Thread dieter
Jesse Ibarra writes: > ... > Now ,I need to bring in shared libraries using C/Python API using Smalltalk. > It seems like I can't directly bring in C shared libraries (.so files). > PROBLEM. With Python, you typically do not load ("bring in") shared libraries explicitly; instead, you simply imp

Re: Embedding Python in C

2019-07-19 Thread Jesse Ibarra
Sorry, I am not understanding. Smalltlak VW 8.3 does not support Python. I can only call Pyhton code through C/Python API. -- https://mail.python.org/mailman/listinfo/python-list

Re: Embedding Python in C

2019-07-19 Thread Stefan Behnel
mporting a module is just "import module", and it even adapts to different Python versions automatically). You can keep writing Python code, and at the same time trivially use external C code. https://cython.org/ http://docs.cython.org/en/latest/src/tutorial/ For embedding Python in an ex

Re: Embedding Python in C

2019-07-19 Thread Christian Gollwitzer
Am 19.07.19 um 16:26 schrieb Jesse Ibarra: On Friday, July 19, 2019 at 8:17:43 AM UTC-6, Chris Angelico wrote: On Sat, Jul 20, 2019 at 12:16 AM Jesse Ibarra wrote: On Thursday, July 18, 2019 at 2:01:39 PM UTC-6, Chris Angelico wrote: On Fri, Jul 19, 2019 at 5:51 AM Christian Gollwitzer wrot

Re: Embedding Python in C

2019-07-19 Thread Jesse Ibarra
On Friday, July 19, 2019 at 8:17:43 AM UTC-6, Chris Angelico wrote: > On Sat, Jul 20, 2019 at 12:16 AM Jesse Ibarra > wrote: > > > > On Thursday, July 18, 2019 at 2:01:39 PM UTC-6, Chris Angelico wrote: > > > On Fri, Jul 19, 2019 at 5:51 AM Christian Gollwitzer > > > wrote: > > > > Once you can

Re: Embedding Python in C

2019-07-19 Thread Jesse Ibarra
On Thursday, July 18, 2019 at 1:46:05 PM UTC-6, Christian Gollwitzer wrote: > Am 18.07.19 um 16:18 schrieb Jesse Ibarra: > > On Wednesday, July 17, 2019 at 2:20:51 PM UTC-6, Christian Gollwitzer wrote: > >> What level of integration do you want to achieve? Do you want > >> > >> a) to call Python fu

Re: Embedding Python in C

2019-07-19 Thread Chris Angelico
On Sat, Jul 20, 2019 at 12:16 AM Jesse Ibarra wrote: > > On Thursday, July 18, 2019 at 2:01:39 PM UTC-6, Chris Angelico wrote: > > On Fri, Jul 19, 2019 at 5:51 AM Christian Gollwitzer > > wrote: > > > Once you can do this, you can proceed to call a Python function, which > > > in C means that yo

Re: Embedding Python in C

2019-07-19 Thread Jesse Ibarra
On Thursday, July 18, 2019 at 2:01:39 PM UTC-6, Chris Angelico wrote: > On Fri, Jul 19, 2019 at 5:51 AM Christian Gollwitzer wrote: > > Once you can do this, you can proceed to call a Python function, which > > in C means that you invoke the function PyObject_CallObject(). A basic > > example is s

Re: Embedding Python in C

2019-07-18 Thread Chris Angelico
On Fri, Jul 19, 2019 at 5:51 AM Christian Gollwitzer wrote: > Once you can do this, you can proceed to call a Python function, which > in C means that you invoke the function PyObject_CallObject(). A basic > example is shown here: > > https://docs.python.org/2/extending/embedding.html#pure-embeddi

Re: Embedding Python in C

2019-07-18 Thread Christian Gollwitzer
Am 18.07.19 um 16:18 schrieb Jesse Ibarra: On Wednesday, July 17, 2019 at 2:20:51 PM UTC-6, Christian Gollwitzer wrote: What level of integration do you want to achieve? Do you want a) to call Python functions from Smalltalk b) call Smalltalk functions from Python c) pass callbacks around, e.g.

Re: Embedding Python in C

2019-07-18 Thread Jesse Ibarra
On Wednesday, July 17, 2019 at 2:20:51 PM UTC-6, Christian Gollwitzer wrote: > Am 17.07.19 um 20:39 schrieb Jesse Ibarra: > > My options seem rather limited, I need to make a Pipeline from (Smalltalk > > -> C -> Python) then go back (Smalltalk <- C <- Python). Since Smalltalk > > does not support

Re: Embedding Python in C

2019-07-18 Thread Barry Scott
> On 17 Jul 2019, at 19:39, Jesse Ibarra wrote: > > On Wednesday, July 17, 2019 at 11:55:28 AM UTC-6, Barry Scott wrote: >>> On 17 Jul 2019, at 16:57, wrote: >>> >>> I am using Python3.6: >>> >>> [jibarra@redsky ~]$ python3.6 >>> Python 3.6.8 (default, Apr 25 2019, 21:02:35) >>> [GCC 4.8.5

Re: Embedding Python in C

2019-07-17 Thread dieter
Jesse Ibarra writes: > ... > My options seem rather limited, I need to make a Pipeline from (Smalltalk -> > C -> Python) then go back (Smalltalk <- C <- Python). Since Smalltalk does > not support Python directly I have to settle with the C/Python API > (https://docs.python.org/3.6/extending/em

Re: Embedding Python in C

2019-07-17 Thread Christian Gollwitzer
Am 17.07.19 um 20:39 schrieb Jesse Ibarra: My options seem rather limited, I need to make a Pipeline from (Smalltalk -> C -> Python) then go back (Smalltalk <- C <- Python). Since Smalltalk does not support Python directly I have to settle with the C/Python API (https://docs.python.org/3.6/ext

Re: Embedding Python in C

2019-07-17 Thread Jesse Ibarra
On Wednesday, July 17, 2019 at 11:55:28 AM UTC-6, Barry Scott wrote: > > On 17 Jul 2019, at 16:57, wrote: > > > > I am using Python3.6: > > > > [jibarra@redsky ~]$ python3.6 > > Python 3.6.8 (default, Apr 25 2019, 21:02:35) > > [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux > > Type "help", "

Re: Embedding Python in C

2019-07-17 Thread Barry Scott
> On 17 Jul 2019, at 16:57, jesse.ibarra.1...@gmail.com wrote: > > I am using Python3.6: > > [jibarra@redsky ~]$ python3.6 > Python 3.6.8 (default, Apr 25 2019, 21:02:35) > [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux > Type "help", "copyright", "credits" or "license" for more information

Embedding Python in C

2019-07-17 Thread jesse . ibarra . 1996
I am using Python3.6: [jibarra@redsky ~]$ python3.6 Python 3.6.8 (default, Apr 25 2019, 21:02:35) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux Type "help", "copyright", "credits" or "license" for more information. I am referencing:https://docs.python.org/3.6/extending/embedding.html#beyond

Re: embedding python - PyImport_ImportModule returns null

2019-03-28 Thread babita . trial
If nothing works mentioned above, please try building your application from common path. ( not from c:\users\ ). While working on office environment, this has impact. -- https://mail.python.org/mailman/listinfo/python-list

Embedding Python (3.7) on OSX crash on Py_Initialize when run as bundle

2019-02-28 Thread Arnaud Loonstra
Hi, I'm trying to wrap my head around an OSX app which has python embedded. This works fine if I run the build on the same machine as it is build on. However when using Travis to build the app I can only get it to run from the terminal. A double click on the appdir (or using open) results in

Embedding python, run a function and get it's result

2017-01-31 Thread Charles Heizer
Hello, I'm messing around with the embedded python and I can get parts to work. What I'm having a hard time is getting my head around calling a function in the python string and getting it's result. Question, how do I load the python script and call runMe() and get it's value? Thanks! Example

Re: Forcing prompt to be on newline when embedding Python with

2017-01-06 Thread H Krishnan
Thanks for your help. > > > > > I am working on embedding Python in my application. > > You forgot to tell us the version of Python that you're embedding. > > I am using Python2.7. > > I have redirected sys.stdin and sys.stdout to call methods from a Qt &

Re: Forcing prompt to be on newline when embedding Python with

2017-01-06 Thread eryk sun
On Fri, Jan 6, 2017 at 1:06 AM, H Krishnan wrote: > I tried replacing sys.displayhook with a function that does not print > newline but the newline still got inserted. So, I am not sure where the > newline is coming from. In any case, I could override sys.displayhook to add > a newline at the end

Re: Forcing prompt to be on newline when embedding Python with

2017-01-06 Thread H Krishnan
Hello Mr.Eryk, Thanks for the detailed explanation. After I added attribute support to my extension class for stdio, the problem was resolved. Regards, Krishnan On Fri, Jan 6, 2017 at 9:24 AM, eryk sun wrote: > On Fri, Jan 6, 2017 at 1:06 AM, H Krishnan wrote: > > I tried replacing sys.disp

Re: Forcing prompt to be on newline when embedding Python with

2017-01-06 Thread eryk sun
On Thu, Jan 5, 2017 at 7:09 AM, H Krishnan wrote: > > I am working on embedding Python in my application. You forgot to tell us the version of Python that you're embedding. > I have redirected sys.stdin and sys.stdout to call methods from a Qt TextEdit > widget. Everything

Re: Forcing prompt to be on newline when embedding Python with stdin/out redirection

2017-01-06 Thread H Krishnan
Hello Mr.Eryk, Thanks for the detailed explanation. After I added attribute support to my extension class for stdio, the problem was resolved. Regards, Krishnan On Fri, Jan 6, 2017 at 9:24 AM, eryk sun wrote: > On Fri, Jan 6, 2017 at 1:06 AM, H Krishnan wrote: > > I tried replacing sys.displ

Re: Forcing prompt to be on newline when embedding Python with stdin/out redirection

2017-01-05 Thread eryk sun
On Fri, Jan 6, 2017 at 1:06 AM, H Krishnan wrote: > I tried replacing sys.displayhook with a function that does not print > newline but the newline still got inserted. So, I am not sure where the > newline is coming from. In any case, I could override sys.displayhook to add > a newline at the end

Re: Forcing prompt to be on newline when embedding Python with stdin/out redirection

2017-01-05 Thread H Krishnan
Thanks for your help. > > > > > I am working on embedding Python in my application. > > You forgot to tell us the version of Python that you're embedding. > > I am using Python2.7. > > I have redirected sys.stdin and sys.stdout to call methods from a Qt &

Re: Forcing prompt to be on newline when embedding Python with stdin/out redirection

2017-01-05 Thread eryk sun
On Thu, Jan 5, 2017 at 7:09 AM, H Krishnan wrote: > > I am working on embedding Python in my application. You forgot to tell us the version of Python that you're embedding. > I have redirected sys.stdin and sys.stdout to call methods from a Qt TextEdit > widget. Everything

Forcing prompt to be on newline when embedding Python with stdin/out redirection

2017-01-05 Thread H Krishnan
Hi, I am working on embedding Python in my application. I have redirected sys.stdin and sys.stdout to call methods from a Qt TextEdit widget. Everything works fine except that the Python prompt does not always come in a new line: >>> dir() ['__builtins__', '__doc__&#x

Re: Best way to go about embedding python

2016-11-13 Thread Michael Torrie
On 11/13/2016 08:40 PM, Kaylen Wheeler wrote: > I wonder if Lua would be a better option. Does it suffer from the > same sandboxing issues that python does? Lua was designed for this sort of thing and it can be secured and sandboxed. -- https://mail.python.org/mailman/listinfo/python-list

Re: Best way to go about embedding python

2016-11-13 Thread Gregory Ewing
dom, you may find it easier to turn the problem around -- instead of embedding Python in the game, embed the game in Python. Implement the game engine as a Python extension module, where the game objects are all inherently Python objects, and Python is responsible for all of the lifetime manag

Re: Best way to go about embedding python

2016-11-13 Thread Kaylen Wheeler
I wonder if Lua would be a better option. Does it suffer from the same sandboxing issues that python does? On Sunday, 13 November 2016 17:38:23 UTC-8, Nathan Ernst wrote: > In regards to performance of Lua vs Python, I don't have enough (near zero > experience) with Lua to comment there. > > B

Re: Best way to go about embedding python

2016-11-13 Thread Nathan Ernst
In regards to performance of Lua vs Python, I don't have enough (near zero experience) with Lua to comment there. But in regards to embedding in a game, the only experience I have w/ Python being embedded is while working on modding Civilization IV. What I saw there just made me nauseous. The rea

Re: Best way to go about embedding python

2016-11-13 Thread Michael Torrie
ending Python with C and embedding Python in C. The principles are the same. The hardest part about integrating Python is that you have to consider what kinds of primitives from your C program you want to expose to Python and how you intend to expose them. You'll have to use the C api to wr

Re: Best way to go about embedding python

2016-11-13 Thread Chris Angelico
On Mon, Nov 14, 2016 at 11:40 AM, Steve D'Aprano wrote: > On Mon, 14 Nov 2016 12:23 am, Chris Angelico wrote: > >> Python without its stdlib is a disappointingly featureless >> language :) > > > I don't think that's true. You can do a lot in Python without any imports in > your code: > > - basic s

Re: Best way to go about embedding python

2016-11-13 Thread Steve D'Aprano
On Mon, 14 Nov 2016 12:23 am, Chris Angelico wrote: > Python without its stdlib is a disappointingly featureless > language :) I don't think that's true. You can do a lot in Python without any imports in your code: - basic string processing - BigNum (int) and float arithmetic - lists and tuples

Re: Best way to go about embedding python

2016-11-13 Thread Chris Angelico
re you intending to let untrusted or less trusted people write the scripts? If so, *do not* use Python. Embedding Python can be done to make your work easier, but it isn't sandboxed. > 1. What's the best implementation to use? > - The engine itself is written in pure C,

Re: Best way to go about embedding python

2016-11-13 Thread Ben Finney
kfjwhee...@gmail.com writes: > A friend of mine is developing a game engine, and I would like to > extend the engine by adding some scripting functionality. I haven't done it myself. But the Python Wiki has some pages that will help you, I think: * https://wiki.python.org/moin/AppsWithPythonScr

Best way to go about embedding python

2016-11-12 Thread kfjwheeler
(Sorry about the last post, my finger slipped before I was finished, and I can't delete it for some reason.) A friend of mine is developing a game engine, and I would like to extend the engine by adding some scripting functionality. However, there's a lot of information out there, and I have

Best way to go about embedding python

2016-11-12 Thread kfjwheeler
A friend of mine is developing a game engine, and I would like to extend the engine by adding some scripting functionality. However, there's a lot of information out there -- https://mail.python.org/mailman/listinfo/python-list

Re: Embedding Python into C set up issues

2016-03-14 Thread robert . snoeberger
> > However, I am having great trouble getting Py_Initialize() to work in the > both CDT and Visual Studio 2015. I have as a starting point a simple C > program that prints hello world then calls py_initialize and then prints > another line of text to the screen. Calling Py_initialize causes th

Embedding Python into C set up issues

2016-03-14 Thread steven . flolid
Good morning! I have been working with Python for the last few months. I have created a script that I want to embed into a C++ environment, specifically CDT for eclipse. I have read the https://docs.python.org/2/extending/index.html and understand the ideas and differences between the two langu

how to create a frame object when embedding python?

2014-05-23 Thread Robert Snoeberger
Hi python-list, I'm embedding Python in an application and I have encountered two crashes while calling built-in functions that expect a top-level frame. See the following bug reports: http://bugs.python.org/issue21563 and http://bugs.python.org/issue21418. The problem is that the wor

Re: real-time monitoring of propriety system: embedding python in C or embedding C in python?

2013-02-05 Thread Terry Reedy
On 2/5/2013 10:23 AM, Duncan Booth wrote: Bas wrote: A) Implement the main program in C. In a loop, get a chunk of data using direct call of C functions, convert data to python variables and call an embedded python interpreter that runs one iteration of the user's algorithm. When the script fi

Re: real-time monitoring of propriety system: embedding python in C or embedding C in python?

2013-02-05 Thread Stefan Behnel
Bas, 05.02.2013 16:10: > at work, we are thinking to replace some legacy application, which is a > home-grown scripting language for monitoring and controlling a large > experiment. It is able to read live data from sensors, do some simple > logic and calculations, send commands to other subsystems

Re: real-time monitoring of propriety system: embedding python in C or embedding C in python?

2013-02-05 Thread rusi
On Feb 5, 8:10 pm, Bas wrote: > Since all the functions I have to interface with (read and write of live > data, sending > commands, ...) are implemented in C, the solution will require writing both C > and python. Standard embedding/extending is ok when the interface is 'thin' ie the number of

Re: real-time monitoring of propriety system: embedding python in C or embedding C in python?

2013-02-05 Thread Duncan Booth
urn the external code into a library, use ctypes to call the library and you're done. That also means reading command line arguments and/or config files can be done in Python and keep the C code simpler. Embedding Python isn't hard but it sounds more complex than needed here. You can of

real-time monitoring of propriety system: embedding python in C or embedding C in python?

2013-02-05 Thread Bas
Hi Group, at work, we are thinking to replace some legacy application, which is a home-grown scripting language for monitoring and controlling a large experiment. It is able to read live data from sensors, do some simple logic and calculations, send commands to other subsystems and finally gene

Re: Embedding Python in a shell script

2011-06-17 Thread Jason Friedman
Thank you, everyone, for your suggestions. I'll try them all and decide which I like best. -- http://mail.python.org/mailman/listinfo/python-list

Re: Embedding Python in a shell script

2011-06-17 Thread Timo Lindemann
On Fri, 17 Jun 2011 22:15:57 +0200, Hans Mulder said: > On 17/06/11 19:47:50, Timo Lindemann wrote: >> On Fri, 17 Jun 2011 00:57:25 +, Jason Friedman said: >> >> >> >>> but for various reasons I want a single script. Any alternatives? >> >> you can use a here document like this: > That does n

Re: Embedding Python in a shell script

2011-06-17 Thread Hans Mulder
On 17/06/11 19:47:50, Timo Lindemann wrote: On Fri, 17 Jun 2011 00:57:25 +, Jason Friedman said: but for various reasons I want a single script. Any alternatives? you can use a here document like this: #! /bin/bash /usr/bin/python2<< EOPYTHON def hello(): print("Hello, Worl

Re: Embedding Python in a shell script

2011-06-17 Thread Timo Lindemann
On Fri, 17 Jun 2011 00:57:25 +, Jason Friedman said: > > but for various reasons I want a single script. Any alternatives? you can use a here document like this: #! /bin/bash /usr/bin/python2 << EOPYTHON def hello(): print("Hello, World"); if __name__ == "__main__": hel

Re: Embedding Python in a shell script

2011-06-17 Thread mg
rusi wrote: > On Jun 17, 6:05 am, Chris Angelico wrote: > >> > Python call becomes.  I'd prefer something like: >> >> #!/bin/bash >> for i in 1 2 3 4; do >>   python -c "if True: > # comfortably indented python code > > Thanks. Nice! You can use bash here document feature, <<-, that strips hea

Re: Embedding Python in a shell script

2011-06-16 Thread rusi
On Jun 17, 6:05 am, Chris Angelico wrote: > > Python call becomes.  I'd prefer something like: > > #!/bin/bash > for i in 1 2 3 4; do >   python -c "if True: # comfortably indented python code Thanks. Nice! -- http://mail.python.org/mailman/listinfo/python-list

Re: Embedding Python in a shell script

2011-06-16 Thread Chris Angelico
On Fri, Jun 17, 2011 at 10:57 AM, Jason Friedman wrote: > The code behaves as I expect and want, but the de-denting of the > Python call is unattractive, especially unattractive the longer the > Python call becomes.  I'd prefer something like: > #!/bin/bash for i in 1 2 3 4; do python -c "if Tr

Embedding Python in a shell script

2011-06-16 Thread Jason Friedman
$ cat test.sh #!/bin/bash for i in 1 2 3 4; do python -c " for j in range($i): print j " done $ sh test.sh 0 0 1 0 1 2 0 1 2 3 The code behaves as I expect and want, but the de-denting of the Python call is unattractive, especially unattractive the longer the Python call becomes. I'd prefe

Re: Link errors embedding Python 3.2

2011-05-27 Thread Chris Angelico
On Fri, May 27, 2011 at 12:45 PM, Ned Deily wrote: > > The discussion in http://bugs.python.org/issue4434 might be of some help. Thanks Ned! That was most helpful. I'm still not sure exactly what I changed, but between building with --enable-shared and some fiddling with how I link my program, I'

Re: Link errors embedding Python 3.2

2011-05-26 Thread Ned Deily
In article , Chris Angelico wrote: > Still trying to sort this out, trying various things. If I configure > --enable-shared, I get a different ImportError: 'libpython3.3m.so.1.0: > cannot open shared object file: No such file or directory'. That file > exists in ~/cpython, but sudo make install d

Re: Link errors embedding Python 3.2

2011-05-26 Thread Chris Angelico
Still trying to sort this out, trying various things. If I configure --enable-shared, I get a different ImportError: 'libpython3.3m.so.1.0: cannot open shared object file: No such file or directory'. That file exists in ~/cpython, but sudo make install doesn't put it anywhere else. Pointing LD_LIBR

Re: Link errors embedding Python 3.2

2011-05-25 Thread Chris Angelico
Followup. I'm now using Python 3.3 straight from Mercurial, and am seeing the same issues. I've managed to get the compilation step to succeed by naming the library for full inclusion and adding -lutil -ldl (sounding rather Donizetti there), and my program runs. However, it's unable to import all i

Link errors embedding Python 3.2

2011-05-24 Thread Chris Angelico
I'm starting to feel incredibly stupid here. Hopefully someone can point out a really obvious thing that I've missed, thus enabling me to move forward! Up until now, I've been embedding Python 2.6.6 in my C++ program, by compiling with "-I/usr/include/python2.6 -lpython2.6&quo

Re: Embedding Python: estimate size of dict/list

2011-03-28 Thread Michael Hunter
On Mon, Mar 28, 2011 at 4:18 PM, Chris Angelico wrote: [...] > Obviously I could use PyObject_Str() and PyString_Size() to get a > decent figure, but that seems like overkill. > > What I'm hoping for is some simple function that zips through a > complex object and sums its approximate memory usage

Re: Embedding Python: estimate size of dict/list

2011-03-28 Thread Chris Angelico
On Tue, Mar 29, 2011 at 12:03 PM, Jerry Hill wrote: > On Mon, Mar 28, 2011 at 8:26 PM, Chris Angelico wrote: >> Based on the docs and http://code.activestate.com/recipes/577504/ I >> understand that to be non-recursive. I'm guessing then that there >> isn't a recursive version, and that it's best

Re: Embedding Python: estimate size of dict/list

2011-03-28 Thread Jerry Hill
On Mon, Mar 28, 2011 at 8:26 PM, Chris Angelico wrote: > Based on the docs and http://code.activestate.com/recipes/577504/ I > understand that to be non-recursive. I'm guessing then that there > isn't a recursive version, and that it's best to recurse myself? Yes, you're right. I completely miss

Re: Embedding Python: estimate size of dict/list

2011-03-28 Thread Chris Angelico
On Tue, Mar 29, 2011 at 10:56 AM, Jerry Hill wrote: > For python 2.6 and later, sys.getsizeof() will probably do what you > want.  It relies on objects implementing a __sizeof__() method, so > third-party objects may or may not support this, but since you're > looking at dicts and lists, you shoul

Re: Embedding Python: estimate size of dict/list

2011-03-28 Thread Jerry Hill
On Mon, Mar 28, 2011 at 7:18 PM, Chris Angelico wrote: > I have an application that embeds Python to allow third-party > scripting. The Python code returns data to the application in the form > of a list or dictionary, and I'd like to have a quick check on the > size of the outputted object before

Embedding Python: estimate size of dict/list

2011-03-28 Thread Chris Angelico
me sort of "if this ran out of references now, how much memory would be freed" function, that would be awesome. My code is in C++, is embedding Python 2.6.6, and is running on Ubuntu Linux. If the solution is to move to Python 3.x then this may be an option. Hoping there's somethin

Re: Embedding python : can't find encoding error

2011-03-01 Thread swapnil
On Feb 28, 4:57 pm, Mathieu CLERICI wrote: > Hi, > > I'm trying to embed python in a c++ program. > I have compiled python32.lib with msvc 2010 targetting 32bits, i link > it with my program wich is also 32bit. > I get an error when calling Py_Initialize() : "no codec search > functions registered

Re: Embedding python : can't find encoding error

2011-02-28 Thread Mathieu CLERICI
Precisions : I'm trying to embed python 3.2 release. -- http://mail.python.org/mailman/listinfo/python-list

Embedding python : can't find encoding error

2011-02-28 Thread Mathieu CLERICI
Hi, I'm trying to embed python in a c++ program. I have compiled python32.lib with msvc 2010 targetting 32bits, i link it with my program wich is also 32bit. I get an error when calling Py_Initialize() : "no codec search functions registered: can't find encoding" Py_FileSystemDefaultEncoding val

embedding python ImportError: libpyglib PyExc_ImportError

2010-10-28 Thread Oliver Marks
Hi i am a new member on this list and thought if some people may be able to enlighten me to the error below ? I am running 64 bit ubuntu 10.10 and python 2.6 in case there are know issues with this setup, basically i am embedding python inside a c application i managed to get this to work i can

Re: embedding python in macOS 10.6

2010-10-28 Thread Aahz
[posted & e-mailed] In article , tinau...@libero.it wrote: > >i'm trying to embed python in a c++ code.i'm starting with the example in the >tutorial.i've problem with setting up the enveiroment. >I've installed python with the distributed version (i.e., i did not, as a >start, build it myself)

R: embedding python in macOS 10.6

2010-09-29 Thread tinau...@libero.it
option,but then to that message, another is added for the object file file was built for i386 which is not the architecture being linked (x86_64) >Messaggio originale >Da: tinau...@libero.it >Data: 29/09/2010 16.06 >A: >Ogg: embedding python in macOS 10.6 > >hi th

embedding python in macOS 10.6

2010-09-29 Thread tinau...@libero.it
hi there, i'm trying to embed python in a c++ code.i'm starting with the example in the tutorial.i've problem with setting up the enveiroment. I've installed python with the distributed version (i.e., i did not, as a start, build it myself); i added the library where both python.h and pyconfig

Re: Embedding Python in a C extension

2010-06-03 Thread kai028
Thanks for the reply. I'm checking this out today. On Wed, 2 Jun 2010 22:30:37 -0700 (PDT), Carl Banks wrote: >On Jun 2, 1:46 pm, Paul Grunau wrote: >> I have a problem with embedding Python into a C extension in Windows >> Vista. I have implemented a timer routine in C as

Re: Embedding Python in a C extension

2010-06-03 Thread kai028
Thanks for the reply. I'm looking into the Global Interpreter Lock today. On Thu, 03 Jun 2010 01:07:39 +0100, MRAB wrote: >p...@mail.python.org wrote: >> I have a problem with embedding Python into a C extension in Windows >> Vista. I have implemented a timer routine in C as

Re: Embedding Python in a C extension

2010-06-02 Thread Carl Banks
On Jun 2, 1:46 pm, Paul Grunau wrote: > I have a problem with embedding Python into a C extension in Windows > Vista. I have implemented a timer routine in C as an extension, which > I can import into Python 2.6.5 and run. Each timer interval, the > extension calls a C CALLBACK functio

Re: Embedding Python in a C extension

2010-06-02 Thread MRAB
p...@mail.python.org wrote: I have a problem with embedding Python into a C extension in Windows Vista. I have implemented a timer routine in C as an extension, which I can import into Python 2.6.5 and run. Each timer interval, the extension calls a C CALLBACK function. I want to be able to have

Embedding Python in a C extension

2010-06-02 Thread Paul
I have a problem with embedding Python into a C extension in Windows Vista. I have implemented a timer routine in C as an extension, which I can import into Python 2.6.5 and run. Each timer interval, the extension calls a C CALLBACK function. I want to be able to have this CALLBACK function call a

  1   2   3   4   >