One of common question of python programming is how to do jar equivalent - i.e. run something like python myapp.zip . Below I describe a method producing a close result (hey python team - good place to enhance): unfortunately couple of bugs in python zip handling (e.g. python can't import module from zipfile with comments) make this task a little bit tricky.

  1. Make sure you app is ready to work with zip bundle i.e. file is replaced to ZipFile when necessary.
  1. Prepare the entry point:
    main.py
    def __main__():
         ....
    
  1. create a bundle
    zip -r test.zip *.py *.pyc
    
  1. create a launcher either shell or pure python one and place it somewhere.
#!/bin/sh
mod="$1"
shift
python -c "import sys; sys.path.insert(0,'${mod}'); import main;main.__main__()" $*
import sys
sys.path.insert(0,sys.argv[1])
import main
main.__main__()

enjoy

 

Канал Частота (МГц)

  • 1 446,00625
  • 2 446,01875
  • 3 446,03125
  • 4 446,04375
  • 5 446,05625
  • 6 446,06875
  • 7 446,08125
  • 8 446,09375

Хорошие (на мой вкус) стихи XX - XXI века. Арчету посвещается.