maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Proper Way to Distribute Python Apps? (https://talk.maemo.org/showthread.php?t=38825)

aspidites 2009-12-30 18:22

Proper Way to Distribute Python Apps?
 
I'm trying to figure out the proper way to package my aptly for distribution. Following the Py2deb wiki article, I came up with the following src structure:
Code:


/usr/bin/aptly
/usr/lib/aptly/
/usr/lib/aptly/aptly.py
/usr/lib/aptly/aptly-curses.py
/usr/share/doc/aptly
/usr/share/doc/aptly/README
/usr/share/doc/aptly/COPYING

It then dawned on me that aptly.py can be imported as a module in order to add a GUI to it (the strategy I'm using with aptly-curses.py), so it would need to be accessible by other python scripts. As such, I changed the above to the following:
Code:

/usr/lib/python2.5/site-packages/aptly.py
/usr/share/doc/aptly
/usr/share/doc/aptly/CHANGES
/usr/share/doc/aptly/README
/usr/bin/aptly

This leaves me with a few questions:
  1. To invoke the curses (or any GUI for that matter, should a) I place the appropriate script (for example aptly-curses.py) in /usr/bin as a python script or should I b) add that script to site-packages/aptly and write a script that calls it into /usr/bin?
  2. To call the command line variant, would I just make the /usr/bin/aptly script a bash script that calls the module passing it all arguments?
  3. Should the license and other documentation remain in /usr/share/doc/aptly, or should everything be moved (including aptly.py) to a directory named aptly under site-packagres instead?
Until I figure this out, I'm placing everything in site-packages except for aptly-curses

Jaffa 2009-12-30 20:23

Re: Proper Way to Distribute Python Apps?
 
Your basic structure looks fine.

Your /usr/bin "launchers" can either be shell scripts which launch Python appropriately; Python scripts (without a trailing .py), or symlinks to wherever you want.

I've typically used the former. Remember, as a Python app, anything you put in /usr/lib/python2.5 will automatically be put outside of the rootfs, but anything else will be inside it - and so you'll want to minimise the disk usage.

aspidites 2009-12-30 20:55

Re: Proper Way to Distribute Python Apps?
 
Ok. So I've decided to put everything except for a shell script that calls aptly inside site-packages like so:
Code:

/usr/lib/python2.5/site-packages/aptly
/usr/lib/python2.5/site-packages/aptly/aptly.py
/usr/lib/python2.5/site-packages/aptly/COPYING
/usr/lib/python2.5/site-packages/aptly/CHANGES

/usr/bin/aptly

/usr/bin/aptly contains the following:
Code:

!#/bin/bash

exec /usr/lib/python2.5/site-packages/aptly/aptly.py $@


fatalsaint 2009-12-30 21:18

Re: Proper Way to Distribute Python Apps?
 
I don't know about the N900... but usually it's recommended in shell scripts to use #!/bin/sh ... for compatibility purposes with systems that either don't have bash, or have it in a different location.

At least.. that's what I've been told before..

(assuming you don't use bash-specific calls)

j.s 2009-12-30 21:28

Re: Proper Way to Distribute Python Apps?
 
Quote:

Originally Posted by fatalsaint (Post 447155)
I don't know about the N900... but usually it's recommended in shell scripts to use #!/bin/sh ... for compatibility purposes with systems that either don't have bash, or have it in a different location.

At least.. that's what I've been told before..

(assuming you don't use bash-specific calls)

Also, bash is not installed by default on the n900.

fatalsaint 2009-12-30 21:31

Re: Proper Way to Distribute Python Apps?
 
That is definitely a handy piece of information...

aspidites 2009-12-30 23:39

Re: Proper Way to Distribute Python Apps?
 
Doh! can you tell i don't write shell scripts?

Thanks again, third time's a charm

Jaffa 2009-12-31 12:30

Re: Proper Way to Distribute Python Apps?
 
Quote:

Originally Posted by aspidites (Post 447118)
/usr/bin/aptly contains the following:
Code:

!#/bin/bash

exec /usr/lib/python2.5/site-packages/aptly/aptly.py $@


You want this to be:

Code:

#!/bin/sh

exec /usr/lib/python2.5/site-packages/aptly/aptly.py "$@"

  1. Note "#!" rather than "!#"
  2. bash vs. sh already mentioned
  3. "$@" will ensure that any parameters containing spaces will be quoted properly.

aspidites 2009-12-31 15:14

Re: Proper Way to Distribute Python Apps?
 
i had the # before ! in the actual code. it was a typo. good point about the qoutes though


All times are GMT. The time now is 09:22.

vBulletin® Version 3.8.8