Making a python package and cross-platform compatible

This is the place for queries that don't fit in any of the other categories.

Making a python package and cross-platform compatible

Postby RedEyedDog1 » Thu Oct 10, 2013 11:30 am

Hi

Ive been trying todo this for the couple of days and i realy cant figure it out and my boss is going to be getting angry soon. Need help ASAP

Im running Debian GNU/Linux 6.0.7 (squeeze)

Im trying to make a python program package from my OS to a LINUX 2.6.9.

I've got the python code. Ive got Python3 installed and python 2.6.

Ive also downloaded cx_freeze. when i run cxfreeze on the main .py script it create a dis directory with an executable. but this seems to bee missing a few things.

Note i have run the script by using ($python3 script.py ) this runs fine and the code starts to execute. Im just haveing trouble making a package :(

when i installed i used ($python setup.py build) becuase ($python3 setup.py build) dosent work becuase its missing zlb?

Any help would be appreciated thanks :)
Last edited by Mekire on Thu Oct 10, 2013 2:10 pm, edited 1 time in total.
Reason: First post lock
RedEyedDog1
 
Posts: 17
Joined: Thu Oct 10, 2013 11:21 am

Re: Making a python package and cross-platform compatible

Postby gplayersv » Thu Oct 10, 2013 1:18 pm

You can try http://www.pyinstaller.org/.

Why do you say that the dis directory made by cx_freeze is missing a few things?
And I suppose you tried running the script from the dis directory on LINUX 2.6.9 machine, not on your dev machine, and it worked.
If so, then what package do you want to make?

A python package is just a structure of folders and files - http://docs.python.org/2/tutorial/modules.html#packages.
If python and all the libraries used by your script are available on the 2.6.9 machine just copy the source files there and run it, if not, cx_freeze or pyinstaller will make a folder or a single file with all required imports which can run on (theoretically) any machine.
User avatar
gplayersv
 
Posts: 6
Joined: Mon Apr 15, 2013 10:56 am

Re: Making a python package and cross-platform compatible

Postby RedEyedDog1 » Thu Oct 10, 2013 2:22 pm

Hi thank you for replying

I read pyinstaller only makes an executable that works on windows?

i use cxfreeze on the main .py file, which creates a dis folder with an executable of the main .py file ( and some other files) but none of the other .py files that are needed ? are they included in the executable?

I havent tryed it on the linux 2.6.9 yet becuase i thought if it wasnt working on my debian it wont work over there. Is that not write.

Also when i use cxfreeze it refrences python2.6 but the code uses python3.3 libaries. have i installed cx_freeze right? if not how do you do it so it refrences python3.3?

Thank you so much
RedEyedDog1
 
Posts: 17
Joined: Thu Oct 10, 2013 11:21 am

Re: Making a python package and cross-platform compatible

Postby metulburr » Fri Oct 11, 2013 1:36 pm

this
Note i have run the script by using ($python3 script.py ) this runs fine and the code starts to execute. Im just haveing trouble making a package :(

and this
when i installed i used ($python setup.py build) becuase ($python3 setup.py build) dosent work becuase its missing zlb?

are two different things. The second is creating a package, while the first is directly calling the python interpreter to execute the code.
Code: Select all
python setup.py build

is going to make the build using python2.x libraries, while
Code: Select all
python3 setup.py build
is going to make the build using the python3.x libraries
If you build it using 2.x libraries, you need cx_freeze installed for python2.x, likewise if you build it using 3.x libraries, you need cx_freeze installed for python3.x. If both of those commands worked, than you have it installed for both 2.x and 3.x.

becuase ($python3 setup.py build) dosent work becuase its missing zlb?

this would indicate that your python3.x does not have cx_freeze installed, and therefore cannot make a build using python 3.x. Either that or you messed up the setup script or you typo'd the module zlib? I couldnt tell without your setup script and error you get.
New Users, Read This
version Python 3.3.2 and 2.7.5, tkinter 8.5, pyqt 4.8.4, pygame 1.9.2 pre
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
User avatar
metulburr
 
Posts: 1104
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Making a python package and cross-platform compatible

Postby RedEyedDog1 » Fri Oct 11, 2013 2:39 pm

Ok i understand that now. I think i know where im going wrong

i think my problem is i'm not installing python3.3 correctly

I downloaded the package, extracted and then the README says
'./configure', then 'make', and then 'make test'

when i make test, which i never did befor i get this error
root@debian:/home/halo11/Downloads/Python-3.3.2# make test
running build
running build_ext

Python build finished, but the necessary bits to build these modules were not found:
_bz2 _lzma
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

running build_scripts
copying and adjusting /home/halo11/Downloads/Python-3.3.2/Tools/scripts/pydoc3 -> build/scripts-3.3
copying and adjusting /home/halo11/Downloads/Python-3.3.2/Tools/scripts/idle3 -> build/scripts-3.3
copying and adjusting /home/halo11/Downloads/Python-3.3.2/Tools/scripts/2to3 -> build/scripts-3.3
copying and adjusting /home/halo11/Downloads/Python-3.3.2/Tools/scripts/pyvenv -> build/scripts-3.3
changing mode of build/scripts-3.3/pydoc3 from 644 to 755
changing mode of build/scripts-3.3/idle3 from 644 to 755
changing mode of build/scripts-3.3/2to3 from 644 to 755
changing mode of build/scripts-3.3/pyvenv from 644 to 755
renaming build/scripts-3.3/pydoc3 to build/scripts-3.3/pydoc3.3
renaming build/scripts-3.3/idle3 to build/scripts-3.3/idle3.3
renaming build/scripts-3.3/2to3 to build/scripts-3.3/2to3-3.3
renaming build/scripts-3.3/pyvenv to build/scripts-3.3/pyvenv-3.3
./python -E -c 'import sys ; from sysconfig import get_platform ; print(get_platform()+"-"+sys.version[0:3])' >platform
./python ./Tools/scripts/run_tests.py
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
make: *** [test] Aborted
RedEyedDog1
 
Posts: 17
Joined: Thu Oct 10, 2013 11:21 am


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 3 guests