distPND


Tempel

Active Member
Joined
Dec 30, 2008
Messages
670
Age
37
Website
randy.heydon.selfip.net
Cross posted from gp32x.


Dear everyone,


If you're a Python developer, you're probably aware that Distutils is the standard mechanism for distributing Python software. As long as you have a well-made setup script, you can distribute the sources, install to root or home, create an RPM, or, with the right extensions, package it just about any way else.


distPND is a Distutils extension I've created to build PND and PXML files easily. It provides two commands: gen_pxml will slap together a PXML file based on parameters in the setup script and command-line options, while bdist_pnd will assemble your project into a PND file (calling gen_pxml if it needs a PXML file).


To use it, download the sources from its github page and install like any Python package (sudo python setup.py install). After that, you can use the commands with any other Distutils-based setup script by specifying distpnd in command-packages (ie: "python setup.py --command-packages distpnd [command]", or make a setup.cfg file with "command-packages=distpnd" included under the "global" heading). To make iso- or squash-based PNDs, you'll need to have mkisofs or mksquashfs (respectively) available. Even without those, though, you can make a folder that will be read by libpnd.


So far, it works pretty well, but it's kind of hackish and somewhat limited. I'm hoping my fellow Python devs will take distPND for a ride and abuse the crap out of it. Tell me where it breaks or could behave more nicely and I'll fix it up. Or, if you're feeling generous, send along some patches. Some things to note:

  • Almost none of this respects the dry-run flag. It shouldn't make any system changes, but watch out for that.
  • gen_pxml does not nearly expose all the functionality in a PXML. Is there an elegant way to include associations, multiple applications, and multilingual titles and descriptions? One solution might be to have PXML templates; can you concoct a good approach to doing that?
  • bdist_pnd doesn't yet check that it's not overwriting existing files. Again, watch out.
  • If you have an icon or info file to include, bdist_pnd expects that file will make its own way into the build_pnd folder (presumably during the "install" portion of the job). Is there a better way to handle this? I think I've solved this pretty well. If you tell bdist_pnd about your icon and info, it ensures they end up in the root of the PND and in your PXML. I've updated the Lonely Tower sources to show two different ways to do it.



As an example of how it works, I've packed up my opus; you can download the sources to see how setup.py and setup.cfg work, or you can download the resulting PND to see the results (with no Pandora, I can't actually confirm that this works, so please don't laugh at me if it fails!).


Have fun everyone! I look forward to hearing back from you.


PS: If your package includes extension modules written in a compiled language (C or Cython or whatever), they'll need to be built for the Pandora. You could just run the whole build process on the Pandora, but if you can make cross-compiling work through the build command, then it should be no additional effort to make it work with bdist_pnd. You might want to take a look at distutilscross to help with this.


PPS: You might also be interested in stdeb, a Distutils extension to build deb packages. Since debs are identical to ipks, this would allow you to build PNDs and Pandora-installable ipks from the same build script! I find that exciting.
 
Last edited by a moderator:
Great job! :D


I'll be sure to test it on the crappy simple pygame game I've written.


Don't have my pandora yet but I'll try to package what I have, see if it fit my needs.


Clop'
 
Great job! :D


I'll be sure to test it on the crappy simple pygame game I've written.


Don't have my pandora yet but I'll try to package what I have, see if it fit my needs.


Clop'
Hey! Copyright infringement. I've written a crappy simple pygame. :p
 
Can someone turn this into a Pandora file and put on the app site please?
It is done. Since I can't test it, I don't want to put it in the app store, but if anyone else tries it and it works, feel free to put it up (or tell me about it and I can put it up, I guess).


When I downloaded the sources, I was very upset that the creator hadn't made a setup script. But then I had so much fun playing it that I had to package it. I made some minor edits - added an empty __init__.py file to lib and made a three-line change to run_game.py - then created a setup.py and setup.cfg that I'll include here for posterity:

setup.py:



Code:
import sys

sys.path.append('/home/randy/Projects/distPND')


from distutils.core import setup

from glob import glob


setup(

    name = 'BubbMan2',

    version = '1.0',

    description = 'A solo entry by pymike for PyWeek #8',

    author = 'pymike',

    maintainer = 'Tempel',

    maintainer_email = 'randy.heydon@clockworklab.net',

    url = 'http://www.pygame.org/project-BubbMan+2-1114-.html',

    packages = ['lib','retrogamelib'],

    package_data = {'retrogamelib': ['*.png']},

    data_files = [('data', glob('data/*'))],

    scripts = ['run_game.py'],

    license = 'GPL',

)



setup.cfg:



Code:
[global]

command-packages=distpnd


[gen_pxml]

categories=Game:ActionGame

icon=data/logo.png


[bdist_pnd]

info=Readme.txt

pndname=BubbMan2.pnd
 
Being a python enthusiast I'm looking forward with playing with this.. Not a game programmer, but may make some handy utilities down the road once I get my Pandora.
 
With this tool is it possible to declare a folder that gets copied/created in the appdata folder (similar to quake and pak files)? I have a python project with copyrighted images that need to be downloaded and copied in after a first run.
 
DasFool: That's very possible, though distPND won't do that part for you. I'm not familiar with how Quake handles it, but you could add something like this to the program's startup:



Code:
if not os.path.isdir(datadir):

    urllib.urlretrieve('http://source.file')

If you can direct me to the program/code in question, I'd be happy to help you make it work.
 
Has anyone actually tested this on their Pandora ? Lots of posts saying "I will test this" but very little feedback as to whether it works or not :) I'd like to have an update on this - thanks for your help.
 
It works in that it successfully makes PNDs (for example, I used it to package PNDstore). If you mean making packages on your Pandora, there is no technical limitation on distPND. It makes PNDs on desktops, so it will make PNDs on a Pandora. I don't know if anyone's actually done so, but I pretty much guarantee it'll work.
 
Last edited by a moderator:
It works in that it successfully makes PNDs (for example, I used it to package PNDstore). If you mean making packages on your Pandora, there is no technical limitation on distPND. It makes PNDs on desktops, so it will make PNDs on a Pandora. I don't know if anyone's actually done so, but I pretty much guarantee it'll work.

Allright - but what do you mean in your first post when you said "it's kind of hackish and somewhat limited. " - are there other limitations than the ones you mentioned in your post ?
 
For one, it won't do anything about dependencies; it's up to you to put any needed libraries into the build_pnd folder before building. For another, it doesn't play very nicely with data_files, since I don't really get how one should use data_files in any situation; use package_data and paths relative to __file__ instead.


But those are the only things off the top of my head. If there are any other limitations, you're going to have to tell me. I am eager to help you get up and running.
 
Back
Top