We've been moving forward on the PySoy rewrite using Genie in faith that a Python 3 binding for GObject would come about.
At PyCon this weekend I've brainstormed with Kirk McDonald, author of PyD which serves a similar role to use D types/objects in Python, and several other authors of FFIs for Python. A rough strategy is coming together to solve this in a dynamic manner.
The first part of the solution is libvala; using a small part of its functionality to parse .vapi and .gir files for existing GObject libraries such as GTK and Cairo as well as any library written in Vala or Genie. This gets us the C API for the library in all it's object oriented goodness, and with that we can dynamically generate bindings using Python's ctypes.
The second part is a GObject type in Python which supports subclassing in Python. Kirk detailed how this is done in PyD; each generated GObject type gets a subtype with all of its virtual methods all running Python methods which call the superclass's C method by default. When a Python subclass of a GObject class is made this GObject subclass is used allowing Python to override any of its methods and pass objects of the subclass back to GObject where they'll perform as expected. Not simple or easy, but its a strategy.
The end result is dynamic Python 3 bindings for GTK as well as PySoy and all the other tools we work on.
I'm organizing a sprint for this at PyCon. If anyone has ideas on this please comment, or if you'd like to help (whether at PyCon 2010 or not) get in touch with me.
Saturday, February 20, 2010
Wednesday, January 13, 2010
Epson Artisan 810 on Linux (Ubuntu)
We purchased a new printer for the house last night to replace the windows-only Dell printer that ran out of ink (and would cost almost as much as a new printer for replacements).
First, some advice: plan ahead, order online, don't buy from Staples. We paid $170 for this when Epson is offering them direct for $130 with free shipping. If we were not in need of immediate replacement we could have saved $40 and waited a week. Further, the rep at the store lied when he told us the printer was going to the back to get a unit "fresh off the truck", it was a unit another customer had returned with ink spilled and dried on the inside and some of the packaging torn open. Buyer beware. Otherwise, they seemed to clean it up and repackaged it well. I have half a mind to order the printer online and return this one within 14 days for refund to save the $40.
The printer itself is fairly impressive. Two paper trays (letter/legal plus photo/cardstock) and a built-in CD printing tray that slides out when you select CD printing, scanner with auto-document feeder, and built in 10/100 and wifi so we don't need to depend on any computer in the house to properly "share" the printer. All I had to do is select our access point on the front controls and give it a static IP on our router.
Ubuntu 9.10 detects the printer over the network in seconds and I was printing the Ubuntu test page in under a minute, so more than half the systems in the house were easy. Windows setup was not hard, but time consuming as loads of bundled software installed from the CD. The only complaint I have is the color seems a little off; printing the same image in both Linux and Windows shows a fairly radical difference in quality. The prints from Linux are still much better than printing from Windows to our older printer.
Next I tried to use the scanner function. Using GIMP to launch SANE (Scanner Access Now Easy), the printer was automatically detected and let me select either the flatbed or auto-document feeder. Both options work fine until I start the scan, at which point the Epson Artisan 810 locks up and needs to be rebooted.
There is a scan function from the front panel, not supporting anywhere near the scanner's full resolution and storing in JPEG format with obvious artifacts around text/etc, but at least we don't need to use a Windows system for basic scans until SANE is fixed. Since I have a stand-alone Epson scanner that works beautifully this isn't a huge issue for me, though it would be great to be able to use the auto-document feeder from Linux and be able to put this older scanner into storage.
First, some advice: plan ahead, order online, don't buy from Staples. We paid $170 for this when Epson is offering them direct for $130 with free shipping. If we were not in need of immediate replacement we could have saved $40 and waited a week. Further, the rep at the store lied when he told us the printer was going to the back to get a unit "fresh off the truck", it was a unit another customer had returned with ink spilled and dried on the inside and some of the packaging torn open. Buyer beware. Otherwise, they seemed to clean it up and repackaged it well. I have half a mind to order the printer online and return this one within 14 days for refund to save the $40.
The printer itself is fairly impressive. Two paper trays (letter/legal plus photo/cardstock) and a built-in CD printing tray that slides out when you select CD printing, scanner with auto-document feeder, and built in 10/100 and wifi so we don't need to depend on any computer in the house to properly "share" the printer. All I had to do is select our access point on the front controls and give it a static IP on our router.
Ubuntu 9.10 detects the printer over the network in seconds and I was printing the Ubuntu test page in under a minute, so more than half the systems in the house were easy. Windows setup was not hard, but time consuming as loads of bundled software installed from the CD. The only complaint I have is the color seems a little off; printing the same image in both Linux and Windows shows a fairly radical difference in quality. The prints from Linux are still much better than printing from Windows to our older printer.
Next I tried to use the scanner function. Using GIMP to launch SANE (Scanner Access Now Easy), the printer was automatically detected and let me select either the flatbed or auto-document feeder. Both options work fine until I start the scan, at which point the Epson Artisan 810 locks up and needs to be rebooted.
There is a scan function from the front panel, not supporting anywhere near the scanner's full resolution and storing in JPEG format with obvious artifacts around text/etc, but at least we don't need to use a Windows system for basic scans until SANE is fixed. Since I have a stand-alone Epson scanner that works beautifully this isn't a huge issue for me, though it would be great to be able to use the auto-document feeder from Linux and be able to put this older scanner into storage.
Sunday, January 10, 2010
soy.windows.Window rendering, GLEW headache
I'm seeing "red" now with our Windows, in more ways than one. The rendering code for soy.windows.Windows is to the point that, by changing the glClear color, we're seeing red in the window rather than black. This is a big step forward given that porting to use GDK is a big part of the libsoy migration.
On the other side of "red" is anger over GLEW. I really wish I knew of a decent, mature alternative to GLEW. The project is so immature that, though one of the maintainers is a Debian developer, they do not provide the pkgconfig file for it. Without this file, which provides Waf with the location of the library and it's headers, we would have to write a search script to verify that it's installed and find it's location. None of the major distros I looked at provide the pkgconfig on their own.
It's also at least partially redundant with the functionality of gtkglext which I believe should be able to replace GLEW entirely.
On the other side of "red" is anger over GLEW. I really wish I knew of a decent, mature alternative to GLEW. The project is so immature that, though one of the maintainers is a Debian developer, they do not provide the pkgconfig file for it. Without this file, which provides Waf with the location of the library and it's headers, we would have to write a search script to verify that it's installed and find it's location. None of the major distros I looked at provide the pkgconfig on their own.
It's also at least partially redundant with the functionality of gtkglext which I believe should be able to replace GLEW entirely.
Friday, January 08, 2010
libsoy running on OSX - briefly
For the first time in 3.5 years, we had soy.windows.Window running on OSX. Just the basics; opening, (re)setting the title, resizing - but it worked. This is thanks to GDK, the windowing and event backend to GTK+, running on Mac OSX via native Quartz backend (not X11).
Shortly after we moved the window code to a background thread and it broke. The code runs fine on GNU/Linux and Windows, but on OSX all we get are white rectangles where the windows would normally be rendered. The rectangles even resize properly, and window events are getting processed by our code, just nothing rendered inside (not even the window title or buttons). I filed this bug and hope the problem to be solved quickly.
The problem could be as simple as a missing NSGraphicsContext.flushGraphics call (which is only needed when rendering is done in a non-main thread). If the bug hasn't been fixed by our next release I'll look into patching this myself.
Shortly after we moved the window code to a background thread and it broke. The code runs fine on GNU/Linux and Windows, but on OSX all we get are white rectangles where the windows would normally be rendered. The rectangles even resize properly, and window events are getting processed by our code, just nothing rendered inside (not even the window title or buttons). I filed this bug and hope the problem to be solved quickly.
The problem could be as simple as a missing NSGraphicsContext.flushGraphics call (which is only needed when rendering is done in a non-main thread). If the bug hasn't been fixed by our next release I'll look into patching this myself.
Tuesday, January 05, 2010
language mixing
After some work to update our ODE bindings for Vala, we discussed Bullet again last night and returned to the conclusion to drop further work on ODE and focus on Bullet for the next release.
It quickly became clear that the C bindings for Bullet are utter horse crap; praise for the effort for whoever wrote them, and I by no means intend to disparage your ability or intentions, but they're horribly incomplete and usable for little more than the two demo apps included in the source. Moreso, the C bindings are "higher level" than the C++ library, performing several steps automatically (such as calculating body inertia from mass and shape) which our 3d game engine needs more direct control over. I first wrote an alternative (ABI compatible) C header for it, and then started to rewrite it entirely.
I decided that if we're going to write our own Bullet compatibility layer, we may as well go all the way in wrapping it with GObject. The code is simple enough, but defining GObject in C involves a lot of boilerplate - in some cases more than the code itself. To get through this and retain my sanity, I started work this morning on a C++ code generator that takes the relevant functions and wraps them in the standard boilerplate.
The format I'm using is Genie-like for class and method definition, then C++ within dumped directly to the target .cpp. The code generator will generate the .vapi as it works and compile our wrapper as a static library which libsoy can link to directly.
Kudos again to Waf for making this rather eccentric use of their build system dead simple and clean.
It quickly became clear that the C bindings for Bullet are utter horse crap; praise for the effort for whoever wrote them, and I by no means intend to disparage your ability or intentions, but they're horribly incomplete and usable for little more than the two demo apps included in the source. Moreso, the C bindings are "higher level" than the C++ library, performing several steps automatically (such as calculating body inertia from mass and shape) which our 3d game engine needs more direct control over. I first wrote an alternative (ABI compatible) C header for it, and then started to rewrite it entirely.
I decided that if we're going to write our own Bullet compatibility layer, we may as well go all the way in wrapping it with GObject. The code is simple enough, but defining GObject in C involves a lot of boilerplate - in some cases more than the code itself. To get through this and retain my sanity, I started work this morning on a C++ code generator that takes the relevant functions and wraps them in the standard boilerplate.
The format I'm using is Genie-like for class and method definition, then C++ within dumped directly to the target .cpp. The code generator will generate the .vapi as it works and compile our wrapper as a static library which libsoy can link to directly.
Kudos again to Waf for making this rather eccentric use of their build system dead simple and clean.
Monday, January 04, 2010
libsoy building separately now
We've been working on the "libsoy" branch of PySoy for some time, a split of the compiled code to a GObject-based C library with Python bindings plus the pure Python code constituting PySoy itself.
Previously we were struggling to build this with Python's distutils system, which didn't support building system-wide C libraries nor using valac to do so. Jon and I started looking into Waf last week. It's pretty impressive; Python based (and works with Python 3), simple, intuitive, does everything we need with only a few dozen lines of script. Last night we setup libsoy in it's own repository and building (just a very basic soy.windows for now) on it's own.
I think we're settled to work with Genie, a comparison between the syntax of soy.windows in Vala vs in Genie makes that choice simple. The only complaint I have with Genie is needing to escape newlines inside struct {}'s (ie, line 32-35), but reportedly this is being fixed in an upcoming release to be more Python-like (ignoring newlines while inside () or {}).
After a bit of searching (through source code, I wish Waf had better API reference in it's docs) I found the gir= option for Vala building, and another hour later both soy-1.0.gir and soy-1.0.typelib were being generated, except both were empty save the "soy" namespace:
I've hit this before with trying to generate GObject Introspection from distutils but chalked it up to not building it correctly. As it turns out, this is a known bug in GIR and a previously unknown bug in valac to fail silently.
I'm still hoping the GIR developers will come to their senses and support nested namespaces, but given that they've stubbornly rejected this for months already I'm afraid we'll have to build a cross-language bindings builder based on Vala/Genie instead of helping to update PyGI for Python 3.
Previously we were struggling to build this with Python's distutils system, which didn't support building system-wide C libraries nor using valac to do so. Jon and I started looking into Waf last week. It's pretty impressive; Python based (and works with Python 3), simple, intuitive, does everything we need with only a few dozen lines of script. Last night we setup libsoy in it's own repository and building (just a very basic soy.windows for now) on it's own.
I think we're settled to work with Genie, a comparison between the syntax of soy.windows in Vala vs in Genie makes that choice simple. The only complaint I have with Genie is needing to escape newlines inside struct {}'s (ie, line 32-35), but reportedly this is being fixed in an upcoming release to be more Python-like (ignoring newlines while inside () or {}).
After a bit of searching (through source code, I wish Waf had better API reference in it's docs) I found the gir= option for Vala building, and another hour later both soy-1.0.gir and soy-1.0.typelib were being generated, except both were empty save the "soy" namespace:
<?xml version="1.0"?>
<repository version="1.0" xmlns="http://www.gtk.org/introspection/core/1.0" xmlns:c="http://www.gtk.org/introspection/c/1.0" xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<package name="soy"/>
<namespace name="soy" version="1.0" c:prefix="soy">
</namespace>
</repository>
I've hit this before with trying to generate GObject Introspection from distutils but chalked it up to not building it correctly. As it turns out, this is a known bug in GIR and a previously unknown bug in valac to fail silently.
I'm still hoping the GIR developers will come to their senses and support nested namespaces, but given that they've stubbornly rejected this for months already I'm afraid we'll have to build a cross-language bindings builder based on Vala/Genie instead of helping to update PyGI for Python 3.
Saturday, January 02, 2010
state of Vala IDEs
Wasted quite a few hours today trying to get a Vala/Genie IDE working.
VTG is basically broken, crashing at random. It had problems before this; having a fairly rigid concept of a "project", not supporting non-autotools build systems or libraries very easily, not supporting Genie, and the symbol mapping having odd quirks, so this is not a huge loss.
A newer Vala plugin for gEdit, Valencia, looks promising but doesn't support recent Vala versions and attempting to build it raised pages of errors.
Anjuta has always looked interesting, but I've never managed to get the Anjuta Vala plugin to compile. At present, it doesn't appear to work with Gnome 2.28.
I don't use Eclipse or Mono, so the final option is Valide. To my surprise, it's been packaged for Ubuntu and works out of the box. It supports Genie, it seems to have features on-par with VTG and the other IDEs, and works with the latest version of Vala.
My only complaint so far is the new project wizard doesn't list the AGPLv3 as a license option, but then none of the Vala IDE options do yet.
VTG is basically broken, crashing at random. It had problems before this; having a fairly rigid concept of a "project", not supporting non-autotools build systems or libraries very easily, not supporting Genie, and the symbol mapping having odd quirks, so this is not a huge loss.
A newer Vala plugin for gEdit, Valencia, looks promising but doesn't support recent Vala versions and attempting to build it raised pages of errors.
Anjuta has always looked interesting, but I've never managed to get the Anjuta Vala plugin to compile. At present, it doesn't appear to work with Gnome 2.28.
I don't use Eclipse or Mono, so the final option is Valide. To my surprise, it's been packaged for Ubuntu and works out of the box. It supports Genie, it seems to have features on-par with VTG and the other IDEs, and works with the latest version of Vala.
My only complaint so far is the new project wizard doesn't list the AGPLv3 as a license option, but then none of the Vala IDE options do yet.
Tuesday, December 29, 2009
Python meme 2009
Here’s a short, 5 questions, 2009 Python meme. Copy-paste the questions, and blog your answers !
1. What’s the coolest Python application, framework or library you have discovered in 2009 ?
SQLAlchemy, not only does it fully (properly) abstract the SQL database for you, but provides a full Object Relational Mapping. What's more, it's Python 3 ready.
2. What new programming technique did you learn in 2009 ?
Using GObject Introspection to mix several languages (ie, Python and Javascript) in the same application.
3. What’s the name of the open source project you contributed the most in 2009 ? What did you do ?
Concordance XMPP, an XMPP service framework for Python I started January 1st 2009.
4. What was the Python blog or website you read the most in 2009 ?
Python Planet
5. What are the three top things you want to learn in 2010 ?
1. What’s the coolest Python application, framework or library you have discovered in 2009 ?
SQLAlchemy, not only does it fully (properly) abstract the SQL database for you, but provides a full Object Relational Mapping. What's more, it's Python 3 ready.
2. What new programming technique did you learn in 2009 ?
Using GObject Introspection to mix several languages (ie, Python and Javascript) in the same application.
3. What’s the name of the open source project you contributed the most in 2009 ? What did you do ?
Concordance XMPP, an XMPP service framework for Python I started January 1st 2009.
4. What was the Python blog or website you read the most in 2009 ?
Python Planet
5. What are the three top things you want to learn in 2010 ?
Monday, December 07, 2009
peer1/serverbeach severe failure
We've seen a greater than average share of service outages at Serverbeach; incompetent electricians blowing out the battery backup system causing an evening of downtime, network failures taking the server down for hours at a time, other random outages without explanation.
Of course these outages affect large numbers of customers so you get 500 errors when trying to access the customer portal or put on hold for up to an hour waiting to talk to someone only able to enter a ticket into the system on your behalf.
This latest outage tops them all, however. Yesterday afternoon they attempted to merge the Peer1 and Serverbeach customer portals which knocked out DNS for a "large number" of customers. They sent out an email to everyone and I fully expected it to be a short outage.
Last night at around 8pm all of our domains were still down. I attempted to log into the customer portal to find my old password not working, and after a lengthy process to recover it I found myself locked out of it unless I agreed to a lengthy new service agreement which I certainly don't have time to read through in the middle of an outage.
After sitting on hold with customer service a ticket was filed. Which I replied to, and replied to, and have only received blanket emails asking to reply again if we're still out. More than 24 hours later we are still down.
Serverbeach claims they refund customers for outages, but I have yet to receive a dime credited for any past issues and I fully expect them to make getting credit for this difficult as well. At this point I don't think it's fair to myself or the communities which rely on this server to continue hosting with them.
I've found a really decent deal with Hurricane Electric with the added perks of IPV6, more bandwidth, and newer hardware for less than I'm paying now.
Of course these outages affect large numbers of customers so you get 500 errors when trying to access the customer portal or put on hold for up to an hour waiting to talk to someone only able to enter a ticket into the system on your behalf.
This latest outage tops them all, however. Yesterday afternoon they attempted to merge the Peer1 and Serverbeach customer portals which knocked out DNS for a "large number" of customers. They sent out an email to everyone and I fully expected it to be a short outage.
Last night at around 8pm all of our domains were still down. I attempted to log into the customer portal to find my old password not working, and after a lengthy process to recover it I found myself locked out of it unless I agreed to a lengthy new service agreement which I certainly don't have time to read through in the middle of an outage.
After sitting on hold with customer service a ticket was filed. Which I replied to, and replied to, and have only received blanket emails asking to reply again if we're still out. More than 24 hours later we are still down.
Serverbeach claims they refund customers for outages, but I have yet to receive a dime credited for any past issues and I fully expect them to make getting credit for this difficult as well. At this point I don't think it's fair to myself or the communities which rely on this server to continue hosting with them.
I've found a really decent deal with Hurricane Electric with the added perks of IPV6, more bandwidth, and newer hardware for less than I'm paying now.
Tuesday, December 01, 2009
Gentoo wins again with Python 3
Despite being heavily involved in Ubuntu advocacy and promotion, being a member of the Ubuntu project, and using it on my personal systems, I've had to keep my servers and development machines running Gentoo.
When developing software, we need to work on what will be "mainstream" in 6 to 12 months, not what's already mainstream. When a new version of our physics library is released, it may depreciate certain methods or include new features we'll really want in our release, but that version won't be packaged until 2-8 months after the new library was released, given the typical release cycles and "feature freeze" stopping new packages from being included too close to release time.
Python 3 is a great example of this; Gnome 3 will apparently use Python 3 for many applets, and Gnome 3's release schedule sets it for inclusion in Ubuntu 10.10 (next Fall), but at present Python 3.1 is packaged but none of the 3rd party packages are available for it - even those which explicitly support Python 3 already.
While doing my periodic Gentoo upgrade, I just noticed that Portage, the package system for Gentoo, can now be built to run on Python 3 directly. When you have both Python 2 and 3 installed on your system, packages wich support both will build and install for both, and their packaged versions are often available just days after release. From what I've seen, Gentoo is one of the best distributions for Python developers right now.
I wouldn't recommend that my family run Gentoo, many of whom happily run Ubuntu, but it's lack of support for developers is concerning to me. I do not believe it should be difficult to both support new Linux users and experienced developers with the same distribution.
When developing software, we need to work on what will be "mainstream" in 6 to 12 months, not what's already mainstream. When a new version of our physics library is released, it may depreciate certain methods or include new features we'll really want in our release, but that version won't be packaged until 2-8 months after the new library was released, given the typical release cycles and "feature freeze" stopping new packages from being included too close to release time.
Python 3 is a great example of this; Gnome 3 will apparently use Python 3 for many applets, and Gnome 3's release schedule sets it for inclusion in Ubuntu 10.10 (next Fall), but at present Python 3.1 is packaged but none of the 3rd party packages are available for it - even those which explicitly support Python 3 already.
While doing my periodic Gentoo upgrade, I just noticed that Portage, the package system for Gentoo, can now be built to run on Python 3 directly. When you have both Python 2 and 3 installed on your system, packages wich support both will build and install for both, and their packaged versions are often available just days after release. From what I've seen, Gentoo is one of the best distributions for Python developers right now.
I wouldn't recommend that my family run Gentoo, many of whom happily run Ubuntu, but it's lack of support for developers is concerning to me. I do not believe it should be difficult to both support new Linux users and experienced developers with the same distribution.
Subscribe to:
Posts (Atom)