<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Extend py2exe to copy files to the zipfile where pkg_resources can load them</title>
	<atom:link href="http://crazedmonkey.com/blog/python/pkg_resources-with-py2exe.html/feed" rel="self" type="application/rss+xml" />
	<link>http://crazedmonkey.com/blog/python/pkg_resources-with-py2exe.html</link>
	<description>Ian Stevens&#039; weblog</description>
	<lastBuildDate>Wed, 20 Jan 2010 00:40:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dragos Anghel</title>
		<link>http://crazedmonkey.com/blog/python/pkg_resources-with-py2exe.html/comment-page-1#comment-75693</link>
		<dc:creator>Dragos Anghel</dc:creator>
		<pubDate>Fri, 03 Apr 2009 18:53:06 +0000</pubDate>
		<guid isPermaLink="false">http://crazedmonkey.com/blog/?p=380#comment-75693</guid>
		<description>First of all, thanks for your article... I try to use it, but I&#039;ve got some errors with &quot;super(MediaCollector, self).copy_extensions(extensions)&quot; line:

  File &quot;ServiceDirs\mysetup.py&quot;, line 76, in copy_extensions
    super(MediaCollector, self).copy_extensions(extensions)
  TypeError: super() argument 1 must be type, not classobj

Also, I try how Igor says, but doesn&#039;t help...
All I want is to add to zipfile the files from my app &quot;Gfx&quot; subdirectory, from where pkg_resources could load them

My &quot;setup.py&quot; looks like:

##############
from distutils.core import setup
import py2exe
import sys, os
import glob

############################################################################
MainScriptName  = &#039;test.py&#039;
description     = &quot;my test app&quot;
version         = &quot;0.0.1&quot;
company_name    = &quot;No Company&quot;
copyright       = &quot;roDAX&quot;
name            = &quot;test&quot;
author          = &#039;Dragos (dax) ANGHEL&#039;
iconFile        = &quot;Gfx\\AppIco.ico&quot;
############################################################################
# ... this creates the MainScriptName of your .exe file in the dist folder
if MainScriptName.endswith(&quot;.py&quot;):
    distribution = MainScriptName[:-3]
elif MainScriptName.endswith(&quot;.pyw&quot;):
    distribution = MainScriptName[:-4]


# if run without args, build executables in quiet mode
if len(sys.argv) == 1:
    sys.argv.append(&quot;py2exe&quot;)
    sys.argv.append(&quot;-q&quot;)

class MyAppClass:
    def __init__(self, **kw):
        self.__dict__.update(kw)
        # for the versioninfo resources, edit to your needs
        self.version = version
        self.company_name = company_name
        self.copyright = copyright
        self.name = name
        self.author =author

myApp = MyAppClass(
    description     = description,     # the versioninfo resource
    script          = MainScriptName,  # will be the exe MainScriptName
    icon_resources  = [(1, iconFile)], # give it an iconfile; otherwise a default icon is used
    )

# follow Ian Stevens&#039; part
#-------------------------------------------------------------------------------
&#039;&#039;&#039;
The best entry point I could find was copy_extensions().
You can override that method to copy files into the build directory.
You&#039;ll want to create the necessary directories if they don&#039;t already exist and then
register the copied files for copying to dist.
Here&#039;s an example with images in a foo module&#039;s media directory:
&#039;&#039;&#039;

#import os
#import glob
from py2exe.build_exe import py2exe as build_exe

class MediaCollector(build_exe):
    def copy_extensions(self, extensions):
        super(MediaCollector, self).copy_extensions(extensions)  # &lt;&lt;&lt;&lt;pyc) 1 or 2=optimized (py--&gt;pyo; 1= -O python param; 2=-OO python param)
                            &quot;ascii&quot;: 1,         # to make a smaller executable, don&#039;t include the encodings
                            &quot;bundle_files&quot;: 1,  # 1=All inside; 2=PythonXX.dll outside; 3=All outside
                           },
               },
    zipfile = distribution +&#039;.bin&#039;,             # None=all components in exe_file; libname_string=all in &#039;libname&quot; file
    windows =   [myApp],
    **py2exe_options
    )
###########

If I comment the involved line from within the &quot;MediaCollector&quot; class, I obtain the &quot;Gfx&quot; in zipfile with all his content, but from builded &quot;zipfile\\wx&quot; directory is missing all PYDs files...


Could anyone have some suggestions about the error thrown by the interpreter??

Thanks in advance...
Dragos

p.s.: sorry for this huge question/reply</description>
		<content:encoded><![CDATA[<p>First of all, thanks for your article&#8230; I try to use it, but I&#8217;ve got some errors with &#8220;super(MediaCollector, self).copy_extensions(extensions)&#8221; line:</p>
<p>  File &#8220;ServiceDirs\mysetup.py&#8221;, line 76, in copy_extensions<br />
    super(MediaCollector, self).copy_extensions(extensions)<br />
  TypeError: super() argument 1 must be type, not classobj</p>
<p>Also, I try how Igor says, but doesn&#8217;t help&#8230;<br />
All I want is to add to zipfile the files from my app &#8220;Gfx&#8221; subdirectory, from where pkg_resources could load them</p>
<p>My &#8220;setup.py&#8221; looks like:</p>
<p>##############<br />
from distutils.core import setup<br />
import py2exe<br />
import sys, os<br />
import glob</p>
<p>############################################################################<br />
MainScriptName  = &#8216;test.py&#8217;<br />
description     = &#8220;my test app&#8221;<br />
version         = &#8220;0.0.1&#8243;<br />
company_name    = &#8220;No Company&#8221;<br />
copyright       = &#8220;roDAX&#8221;<br />
name            = &#8220;test&#8221;<br />
author          = &#8216;Dragos (dax) ANGHEL&#8217;<br />
iconFile        = &#8220;Gfx\\AppIco.ico&#8221;<br />
############################################################################<br />
# &#8230; this creates the MainScriptName of your .exe file in the dist folder<br />
if MainScriptName.endswith(&#8220;.py&#8221;):<br />
    distribution = MainScriptName[:-3]<br />
elif MainScriptName.endswith(&#8220;.pyw&#8221;):<br />
    distribution = MainScriptName[:-4]</p>
<p># if run without args, build executables in quiet mode<br />
if len(sys.argv) == 1:<br />
    sys.argv.append(&#8220;py2exe&#8221;)<br />
    sys.argv.append(&#8220;-q&#8221;)</p>
<p>class MyAppClass:<br />
    def __init__(self, **kw):<br />
        self.__dict__.update(kw)<br />
        # for the versioninfo resources, edit to your needs<br />
        self.version = version<br />
        self.company_name = company_name<br />
        self.copyright = copyright<br />
        self.name = name<br />
        self.author =author</p>
<p>myApp = MyAppClass(<br />
    description     = description,     # the versioninfo resource<br />
    script          = MainScriptName,  # will be the exe MainScriptName<br />
    icon_resources  = [(1, iconFile)], # give it an iconfile; otherwise a default icon is used<br />
    )</p>
<p># follow Ian Stevens&#8217; part<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
&#8221;&#8217;<br />
The best entry point I could find was copy_extensions().<br />
You can override that method to copy files into the build directory.<br />
You&#8217;ll want to create the necessary directories if they don&#8217;t already exist and then<br />
register the copied files for copying to dist.<br />
Here&#8217;s an example with images in a foo module&#8217;s media directory:<br />
&#8221;&#8217;</p>
<p>#import os<br />
#import glob<br />
from py2exe.build_exe import py2exe as build_exe</p>
<p>class MediaCollector(build_exe):<br />
    def copy_extensions(self, extensions):<br />
        super(MediaCollector, self).copy_extensions(extensions)  # &lt;&lt;&lt;&lt;pyc) 1 or 2=optimized (py&#8211;&gt;pyo; 1= -O python param; 2=-OO python param)<br />
                            &#8220;ascii&#8221;: 1,         # to make a smaller executable, don&#8217;t include the encodings<br />
                            &#8220;bundle_files&#8221;: 1,  # 1=All inside; 2=PythonXX.dll outside; 3=All outside<br />
                           },<br />
               },<br />
    zipfile = distribution +&#8217;.bin&#8217;,             # None=all components in exe_file; libname_string=all in &#8216;libname&#8221; file<br />
    windows =   [myApp],<br />
    **py2exe_options<br />
    )<br />
###########</p>
<p>If I comment the involved line from within the &#8220;MediaCollector&#8221; class, I obtain the &#8220;Gfx&#8221; in zipfile with all his content, but from builded &#8220;zipfile\\wx&#8221; directory is missing all PYDs files&#8230;</p>
<p>Could anyone have some suggestions about the error thrown by the interpreter??</p>
<p>Thanks in advance&#8230;<br />
Dragos</p>
<p>p.s.: sorry for this huge question/reply</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor Tkach</title>
		<link>http://crazedmonkey.com/blog/python/pkg_resources-with-py2exe.html/comment-page-1#comment-67521</link>
		<dc:creator>Igor Tkach</dc:creator>
		<pubDate>Mon, 08 Dec 2008 04:04:42 +0000</pubDate>
		<guid isPermaLink="false">http://crazedmonkey.com/blog/?p=380#comment-67521</guid>
		<description>Answering myself: just use proper syntax for classic classes:
build_exe.copy_extensions(self, extensions)
Other than this works great, thank you!</description>
		<content:encoded><![CDATA[<p>Answering myself: just use proper syntax for classic classes:<br />
build_exe.copy_extensions(self, extensions)<br />
Other than this works great, thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor Tkach</title>
		<link>http://crazedmonkey.com/blog/python/pkg_resources-with-py2exe.html/comment-page-1#comment-67518</link>
		<dc:creator>Igor Tkach</dc:creator>
		<pubDate>Mon, 08 Dec 2008 03:42:24 +0000</pubDate>
		<guid isPermaLink="false">http://crazedmonkey.com/blog/?p=380#comment-67518</guid>
		<description>Thanks for the tip, exactly what I was looking for. I&#039;m having trouble getting it to work though - looks like build_exe is classic class, so call to super fails. I tried this with py2exe 0.6.8 and 0.6.9, Python 2.5.2. How did you get around this?</description>
		<content:encoded><![CDATA[<p>Thanks for the tip, exactly what I was looking for. I&#8217;m having trouble getting it to work though &#8211; looks like build_exe is classic class, so call to super fails. I tried this with py2exe 0.6.8 and 0.6.9, Python 2.5.2. How did you get around this?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
