|
|
Home » Developing U++ » U++ Developers corner » STARTED: Python in bazaar
STARTED: Python in bazaar [message #31845] |
Wed, 30 March 2011 23:09  |
 |
kohait00
Messages: 939 Registered: July 2009 Location: Germany
|
Experienced Contributor |
|
|
hi guys,
i've just been playing around with python, and start to lovin it, at least in script area. when it comes to C API it's kinda BS. beeing still a novice in python i've been studying the C API a bit and accumulated some examples from the net.
so here we go. bazaar has got Python now, but is still not complete. it offers the basic development environment, release and debug version. a 'PyConsoleCtrl', which invokes python in a upp window, means the GUI/Main Thread does the job, and a 'PyShell' which opens a new thread window using Tk from python modules itself. it's a MT environment then. A PyTest shows how to generally use the C API when extending/embedding.
the syntax of native embedding is not very nice. i think of building a bridge PyObject <--> Value to make life easier. but since i'm new to it i'd love to have some help. so anyone with experience in python C API and UPP is welcome.
meanwhile, try what's there 
PS: the Python package contains a python27_d, whith the debug version of the lib, to spare you the work of compiling it. installation instructions are provided there too.
|
|
|
Re: STARTED: Python in bazaar [message #31846 is a reply to message #31845] |
Thu, 31 March 2011 06:28   |
Novo
Messages: 1430 Registered: December 2006
|
Ultimate Contributor |
|
|
I developed a Python module in my past life. It seems to be not that hard in simple cases, but if you want to dive deeper it is getting scary. I remember having a lot of troubles trying to simulate exception classes in the way I needed. Any way, I can try to help. My code is open source, though I'm not very proud of it.
Regards,
Novo
|
|
|
Re: STARTED: Python in bazaar [message #31849 is a reply to message #31846] |
Thu, 31 March 2011 09:44   |
 |
kohait00
Messages: 939 Registered: July 2009 Location: Germany
|
Experienced Contributor |
|
|
sound good...
my goal would be to only offer a small single interface to python, not too extensive.. focus on exporting some part of the API of a Upp side class to be available in python and vice versa.
this implys the Value - PyObject translation for the most common types in python
Value: PyObject:
int = long int
in64 = long long integer (theoretically it's unlimited)
double = real
bool = BOOL
String = String
Time = DateTime
Time = Time
Date = Date
Vector<Value> = tuple (Vector<> basicly to distinguish from list)
Array<Value> = list
ArrayMap<Value, Value> = dict
and ofcorse the methods for modules/classes or static funcitons API
i'm still thinnking of how to best do the latter part.
since somehow with the self PyObject we'd need to access the class instance..(module instance is always the same, for static functions self == NULL anyway). i think it'd be best to have the upp class have a python PyObject* instance of the python class, and have the PyObject instance have another PyObject* as private member (kind of a contect variable) which represents the this pointer of a upp class. so both classes are runtime connected without the need to use maps.
could you provide your sourcecode to learn?
BTW: have you been able to use the Python package in bazaar?
[Updated on: Thu, 31 March 2011 09:45] Report message to a moderator
|
|
|
|
|
|
Re: STARTED: Python in bazaar [message #31856 is a reply to message #31853] |
Thu, 31 March 2011 10:37   |
 |
kohait00
Messages: 939 Registered: July 2009 Location: Germany
|
Experienced Contributor |
|
|
w.r.t BOOST:
wasnt there some descussion to include boost in upp?
but i remember it to be very bloated for that means..
but definitely, the part op python could be worth it..
at least, as a helper to achieve similar things for upp.
the licence is sth similar to BSD..
EDIT: can someone try to compile and use the PyConsoleCtrlTest in linux, optimal and debug? i have got no tux environment around now.. tried to compile it with TDMGCC both release and debug, both work..
[Updated on: Thu, 31 March 2011 11:26] Report message to a moderator
|
|
|
|
Re: STARTED: Python in bazaar [message #31860 is a reply to message #31856] |
Thu, 31 March 2011 12:06   |
chickenk
Messages: 171 Registered: May 2007 Location: Grenoble, France
|
Experienced Member |
|
|
PyConsoleCtrlTest works for me under Linux, in both Optimal and Debug modes, with 2 important remarks:
1. I tested with my own upp-waf build system and not theIDE directly since I was too lazy to open up theIDE... I'll try it when I can though
2. On my system (let's say it's a Gentoo even though it's a bit more complicated), python 2.7 library is called libpython2.7.so and I had no debug library associated, so I made the following changes to Python.upp:
library(!DEBUG) python2.7;
library(DEBUG) python2.7;
Another question: is there a way to get the error message or stack trace when python fails? I get the -1 exit code when I write wrong code, but no more precised clue... Is it expected for now?
I also tested other packages, they look good and work nice. Here is another patch I made for PyShell:
Index: bazaar/PyShell/PyShell.h
===================================================================
--- bazaar/PyShell/PyShell.h (revision 3320)
+++ bazaar/PyShell/PyShell.h (working copy)
@@ -21,7 +21,7 @@
if(!t.IsOpen()) t.Run(THISBACK(Proc));
}
void Wait() { t.Wait(); }
- bool IsRunning() const { return AtomicRead(a>0); }
+ bool IsRunning() const { return AtomicRead(a)>0; }
void Proc();
Not sure it's what you expect the function to be but at least it compiles.
Lionel
|
|
|
|
|
|
|
|
|
|
|
Re: STARTED: Python in bazaar [message #31890 is a reply to message #31889] |
Mon, 04 April 2011 21:11   |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
I added to the line to include bazaar
"C:\MyApps;C:\upp\uppsrc;C:\upp\bazaar"
I still do not have the bazaar listing, just the original with Upp3321:
examples
MyApps
reference
tutorial
uppsrc
edit: Right click in that column -> New assembly
Package nests: C:\upp\bazaar;C:\upp\uppsrc
Assembly name: bazaar
This works.
Thanks kohait00
Neil
[Updated on: Mon, 04 April 2011 21:29] Report message to a moderator
|
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 15:12:48 CEST 2025
Total time taken to generate the page: 0.01380 seconds
|
|
|