best practices for python applications targeting f11 gnome on the olpc xo

David Malcolm dmalcolm at redhat.com
Mon Jan 24 22:31:13 UTC 2011


On Mon, 2011-01-24 at 16:57 -0500, Erik Blankinship wrote:
> What would be the best practice for python applications targeting f11
> gnome on the olpc xo?
> 
> 
> I am developing on f13, but my target is f11 (an olpc xo machine)
> running python 2.6.

Both f13 and f11 had Python 2.6, though slightly different
micro-releases:
  Fedora 13 has 2.6.4
  Fedora 11 had 2.6

In theory, 2.6.4 only contains bug fixes relative to 2.6, but there's
always a risk that your code makes use of something that was fixed in
2.6.4, but not in 2.6


> The rpms I am generating have the name: 
> 
> 
>         SunnyApp-1.1-1.fc13.noarch.rpm
>         
> Two things here stand out to me (the very new rpm packager) which
> suggest I have not done a great job targeting my platform.
> 
> 
> 1. fc13

The "f13" you're seeing is purely a by-product of the value of
  %{dist} 
in your version string; on your f13 box it's "fc13".  Presumably you'll
eventually build the rpms in Koji, which will supply "fc11" for that
metadata.  In the mean time, I wouldn't worry too much about that being
wrong.


> 2. noarch

If the rpm is pure python (no compiled .c code), then that's fine.  rpm
makes it "noarch" if the .spec files has this line:

  BuildArch: noarch

If you are compiling .c code, then remove that line from the .spec file.
The compiler and default compiler flags may have changed somewhat
between f11 and f13; there's a slim chance that could cause issues.

> I would like to make sure the rpms are as compatible as possible with
> that platform.  


> 
> 
> Also, I have some code in my application which is python 2.6 specific
> -- is there a way to designate/enforce that in the file to ensure it
> runs smoothly?

Do you mean "specific to 2.6", "2.6 or later", or "2.6 or earlier"?
(what's the language feature in question?)

Within the specfile you can say:
  Requires: python >= 2.6
to enforce this requirement.

However, this is somewhat redundant, given that we don't bump the minor
version of python in released versions of Fedora.

Within the .py file you can "import sys", then write conditionals based
on sys.version and sys.version_info.  However, these conditionals happen
after the file is parsed, so if you have a .py file using a syntactic
construct from a later version of Python, an earlier version can fail
with a syntax error ("from future" can help here)


Hope this is helpful
Dave




More information about the python-devel mailing list