From: Alexander B. <bi...@uk...> - 2004-08-25 12:31:50
|
Hi! I know py2exe can add VERSION_INFO to output exe file. But by default in exe file don't add info about copyright, company_name, trademarks and comments. In py2exe documentation and wiki I did not found information about how add this strings to VERSION_INFO. I analysed py2exe and distutils and found this things: 1. Module py2exe/resources/VersionInfo.py has definition of class Version. Constructor of that class has params with names as "comments", "legal_copyright", "company_name", "trademarks" . I.e. this information must be generated. 2. When instance of Version class is created, constructor of Version invoked with params that gets from instance of distutils.dist.DistributionMetadata class. 3. Look at definition of distutils.dist.DistributionMetadata class and see this class has not attributes like "comments", "copyright", "company_name", "trademarks". Based on this facts I add some code to py2exe for the purpose of support "extra" string in VERSION_INFO. My code add attributes "comments", "copyright", "company_name", "trademarks" to instance of distutils.dist.DistributionMetadata class. I add following code in py2exe/__init__.py: 1. Before invoke constructor of distutils.dist.Distribution I pop from 'attrs' item with name 'version_info' 2. After return from constructor of distutils.dist.Distribution I add corresponding attributes to instance of DistributionMetadata class. This instance is metadata attribute of Distribution class. Value of this attributes gets from 'version_info' dictionary. 'version_info' must be dictionary with keys "comments", "copyright", "company_name", "trademarks". In setup.py file invoking of setup function may be in this form: setup (console=['myprogram.py'], name='My Program', version='X.Y.Z', description='This is my program', author='Your name', version_info={'comments': 'Comments to my program', 'copyright': '(C) Company, 2004', 'company_name': 'Your Company name', 'trademarks': '$$$'}, ) And finally look at my variant of py2exe/__init__.py. I highlight my code with pair of line # [bialix] and # [/bialix] *** py2exe/__init__.py [skip header of module and doc string] __version__ = "0.5.3" import distutils.dist, distutils.core, distutils.command, build_exe, sys class Distribution(distutils.dist.Distribution): def __init__(self, attrs): self.com_server = attrs.pop("com_server", []) self.service = attrs.pop("com_server", []) self.windows = attrs.pop("com_server", []) self.console = attrs.pop("com_server", []) self.zipfile = attrs.pop("zipfile", "library.zip") # [bialix] version_info = attrs.pop("version_info", None) # [/bialix] distutils.dist.Distribution.__init__(self, attrs) # [bialix] if version_info: accepted_info = ("comments", "copyright", "company_name", "trademarks") for item in accepted_info: setattr(self.metadata, item, version_info.get(item, None)) # [/bialix] distutils.core.Distribution = Distribution distutils.command.__all__.append('py2exe') sys.modules['distutils.command.py2exe'] = build_exe *** end of py2exe/__init__.py This variant is working and VERSION_INFO in produced exe contain all necessary data. If my approach is wrong I would to know why. Alexander. -- Удачи, Александр e-mail: bi...@uk... http://OnEmbedding.com -- сайт "Про встраиваемые системы" |
From: Brian D. <bri...@gm...> - 2004-08-25 16:19:45
|
Hi Alexander,=20 I don't claim to be an expert of any sort, but this is what I'm doing (without any changes to py2exe). I'm sure I learned from someone else, but I don't remember who or where. I'm using py2exe 5.3. In my setup.py, I'm creating a class with default properties: class Target: def __init__(self, **kw): # for the versioninfo resources self.name =3D "Replication Monitor" self.description =3D "Part of the Replication Monitor package." self.company_name =3D "Some Company." self.copyright =3D "Copyright 2004, Some Company Inc." self.version =3D sharedutil.__version_string__ #self.comments =3D "These are some comments." * 100 self.__dict__.update(kw) Then in the call to setup(), I'm wrapping the aplication names in my new cl= ass: console =3D [Target(script =3D "BulkBitsAdmin.py")] When I check the file properties after a buid, everything is included.=20 The way I wrote the class, you can also change things for indivitual executables (I create 5 or 6 exes in my setup.py). Target(modules=3D['RMCompleter'], description=3D"Monitors the BITS queue and completes jobs."= ) Hope this helps.=20 Take care, -Brian On Wed, 25 Aug 2004 15:34:23 +0400, Alexander Belchenko <bi...@uk...> wr= ote: > Hi! >=20 > I know py2exe can add VERSION_INFO to output exe file. > But by default in exe file don't add info about copyright, company_name, > trademarks and comments. In py2exe documentation and wiki I did not > found information about how add this strings to VERSION_INFO. >=20 > I analysed py2exe and distutils and found this things: >=20 > 1. Module py2exe/resources/VersionInfo.py has definition of class > Version. Constructor of that class has params with names as "comments", > "legal_copyright", "company_name", "trademarks" . I.e. this information > must be generated. > 2. When instance of Version class is created, constructor of Version > invoked with params that gets from instance of > distutils.dist.DistributionMetadata class. > 3. Look at definition of distutils.dist.DistributionMetadata class and > see this class has not attributes like "comments", "copyright", > "company_name", "trademarks". >=20 > Based on this facts I add some code to py2exe for the purpose of support > "extra" string in VERSION_INFO. My code add attributes "comments", > "copyright", "company_name", "trademarks" to instance of > distutils.dist.DistributionMetadata class. >=20 > I add following code in py2exe/__init__.py: >=20 > 1. Before invoke constructor of distutils.dist.Distribution I pop from > 'attrs' item with name 'version_info' > 2. After return from constructor of distutils.dist.Distribution I add > corresponding attributes to instance of DistributionMetadata class. This > instance is metadata attribute of Distribution class. Value of this > attributes gets from 'version_info' dictionary. >=20 > 'version_info' must be dictionary with keys "comments", "copyright", > "company_name", "trademarks". >=20 > In setup.py file invoking of setup function may be in this form: >=20 > setup (console=3D['myprogram.py'], > name=3D'My Program', > version=3D'X.Y.Z', > description=3D'This is my program', > author=3D'Your name', > version_info=3D{'comments': 'Comments to my program', > 'copyright': '(C) Company, 2004', > 'company_name': 'Your Company name', > 'trademarks': '$$$'}, > ) >=20 > And finally look at my variant of py2exe/__init__.py. I highlight my > code with pair of line > # [bialix] > and > # [/bialix] >=20 > *** py2exe/__init__.py >=20 > [skip header of module and doc string] >=20 > __version__ =3D "0.5.3" >=20 > import distutils.dist, distutils.core, distutils.command, build_exe, sys >=20 > class Distribution(distutils.dist.Distribution): >=20 > def __init__(self, attrs): > self.com_server =3D attrs.pop("com_server", []) > self.service =3D attrs.pop("com_server", []) > self.windows =3D attrs.pop("com_server", []) > self.console =3D attrs.pop("com_server", []) > self.zipfile =3D attrs.pop("zipfile", "library.zip") >=20 > # [bialix] > version_info =3D attrs.pop("version_info", None) > # [/bialix] >=20 > distutils.dist.Distribution.__init__(self, attrs) >=20 > # [bialix] > if version_info: > accepted_info =3D ("comments", "copyright", > "company_name", "trademarks") > for item in accepted_info: > setattr(self.metadata, > item, > version_info.get(item, None)) > # [/bialix] >=20 > distutils.core.Distribution =3D Distribution >=20 > distutils.command.__all__.append('py2exe') >=20 > sys.modules['distutils.command.py2exe'] =3D build_exe >=20 > *** end of py2exe/__init__.py >=20 > This variant is working and VERSION_INFO in produced exe contain all > necessary data. > If my approach is wrong I would to know why. >=20 > Alexander. >=20 > -- > =D0=A3=D0=B4=D0=B0=D1=87=D0=B8, > =D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80 = e-mail: bi...@uk... > http://OnEmbedding.com -- =D1=81=D0=B0=D0=B9=D1=82 "=D0=9F=D1=80=D0=BE = =D0=B2=D1=81=D1=82=D1=80=D0=B0=D0=B8=D0=B2=D0=B0=D0=B5=D0=BC=D1=8B=D0=B5 = =D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D1=8B" >=20 > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Py2exe-users mailing list > Py2...@li... > https://lists.sourceforge.net/lists/listinfo/py2exe-users > |
From: Alexander B. <bi...@uk...> - 2004-08-26 08:39:46
|
Hi! Thank you Brian for hint. Yes. My approach is wrong because py2exe contain code for add all needed versioninfo string. At first I closely look at py2exe/build_exe.py and see declaration of class Target. This class very similar to your own, but there is some difference. I think usage of py2exe.build_exe.Target class is more correct, that construct your own class. But my second thought bring me to another way. In documentation on py2exe I read: "Items in the console, windows, service or com_server list can also be dictionaries to further customize the build process." This sentence hide very important fact: all necessary data can pass to py2exe through this dictionary. I.e. usage of class Target is optional. I can write my setup.py in this form: *** console_dict = {"script": "pylcdstr.py", "icon_resources": [(0,'bialix.ico')], "name": "pyLCDstring", "version": "2.4", "description": "pyLCDstring: prepare strings for output to LCD", "author": "Alexander Belchenko", "copyright": "(c) Bialix Microlab, 2004", "comments": "My comments", "company_name": "Bialix Microlab"} setup(console=[console_dict]) *** This is working fine. Thanks Brian again. I found right way. Alexander > Hi Alexander, > > I don't claim to be an expert of any sort, but this is what I'm doing > (without any changes to py2exe). I'm sure I learned from someone else, > but I don't remember who or where. I'm using py2exe 5.3. > > In my setup.py, I'm creating a class with default properties: > > class Target: > def __init__(self, **kw): > # for the versioninfo resources > self.name = "Replication Monitor" > self.description = "Part of the Replication Monitor package." > self.company_name = "Some Company." > self.copyright = "Copyright 2004, Some Company Inc." > self.version = sharedutil.__version_string__ > #self.comments = "These are some comments." * 100 > self.__dict__.update(kw) > > > Then in the call to setup(), I'm wrapping the aplication names in my new class: > > console = [Target(script = "BulkBitsAdmin.py")] > > When I check the file properties after a buid, everything is included. > > > The way I wrote the class, you can also change things for indivitual > executables (I create 5 or 6 exes in my setup.py). > > Target(modules=['RMCompleter'], > description="Monitors the BITS queue and completes jobs.") > > > Hope this helps. > > Take care, > -Brian |
From: Thomas H. <th...@py...> - 2004-08-26 12:18:30
|
Brian Dorsey <bri...@gm...> writes: > Hi Alexander, > > I don't claim to be an expert of any sort, but this is what I'm doing > (without any changes to py2exe). I'm sure I learned from someone else, > but I don't remember who or where. I'm using py2exe 5.3. Again I can refer to the samples provided with py2exe - py2exe\samples\advanced\setup.py. Thomas |