I would like to find a way to deploy Python programs as an executable on Debian where I would be able to bundle:
- the dependencies and third party libs
- the code that might need to be installed on the host machine. Typically some libs in
Pythonlikepiloworsnappyare 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 Answers 3
Comments
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
1 Comment
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.
2 Comments
python-snappy that depends on shared libraries within /usr/lib. Typically before pip you need to install something on the host OS like this sudo apt-get install -y libsnappy-dev