Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    Proper Way to Distribute Python Apps?

    Reply
    aspidites | # 1 | 2009-12-30, 18:22 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to aspidites For This Useful Post:
    hypnotik, tuminoid

     
    Jaffa | # 2 | 2009-12-30, 20:23 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to Jaffa For This Useful Post:
    aspidites, hypnotik

     
    aspidites | # 3 | 2009-12-30, 20:55 | Report

    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 $@

    Edit | Forward | Quote | Quick Reply | Thanks

     
    fatalsaint | # 4 | 2009-12-30, 21:18 | Report

    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)

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to fatalsaint For This Useful Post:
    aspidites

     
    j.s | # 5 | 2009-12-30, 21:28 | Report

    Originally Posted by fatalsaint View Post
    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to j.s For This Useful Post:
    fatalsaint

     
    fatalsaint | # 6 | 2009-12-30, 21:31 | Report

    That is definitely a handy piece of information...

    Edit | Forward | Quote | Quick Reply | Thanks

     
    aspidites | # 7 | 2009-12-30, 23:39 | Report

    Doh! can you tell i don't write shell scripts?

    Thanks again, third time's a charm

    Edit | Forward | Quote | Quick Reply | Thanks

     
    Jaffa | # 8 | 2009-12-31, 12:30 | Report

    Originally Posted by aspidites View Post
    /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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 3 Users Say Thank You to Jaffa For This Useful Post:
    fatalsaint, noobmonkey, twaelti

     
    aspidites | # 9 | 2009-12-31, 15:14 | Report

    i had the # before ! in the actual code. it was a typo. good point about the qoutes though

    Edit | Forward | Quote | Quick Reply | Thanks

     
vBulletin® Version 3.8.8
Normal Logout