Reputation: 651
I am using Py2exe to create a Windows .exe from my Python script. I would like to have the copyright information as well as the product version, description, etc. I've been able to get everything to show (in the Properties > Details of the exe), except for the copyright information. I've tried the following with no success:
from distutils.core import setup
import py2exe
import sys
if len(sys.argv) == 1:
sys.argv.append("py2exe")
sys.argv.append("-q")
class Target:
def __init__(self, **kw):
self.__dict__.update(kw)
# for the versioninfo resources
self.version = "1.0.0.0"
self.company_name = "ACME."
self.copyright = "Copyright (c) 2014 ACME."
self.name = "My Program"
# create an instance of class Target
# and give it additional needed info
target = Target(
description = "Test Description",
# this is your code file
script = "Main.py",
# this will form TestProgram.exe
dest_base = "TestProgram")
setup(
options = {'py2exe': {'bundle_files': 1,
'compressed': 1}},
console = [{'script': "Main.py"}],
zipfile = None,
)
When using this method I get the File Description, Product Name, and Product version in the PROPERTIES > DETAILS of the .exe but I am missing the copyright.
Upvotes: 7
Views: 4252
Reputation: 117
Thanks mbokil. It's properly working for me.
INFO: py2exe is going to stop support on the setup API and recommending users to start using py2exe.freeze API to build standalone .exe file of your code.
Upvotes: 0
Reputation: 3340
Updated for 2023. There is a new freeze API that is the new way to compile your code. I found it was the only reliable way I could get the copyright and product version to appear using Python 3.11+.
from py2exe import freeze
freeze(
console = [myservice],
zipfile = None,
options = {'bundle_files': 3,'compressed': 1},
version_info={
'version':'1.0.0',
'product_version':'03012023',
'product_name':'My Service',
'copyright':'Copyright 2023 My Company',
}
)
Upvotes: 0
Reputation: 43456
user2643864's answer is more complicated than it needs to be. jgritty's answer is nearly there, and only needs simple modification, adding a couple of entries in the dictionary assigned to console
:
from distutils.core import setup
import py2exe
setup(
options = {'py2exe': {'bundle_files': 1,
'compressed': 1}},
console = [{
'script': 'Main.py',
'copyright': 'Copyright (C) 2016 ACME Pty Ltd',
'company_name': 'ACME Pty Ltd',
}],
zipfile = None,
version = '1.0.0.0',
name = 'My Program',
description = 'Test Description',
)
Upvotes: 3
Reputation: 651
I got the following to work. I realized I didn't set the target right. Fixed at the bottom where I did console = [target]
.
from distutils.core import setup
import py2exe
import sys
if len(sys.argv) == 1:
sys.argv.append("py2exe")
sys.argv.append("-q")
class Target:
def __init__(self, **kw):
self.__dict__.update(kw)
self.version = "1.0.0.0"
self.company_name = "ACME."
self.copyright = "Copyright (c) 2014 ACME."
self.name = "My Program"
target = Target(
description = "Test Description",
script = "Main.py",
dest_base = "TestProgram")
setup(
options = {'py2exe': {'bundle_files': 1,
'compressed': True}},
zipfile = None,
console = [target]
)
Upvotes: 6
Reputation: 11935
I think there's something really wrong with your code, because it doesn't update the File Description, Product Name, and Product version in the exe. However, this code does:
from distutils.core import setup
import py2exe
setup(
options = {'py2exe': {'bundle_files': 1,
'compressed': 1}},
console = [{'script': "Main.py"}],
zipfile = None,
version = "1.0.0.0",
name = "My Program",
description = "Test Description",
)
To put the company name and copyright info into the executable is more challenging, and unfortunately, I don't know how to do that yet. This might be useful.
Upvotes: 1