0

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.

asked Jul 15, 2018 at 0:01

3 Answers 3

2

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

jeremie
1,14112 silver badges23 bronze badges
answered Jul 15, 2018 at 10:29
Sign up to request clarification or add additional context in comments.

Comments

0

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

answered Jul 15, 2018 at 1:57

1 Comment

I was not really thinking of windows-executable. I'm actually deploying on Debian
0

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.

answered Jul 15, 2018 at 10:27

2 Comments

But then how do you deal with libs like 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
Before that, I have a python script that prepares those packages (In my case git, krb, etc). Inside the same script I programmatically call the ansible yaml to continue the env preparation. I can send you some script examples if you require them.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.