py2exe change application name output - python

I am working on my first Python project and I need compile with py2exe. I wrote this setup.py code :
from distutils.core import setup
import py2exe
import sys
import os
if len(sys.argv) == 1:
sys.argv.append("py2exe")
setup( options = {"py2exe": {"compressed": 1, "optimize": 2,"dll_excludes": "w9xpopen.exe",'dist_dir': "myproject", "ascii": 0, "bundle_files": 1}},
zipfile = None,
console = [
{
"script": "myapplication.py", ### Main Python script
"icon_resources": [(0, "favicon.ico")] ### Icon to embed into the PE file.
}
],)
os.system('upx -9 dist/*.exe')
os.system("rmdir /s /q build")
os.system("del /q *.pyc")
The setup code is working, but I need to change the name of the compiled application from myapplication to project.exe. What options for py2exe change the name of output application?

Add "dest_base" : "app_name" to your console dict as such:
console = [
{
"script": "myapplication.py", ### Main Python script
"icon_resources": [(0, "favicon.ico")], ### Icon to embed into the PE file.
"dest_base" : "app_name"
}]

Related

Auto update app desktop python with Pyqt5 and AWS RDS

I want to launch a desktop application to run customer records for my sister at work,
We are actually using local storage with sqlite3, but I will switch to AWS RDS sql
The application uses these packages:
from PyQt5 import uic,QtWidgets
from reportlab.pdfgen import canvas
import sqlite3, csv
Our biggest problem is the update in the application that for each new functionality needs a new installation,
The packages I want to send in the update can contain .ui files,
I try unsuccessfully to use:
-Updater4pyi
-PyUpdater
-Esky
Esky seemingly out of phase and do not support some configurations and I believe that the tools doesn't work correctly freezing the app to .exe because de .ui files,
What is the possible solution to this issue?
Thank you in advance
Setup.py
import esky.bdist_esky
from esky.bdist_esky import Executable as Executable_Esky
from cx_Freeze import setup, Executable
include_files = ['consulta2.ui']
setup(
name = 'cadastro',
version = '1.0',
options = {
'build_exe': {
'packages': ['sqlite3','csv'],
'excludes': ['tkinter','tcl','ttk'],
'include_files': include_files,
'include_msvcr': True,
},
'bdist_esky': {
'freezer_module': 'cx_freeze',
}
},
data_files = include_files,
scripts = [
Executable_Esky(
"controle.py",
gui_only = False,
#icon = XPTO #Coloque um icone aqui se quiser ,
),
],
executables = [Executable('controle.py',base='Win32GUI')]
)
I want to execute continuos deploy,
With new functions and screens

Problems with Cx_freeze

If I'm actually asking you for help, it's because I spend many hours for nothing into trying to fix my problem:
I would like to compile my python script into .exe:
(I am using Python 32 bits 3.1.4 and pygame)
I have 4 files: Class.pyc, _Class_game.pyc, _ressources.pyc et main.py
and a folder #ressources with all images and songs
This is my scritp setup.py:
import cx_Freeze
executables = [cx_Freeze.Executable("main.py"), base = "Win32GUI"]
cx_Freeze.setup(
name="Strike The square",
version = "2.0",
description = "Jeu Strike The Square, V2.1",
options={"build_exe": {"packages":["pygame"],
"include_files": ["_Class_.pyc","_Class_game.pyc","_ressources.pyc"]}},
executables = executables
)
This create a folder "exe.xin32-3.1" with python (compiled) and my game
Next, I use inno setup to build the installer and add the folder #ressources
On my computer, It works very well, but when one of my friend wants to play (he hasn't python and pygame), the game creates this error:
[Error][1]
Then...I think this error comes from windows' ressources but I don't know how can I fix it...
The option (in setup.py):
include_msvcr = True
Doesn't work...
Thanks for your answer and excuse my english...
Hawk_Eyes
PS: this my game imports
try:
import pygame,time, ctypes
from random import randint
from pygame.locals import *
from math import sqrt
from _ressources import Shared
except ImportError as e:
print("Erreur du chargement du module: {0}".format(e))
Not sure if this will help but this is a copy of my setup file, i have used this to compile Pygame, Pubnub and various things. notice i don't include the files i want to include. The setup auto finds the files needed.
import sys
from cx_Freeze import setup, Executable
exe = Executable(
script = r"launcher.py",
base = 'Win32GUI',
icon = None,
targetName = "launcher.exe"
)
setup(
version = "0.1",
description = "launcher",
author = "Joshua Nixon",
name = "launcher",
executables = [exe]
)
$ cd path/to/files
$ python file.py build
EDIT
I recently found you could create .MSI files using cx_freeze which are very nice for distributing. IF the program uses images then (because you cannot bundle images with the MSI (that i know of) you create a little function which downloads them on launch from imgur or some place))
setup.py for MSI
import sys
from cx_Freeze import setup, Executable
company_name = "JoshuaNixon"
product_name = "Test"
bdist_msi_options = {
'add_to_path': False,
'initial_target_dir': r'[ProgramFilesFolder]\%s' % (company_name),
}
if sys.platform == 'win32':
base = 'Win32GUI'
else:
base = None
exe = Executable(script='launcher.py',
base=base,
icon="mushroom.ico",
)
setup(name=product_name,
version='1.0.0',
description='blah',
executables=[exe],
options={'bdist_msi': bdist_msi_options})
$ cd path/to/files
$ python file.py bdist_msi

python pycxx first testing case build error

trying to use pycxx.
using:
python 3.5 64-bit, windows 7 64-bit, pycxx 6.2.8
have written a simple cxx file to test out.
but the build had error, tried to search the solution but failed
aaa.cxx as:
#include "CXX/Objects.hxx"
Py::List haha(Py::List a)
{
a.append(Py::Long(100));
return a;
}
setup.py as:
import os, sys
from distutils.core import setup, Extension
support_dir = os.path.normpath(
os.path.join(
sys.prefix,
'share',
'python%d.%d' % (sys.version_info[0],sys.version_info[1]),
'CXX') )
if os.name == 'posix':
CXX_libraries = ['stdc++','m']
else:
CXX_libraries = []
setup (name = 'aaa',
ext_modules = [
Extension('CXX.aaa',
sources = ['aaa.cxx',
os.path.join(support_dir,'cxxsupport.cxx'),
os.path.join(support_dir,'cxx_extensions.cxx'),
os.path.join(support_dir,'IndirectPythonInterface.cxx'),
os.path.join(support_dir,'cxxextensions.c')
],
)
]
)
using "python setup.py install" to build, but with error:
build error
thank you very much for the help in advance.

Possible uiloader issue when converting pyside app using cx_freeze

I am trying to convert a pyside app to an executable (.exe) on Windows using cx_freeze. The packaging works with no problem, but when starting the generated .exe file, I get the following error:
ImportError: could not import module "PySide.QtXml"
When I try to convert the app shipped with cx_Freeze\Samples\PyQt4, it runs with no problems.
In this sample application there is just a simple QDialog called, but in my application I used QtDesigner for GUI design and I load it with PySide UiLoader directly in my py.file:
class MainWindow(QtGui.QMainWindow):
def __init__(self,parent=None):
QMainWindow.__init__(self)
loader = QUiLoader()
self.ui = loader.load('xxxx.ui',self)
QMetaObject.connectSlotsByName(self)
setup.py
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = [], excludes = [])
import sys
from cx_Freeze import setup, Executable
from PySide import QtXml
base = 'Win32GUI' if sys.platform=='win32' else None
options = {
'build_exe': {
'includes': 'atexit'
}
}
build_exe_options = {
'includes': ['atexit'],
}
executables = [
Executable('xxx.py', base=base)
]
setup(name='xxx',
version = '0.10',
description = 'First try',
options = dict(build_exe = buildOptions),
executables = executables)
In my opinion there's some problem using UiLoader when converting with cx_freeze but I have no clue how to overcome this issue.
This seems to be an old question. Still I am answering as it would help someone who is looking for a solution.
The solution is so simple that you just need to add "PySide.QtXml" to the includes list. After this your setup.py will look like this
build_exe_options = {
'includes': ['atexit'],
'packages': ['PySide.QtXml'],
}

py2exe packing data files

I have an app to pack that contains an image as data file and I tried to run this setup.py script:
from distutils.core import setup
import py2exe
import matplotlib
file_dati=[]
file_dati.append(matplotlib.get_py2exe_datafiles())
file_dati.append(('img1','C:\Users\MZompetta.000\Desktop\20130114_assortimenti\img1.gif'))
setup(console=[{"script": "Int_assortimenti.py"}],
options = {
"py2exe": {
"dll_excludes": ["libzmq.dll", "MSVCP90.dll"]
}
}, data_files=file_dati
)
but I obtain this error:
AttributeError: 'tuple' object has no attribute 'split'
the error is referred to the line: data_files=file_dati
I tried other ways to compose the data_files but no way.
Anyone can help me?
import os
import logging
from distutils.core import setup
import py2exe
import matplotlib
import shutil
distDir = "dist"
# Remove the build and dist folders
shutil.rmtree("build", ignore_errors=True)
shutil.rmtree("dist", ignore_errors=True)
try:
os.mkdir(os.path.abspath(distDir))
except:
logging.exception('')
data_files = matplotlib.get_py2exe_datafiles()
shutil.copyfile('C:\Users\MZompetta.000\Desktop\20130114_assortimenti\img1.gif', os.path.join(distDir, "img1.gif"))
setup(
options = {"py2exe": {
"dll_excludes": ["libzmq.dll", "MSVCP90.dll"],
"dist_dir": distDir,
}
}
data_files = data_files,
console=[{"script": "Int_assortimenti.py"}],
)

Categories

Resources