Py2deb examples
Home Home Contact us Contact
home News Projects Tests Files Follow manatlan on Twitter Sign in
Last edition : 2008/10/14 20:37

back

When we do :

p=Py2deb("packageName")

'p' acts like a dict, where the keys are the destination folder, and the value : a list of existing files.

p["/usr/share/deleteme"]=["file1.py","file2.png",]

(files "file1.py" and "file2.png" should be in the current execution path)

It will generate a "packageName" deb which will install files like that :

  • /usr/share/deleteme/file1.py
  • /usr/share/deleteme/file2.png

Relatives files are installed with their relative path, so something like this :

p["/usr/share/deleteme"]=["file1.py","data/file2.png",]

will produce :

  • /usr/share/deleteme/file1.py
  • /usr/share/deleteme/data/file2.png

It's possible to define files with absolute path too, like that :

p["/usr/share/deleteme"]=["file1.py","/home/me/file2.png",]

which will produce :

  • /usr/share/deleteme/file1.py
  • /usr/share/deleteme/file2.png

But it's possible to rename files, with the 'pipe trick', which can be very handy is some cases :

p["/usr/bin"]=["file1.py|executable",]
p["/usr/share/doc/me"]=["/home/me/mon_cv.htm|cv.html",]

which will produce :

  • /usr/bin/executable (file1.py was renamed as executable)
  • /usr/share/doc/me/cv.html (which was /home/me/mon_cv.htm)

It can be useful to relocate some files too, like that :

p["/usr/share/deleteme"]=["data/images/image.png|image.png","README|doc/french/readme.txt"]

which will produce :

  • /usr/share/deleteme/image.png (image.png is placed at the root path)
  • /usr/share/deleteme/doc/french/readme.txt (README is placed in folders)

At anytime, to see what will be produce, simple 'print p', it will print informations about current package 'p', and list where files will be.

In this case, if the folder 'test' contains file1.py and file2.py

from glob import glob
...
p["/usr/lib/aeff2"] = glob("test/*")
p["/usr/lib/aeff3"] = [i+"|"+i[5:] for i in glob("test/*")]
...
print p

will print :

[...]
/usr/lib/aeff2/test/file1.py
/usr/lib/aeff2/test/file2.py
/usr/lib/aeff3/file1.py (test/file1.py)
/usr/lib/aeff3/file2.py (test/file2.py)
[...]

when a line contains something in '()', it should warn you that the file was renamed/relocated, so the real path of the file is displayed between the '()'.

Just note that the two following commands should produce the same thing :

p["/usr/lib/hello"] = ["file1.png|data/file1.png",]
p["/usr/lib/hello/data"] = ["file1.png",]

something like this : /usr/lib/hello/data/file1.png

back

RSS Python Powered Get Ubuntu
©opyleft 2008-2019 - manatlan