Create single python executable module - python

Guys, I have much python code in modules which are resides in several python packages and now I need to create single python executable module or file which will include all these files, so it will be working on windows and on linux servers. What are possible solutions and how this can be done?

For windows use py2exe , for linux use pyinstaller and for Mac use py2app
Using these tools you can have a setup.py which based on os will build the final binary.
I have tried all three and they work well, or you can use cx_freeze they claim to be cross-platform

That's what egg files are for. Read this: What are the advantages of packaging your python library/application as an .egg file?

Maybe py2exe can help you ..
py2exe is a Python Distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation.
Tutorial > http://www.py2exe.org/index.cgi/Tutorial

You can kivy for python cross plat form application .
Kivy - Open source Python library for rapid development of applications
that make use of innovative user interfaces, such as multi-touch apps

Related

Remove dependencies when compiling .py to .exe [duplicate]

I need to package my Python application, its dependencies, and Python itself into a single MSI installer for distribution to users. The end result should desirably be:
Python is installed in the standard location
the package and its dependencies are installed in a separate directory (possibly site-packages)
the installation directory should contain the Python uncompressed and a standalone executable is not required
Kind of a dup of this question about how to make a python into an executable.
It boils down to:
py2exe on windows, Freeze on Linux, and
py2app on Mac.
I use PyInstaller (the svn version) to create a stand-alone version of my program that includes Python and all the dependencies. It takes a little fiddling to get it to work right and include everything (as does py2exe and other similar programs, see this question), but then it works very well.
You then need to create an installer. NSIS Works great for that and is free, but it creates .exe files not .msi. If .msi is not necessary, I highly recommend it. Otherwise check out the answers to this question for other options.
My company uses the free InnoSetup tool. It is a moderately complex program that has tons of flexibility for building installers for windows. I believe that it creates .exe and not .msi files, however. InnoSetup is not python specific but we have created an installer for one of our products that installs python along with dependencies to locations specified by the user at install time.
I've had much better results with dependencies and custom folder structures using pyinstaller, and it lets you find and specify hidden imports and hooks for larger dependencies like numpy and scipy. Also a PITA, though.
py2exe will make windows executables with python bundled in.
py2exe is the best way to do this. It's a bit of a PITA to use, but the end result works very well.
Ok, I have used py2exe before and it works perfectly except for one thing... It only works on executable windows machines. I then learned about Jython which turn a python script into a .Jar file. Which as you know is executable from any machine that has Java ("To your latest running version") installed. Which is great because both unix, windows, and ios (Most of the time) Run java. That means its executable from all of the following machines. As long as they run Java. No need for "py2mac + py2exe + freeze" just to run on all operating systems. Just Jython
For more information on how it works and how you can use it click here.
http://www.jython.org/

Creating Setup for Windows Systems

This is the question: How to create a setup file(.msi) from a .py file? I have a little script but I need an installer to use it with "InstallSimple" program wich will install another applications.
I tried with pyinstaller but it supports 2.3-2.7 versions and I have an script for 3.3 version.
To create an .msi file you need to use distutils. The essential procedure there is to create a setup.py file with information about your script, and you can then run python setup.py bdist_msi and it will create an .msi file for you.
However, using only this will create an .msi-file for your Python script, but it will require you to install Python on the computer first. This is probably not what you want. To solve that you can create an .exe-file from your script with cx_Freeze. cx_Freeze can in turn use distutils to make the .msi file. There is an example here.
Have you tried cx_Freeze ? According to the latest docs cx_Freeze 4.3.1 documentation, it supports python3.

Using Wine and py2exe to create windows application out of a Python project

I recently built an application, for a client, which has several python files. I use ubuntu, and now that I am finished, I would like to give this to the client in a way that would make it easy for her to use in windows.
I have looked into py2exe with wine, as well as cx_freeze and some other stuff, but cannot find a straightforward tutorial or useful documentation for turning many python files in ubuntu into an easy-to-use windows application or executable or anything really.
Thanks!
This page appears to have a solution, as the asker didn't reply:
Install WINE.
Use WINE to install Python 2.3.
Use WINE to install py2exe.
Make a setup.py file for py2exe to compile your script:
from distutils.core import setup
import py2exe
setup(name="vervang",
scripts=["vervang.py"],
)
Run wine python.exe setup.py py2exe
This page says the resulting binaries might not be valid Win32 executables, though.
py2exe will not work on linux. Try pyinstaller it is a pure python implementation that will work on linux, mac and windows.

build my project to installer for non python enviroment(both windows and linux)

my directroty sturcture is
/src (the source code directory including images)
/src/main.py (main script)
/src/subprojectfile/ (it consist of other several project file include __init__.py)
In my project I am using google procolbuffer,pygtk and other common python package like sys,time,thread etc..
I want to build an installer for non python system where user can install my application with out any python support.
For an alternative approach you might check out PyInstaller. It doesn't produce a proper installer, but rather standalone executables without external dependencies.
For windows you can use py2exe and for Linux have a look at freeze.

Python: Handling modules

I wrote a program which uses a number of built in modules. The program is meant to be used by different persons on their systems. They dont have enough knowledge in python to install it when their system doesnt have the module needed to run the program. Is there any way of handling that.
Also I want to package the program as an executable in linux. It contains 3 py files and one text file only.
I think what you need is to create a debian package that handles the dependencies and the installation process.
I'm an Ubuntu user but this Complete Ubuntu Packaging Guide should help you get started. Good luck!
You can create an executable that contains your python modules and the python interpreter. You can use PyInstaller for creating such an executable.
I think the easiest way to achieve this on a debian distribution is to package your python application in a debian package. You can use this module to make life easier.

Categories

Resources