0
votes

I would like to find a way to deploy Python programs as an executable on Debian where I would be able to bundle:

  1. the dependencies and third party libs
  2. the code that might need to be installed on the host machine. Typically some libs in Python like pilow or snappy are depending on shared libraries within /usr/lib

I think you can achieve (1) and (2) separately. To achieve (1), I believe that there exists different ways to ship virtualenv, and for (2) I've seen some people using Docker image or Ansible to install tool/module on the host OS.

To me, it feels that by having 2 systems to achieve (1) and (2) there is a risk to have them unsynced. It feels very error prone to think that if someone adds an external dependency in its Python program he might also has to change a Docker image. So I'm wondering if there something that does both.

3

3 Answers

2
votes

I read about 2 days back about XAR, executable archive by FB. Have a look at it

0
votes

Yes, the two apps I know of are py2exe and PyInstaller. I'm pretty sure both support Python 3 and can store dependencies, libraries, etc. I recommend this link for more info: Making a Stand Alone Executable from a Python Script using PyInstaller

0
votes

I'm achieving exactly the same with Ansible and virtualenv with a requirements file for Debian, MacOsX (brew) and RedHat.

As part of the playbook example:

  - name: Install prerequisite pip packages
    pip:
      requirements: "{{ _tmp.path }}/{{ required_pip_packages }}"
      virtualenv:  "{{ venv_dir }}"

Let me know if you require more information.