Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get py2exe to build in copyright information

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.

like image 1000
user2643864 Avatar asked Mar 13 '14 20:03

user2643864


3 Answers

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]
)
like image 135
user2643864 Avatar answered Oct 19 '22 23:10

user2643864


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',
)
like image 24
Craig McQueen Avatar answered Oct 20 '22 01:10

Craig McQueen


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.

like image 34
jgritty Avatar answered Oct 20 '22 00:10

jgritty