That is great work so far! I think we are getting somewhere. When
you say
> If there are a lot of them I could also add a
> new option "namespace_packages" which essentially calls
> pkgutil.extend_path for those packages. Let me know what you think.
Do you mean that namespace_packages would handle anything that is a
namespace package? If so, I think that is the only way to go. As I
said, repoze is a set of namepace packages, and I think there are
other ones that cx_freeze has trouble with. For instance, PasteDeploy
and PasteScript appear to be namespace packages, but they are not
named with a '.' in the package name (I'll paste the tree output for
each below). Also, for my application, there are two repoze packages
(repoze.bfg and repoze.lru). I think it would be very difficult if
you had to add a new hook for each new namespace that comes along.
Here are the trees for PasteScript and PasteDeploy:
(wind)cswank-11117s:PasteDeploy-1.3.3-py2.6.egg cswank$ tree
.
|-- EGG-INFO
| |-- PKG-INFO
| |-- SOURCES.txt
| |-- dependency_links.txt
| |-- entry_points.txt
| |-- namespace_packages.txt
| |-- not-zip-safe
| |-- requires.txt
| `-- top_level.txt
`-- paste
|-- __init__.py
|-- __init__.pyc
`-- deploy
|-- __init__.py
|-- __init__.pyc
|-- config.py
|-- config.pyc
|-- converters.py
|-- converters.pyc
|-- epdesc.py
|-- epdesc.pyc
|-- interfaces.py
|-- interfaces.pyc
|-- loadwsgi.py
|-- loadwsgi.pyc
|-- paster_templates
| `-- paste_deploy
| |-- +package+
| | |-- sampleapp.py_tmpl
| | `-- wsgiapp.py_tmpl
| `-- docs
| `-- devel_config.ini_tmpl
|-- paster_templates.py
|-- paster_templates.pyc
`-- util
|-- __init__.py
|-- __init__.pyc
|-- fixtypeerror.py
|-- fixtypeerror.pyc
|-- threadinglocal.py
`-- threadinglocal.pyc
8 directories, 33 files
(wind)cswank-11117s:PasteDeploy-1.3.3-py2.6.egg cswank$ cd ..
(wind)cswank-11117s:site-packages cswank$ cd PasteScript-1.7.3-
py2.6.egg/
(wind)cswank-11117s:PasteScript-1.7.3-py2.6.egg cswank$ tree
.
|-- EGG-INFO
| |-- PKG-INFO
| |-- SOURCES.txt
| |-- dependency_links.txt
| |-- entry_points.txt
| |-- namespace_packages.txt
| |-- not-zip-safe
| |-- requires.txt
| |-- scripts
| | `-- paster
| `-- top_level.txt
`-- paste
|-- __init__.py
|-- __init__.pyc
`-- script
|-- __init__.py
|-- __init__.pyc
|-- appinstall.py
|-- appinstall.pyc
|-- bool_optparse.py
|-- bool_optparse.pyc
|-- cgi_server.py
|-- cgi_server.pyc
|-- checkperms.py
|-- checkperms.pyc
|-- cherrypy_server.py
|-- cherrypy_server.pyc
|-- command.py
|-- command.pyc
|-- copydir.py
|-- copydir.pyc
|-- create_distro.py
|-- create_distro.pyc
|-- default_sysconfig.py
|-- default_sysconfig.pyc
|-- entrypoints.py
|-- entrypoints.pyc
|-- epdesc.py
|-- epdesc.pyc
|-- exe.py
|-- exe.pyc
|-- filemaker.py
|-- filemaker.pyc
|-- flup_server.py
|-- flup_server.pyc
|-- grep.py
|-- grep.pyc
|-- help.py
|-- help.pyc
|-- interfaces.py
|-- interfaces.pyc
|-- paster-templates
| `-- basic_package
| |-- +package+
| | |-- __init__.py
| | `-- __init__.pyc
| |-- setup.cfg
| `-- setup.py_tmpl
|-- pluginlib.py
|-- pluginlib.pyc
|-- request.py
|-- request.pyc
|-- serve.py
|-- serve.pyc
|-- templates.py
|-- templates.pyc
|-- testapp.py
|-- testapp.pyc
|-- twisted_web2_server.py
|-- twisted_web2_server.pyc
|-- util
| |-- __init__.py
| |-- __init__.pyc
| |-- logging_config.py
| |-- logging_config.pyc
| |-- secret.py
| |-- secret.pyc
| |-- string24.py
| |-- string24.pyc
| |-- subprocess24.py
| |-- subprocess24.pyc
| |-- uuid.py
| `-- uuid.pyc
|-- wsgiserver
| |-- __init__.py
| `-- __init__.pyc
|-- wsgiutils_server.py
`-- wsgiutils_server.pyc
9 directories, 79 files
On Feb 23, 2010, at 2:31 PM, Anthony Tuininga wrote:
> Thanks for the script. That demonstrates the problem quite clearly. I
> have checked in a modification to hooks.py which tells cx_Freeze about
> the dynamic manipulation of the path. Specifically, the zope package
> is distributed as multiple packages but needs to be stitched back
> together again at runtime into a single unified whole. So, when you
> import "zope" it finds the first occurrence on sys.path, loads it,
> which in turns looks for other occurrences of itself in sys.path and
> modifies the package path at runtime so that when you ask for the
> other related packages it finds them. I have done the same thing in
> the hook. Interestingly enough, zope.component acts rather strangely
> in that it uses __import__() rather than a plain import to do its work
> -- I'm not sure of the reason for that but I had to add a hook for
> that as well.
>
> You can follow the same procedure for the other ones that follow the
> same technique. If you provide me a list of them and a sample script
> that uses each of them so that I can test I'd be happy to include them
> in the stock hooks.py. If there are a lot of them I could also add a
> new option "namespace_packages" which essentially calls
> pkgutil.extend_path for those packages. Let me know what you think.
> Thanks.
>
> Anthony
>
> On Tue, Feb 23, 2010 at 1:03 PM, Craig Swank <[email protected]>
> wrote:
>>> No problem. Do you have a sample script that I can use? I have never
>>> used Zope before so have no idea how to write a minimal script that
>>> demonstrates the problem. Thanks!
>>
>> The most minimal script do demonstrate the problem would be to just
>> import both packages, but here is an example slightly more
>> interesting
>> (barely):
>>
>> #setup.py
>> from zope.interface import Interface, implements
>> import zope.component
>>
>> class MyInterface(Interface):
>> def say_hi(arg1):
>> """documentation for say_hi"""
>>
>> class X:
>> implements(MyInterface)
>>
>> def say_hi(self, person):
>> print 'hi, ', person
>>
>> x = X()
>> x.say_hi('Anthony')
>>
>>
>>
>> and a setup script for it:
>>
>>
>> from cx_Freeze import setup, Executable
>>
>> version = '1.0'
>> includes=['zope.interface', 'zope.component']
>> setup(name='hi',
>> version=version,
>> options = {
>> "build_exe" : {
>> "includes": includes,
>> },
>> },
>> executables=[Executable('example.py')],
>> )
>>
>> I don't use zope.component (dont' know how).
>>
>> Thanks,
>>
>> Craig
>>
>>
>>
>> On Feb 23, 2010, at 12:40 PM, Anthony Tuininga wrote:
>>
>>> On Tue, Feb 23, 2010 at 11:31 AM, Craig Swank <[email protected]>
>>> wrote:
>>>> Try installing
>>>> zope.component and zope.interface (zope.interface-3.3.0.tar.gz (101
>>>> K)). In
>>>> regards to your comment:
>>>
>>> Did that.
>>>
>>>> I believe this is a requirement for Python -- in other
>>>> words you can't have a module name with a "." in it without the
>>>> stuff
>>>> in front of the dot being a package.
>>>>
>>>> I think these two packages (zope.component and zope.interface)
>>>> demonstrate
>>>> this case. In my site-packages I have both of these installed
>>>> (along with 5
>>>> other 'zope' namespace packages), but there is not a package called
>>>> 'zope'
>>>> installed. The main app that I'm trying to build is a web-app
>>>> build on
>>>> repoze.bfg, and once again, there is no package called repoze.
>>>> Repoze is a
>>>> collection of packages. Forgive me if I'm telling you stuff you
>>>> already
>>>> know.
>>>
>>> No problem. Do you have a sample script that I can use? I have never
>>> used Zope before so have no idea how to write a minimal script that
>>> demonstrates the problem. Thanks!
>>>
>>> Anthony
>>>
>>> ------------------------------------------------------------------------------
>>> Download Intel® Parallel Studio Eval
>>> Try the new software tools for yourself. Speed compiling, find bugs
>>> proactively, and fine-tune applications for parallel performance.
>>> See why Intel Parallel Studio got high marks during beta.
>>> http://p.sf.net/sfu/intel-sw-dev
>>> _______________________________________________
>>> cx-freeze-users mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/cx-freeze-users
>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> cx-freeze-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/cx-freeze-users
>>
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> cx-freeze-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/cx-freeze-users
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
cx-freeze-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cx-freeze-users