Which files to distribute using cx_Freeze? - python

I'm using cx_freeze to freeze a Python script for distribution to other windows systems. I did everything as instructed and cx_freeze generated a build\exe.win32-2.6 folder in the folder containing my sources. This directory now contains a a bunch of PYD files, a library.zip file, the python DLL file and the main executable. Which of these files would I need to distribute? Any help, guys?
Thanks in advance.

You need all of them.

Related

How are the .exe files in Scripts folder for python generated?

I don't know if my question is ambiguous or not but, I noticed that in Scripts folder inside the python installation folder there are executable files. Each file about a 100kb in size.
FYI: when I open it (or them) using 7Zip I often find a init.py file inside.
Thanks
I have tried researching but can't seem to find the answer.
The setuptools package builder is able to
Automatically generate wrapper scripts or Windows (console and GUI) .exe files for any number of “main” functions in your project. (Note: this is not a py2exe replacement; the .exe files rely on the local Python installation.)
(ref. from setuptools documentation)
Unfortunately the way it is actually done is considered an implementation detail and is not documented.

Convert a visual studio python project to one executable file

I have finished my python project and now want to transfer the project into one file, so a user can just double click it and doesn't have to compile it first.
Therefore, I wanted to know if this is possible with python.
I 've read that you can convert a single python script into an executable file using pyinstaller. But in my case I have many files in different folders and I want them to be include in the executable file because otherwise the programm doesnt work.
I also tried this via the auto-pyto-exe converter (https://github.com/brentvollebregt/auto-py-to-exe) but I didnt got the results I wanted.
Therefore, my question is, how can I convert my visual studio python-project with many different files and folders into one executable file, so a user can just double click the file to start it?
Edit
In the other folder are also .py files like some FileImport.py or View.py. I separated these files that the whole project looks cleaner.
The Folder structure looks as follows:
-Views
---MainView
---UpdateView
---AnotherView
-Controllers
---MainViewController
---UpdateViewController
-Model
---MainModel
I found the solution. As it appears the pyinstaller can find all dependencies when you compile your script via pyinstaller myscript.py. PyInstaller creates three different folders where all necessary files are located. In the dist folder one executable is located which can be used from computers without python installed.
I hope this helps somebody who has the same problem.

using PyInstaller as Installer

Is it possible to do a two steps decompression with PyInstaller?
e.g. it can decompress archived files from itself as needed, like InnoSetup, Nullsoft Installer (NSIS).
For --onefile exe generated with PyInstaller, everything is decompressed at invocation runtime, and it takes a lot of time, if there's a lot of bundled datafile.
What I trying to do is to replicate InnoSetup with PyInstaller+PyQt. Any ideas?
Yes you can. You can bundle installer files by appending to a.data in your spec file. Then at runtime your data files will be in the MEIPASS folder and you can copy them wherever you want. https://stackoverflow.com/a/20088482/259538

Keeping the .dll and .pyd files in other directory

I am using cx_Freeze to convert Python scripts to Windows executable. I am using cxfreeze script present in the Scripts directory. I want the executable generated by cxfreeze to be in a different directory and the .dll's and .pyd's in a different one. When I tried to put the two of them in separate directories the .exe did not work I got
The application has failed to start because python33.dll was not found. Try reinstalling to fix this problem
I know this happends because the executable and (dll's & .pyd's) are located in different directories. Is there a way to keep them in different directories ?
I am using the following command to generate the executable
C:\Python33\Scripts>cxfreeze C:\Users\me\Desktop\setup.py --target-name=setup.exe --target-dir=C:\Users\me\Desktop\new_dir
Python for Windows really requires that the main pythonXX.dll (in this case, python33.dll) exists in C:\windows\system32\
In all of our various combinations of installing Python to different locations, network drives, etc. we've always had to use a little batch file to copy pythonXX.dll into the system32 dir.
I don't think PATH manipulation will work for you, just try copying the dll to system32 and see if your issues go away.
Then again, if you installed another version of Python to say C:\Python33 , then that windows-based installer will do this for you, and you'll be able to run your other Python location.

cx_Freeze and PYC/PYD files

I'm using cx_Freeze to freeze my python program. On running cx_Freeze, a bunch of PYD files are created, a whole bunch of PYC files are put into a archive named library.zip and a few DLL files are there too.
Could someone tell me the difference between the PYC and the PYD files?
What's the reason for the PYD files not in the library.zip?
Is it possible to put the PYD files into the archive as well?
Thanks.
Disclaimer: I haven't used cx_Freeze in awhile......
.PYD files are DLL machine-code files that contain specific python-required functions.
.PYC files are .py files that have been compiled into bytecode.
so PYDs are machine code and PYCs are bytecode
Now as for why the PYDs aren't in the .zip....I'd imagine it's because those .PYDs are needed by the python interpreter to run the program. What cx_Freeze does is basically this:
compile all .py files and throw the .pyc files in a zip
put all needed .pyd files in the zip
create a stub .py file and put it in the output directory
copy the python.exe and rename to myprogram.exe
copy all .pyd files needed to open the .zip and run the contents
So you're not actually compiling your python file, you're instead renaming the interpeter and freezing all the source files.
I hope this helps.

Categories

Resources