Standalone Python applications in Linux

前端 未结 8 2327
被撕碎了的回忆
被撕碎了的回忆 2020-12-04 10:54

How can I distribute a standalone Python application in Linux?

I think I can take for granted the presence of a recent Python interpreter in any modern distribution.

相关标签:
8条回答
  • 2020-12-04 11:17

    Create a deb (for everything Debian-derived) and an rpm (for Fedora/SuSE). Add the right dependencies to the packaging and you can be reasonably sure that it will work.

    0 讨论(0)
  • 2020-12-04 11:19

    You can't easily do it in a distribution-neutral format. The only reliable dependency tracking mechanisms are built into the package management systems on the distributions and will vary from distribution to distribution. You'll effectively have to do rpm for fedora, debs for ubuntu and debian etc.

    Py2exe works fine on Windows. It builds a distribution with all of the necessary DLL's and a wrapper for the python interpreter that starts your program. It's fairly straightforward to install - just drop it in a directory - so making a msi file for it is trivial.

    0 讨论(0)
  • 2020-12-04 11:25

    The standard python way is to create a python "Egg".

    You could have a look at this tutorial, or this page about setuptools.

    0 讨论(0)
  • 2020-12-04 11:26

    I think you can fairly safely take for granted python support on most modern Linux distributions - for the ones without it as long as a sane error message is given, users should probably be able to work how to get it on their own (you can use a simple bash startup script for this):

    #!/bin/bash
    if [ -e /usr/bin/python ]
    then
        echo "Python found!"
    else
        echo "Python missing!"
    fi
    
    0 讨论(0)
  • 2020-12-04 11:28

    You might want to look at the dependency declarations in setuptools. This might provide a way to assure that the right packages are either available in the environment or can be installed by someone with appropriate privileges.

    0 讨论(0)
  • 2020-12-04 11:29

    Nope.

    Python is notoriously flaky with respect to different setups. The only sane way to deploy a python app is to ship the whole bundle of interpreter and libraries that you are relying on with your code. That will most likely work.

    Update 2019: I stand by this. Virtualenv is a way of packaging libraries and interpreters together. Tox is a testing tool to test that interpreter/dependency matrix. Docker is a widely used way of then deploying the bundle.

    0 讨论(0)
提交回复
热议问题