Creating a Portable Python (local install) for Linux

后端 未结 7 1140
醉酒成梦
醉酒成梦 2021-02-07 15:53

I\'m looking to create the following:

A portable version of python that can be run on any system (with any previous version of python or no python installed) and have it

7条回答
  •  余生分开走
    2021-02-07 16:36

    I don't know how this is even possible. If it were, they woudn't need to distribute binary packages of python for different platforms. You can't simply distribute python that will run on any platform. It has to be built from source for that arch. Virtualenv will expect you to tell it which system python to use (using links).

    This pretty much goes for almost any binary package that links against system libs. Again, if it were possible, we wouldn't need any platform specific binary distributions.

    You can, however, achieve part of what you want. That is, running python on another machine that doesn't have python installed as long as its the same arch. This is the same concept behind freezing, or py2exe/py2app/pyinstaller. An interpreter is bundled into a standalone environment. So the app can run on any similar platform.

    Edit

    I just realized that while your question speaks about "system" agnostically, your title contains the reference "linux". There are different flavors of linux, so in order for it to work you would have to build it fat for multiple archs and also completely contain the standalone links. You might try building a package with pyinstaller and using that to include in your project.

    You can try just building python from source, in your virtualenv:

    $ ./configure --prefix=/path/to/virtualenv && make && make install
    

    If you still have problems with the links to libs, you can also investigate building it statically

提交回复
热议问题