Compiling From Source

Hoping someone can help me out, or give me an indication of whether or not what I’m trying to do is even reasonable. Some background:

I’m trying to resurrect the py2exe project. I have found it to produce significantly smaller binary distributions, especially when working with single-file or bundled distributions. Additionally, it’s ability to load libraries directly into and from memory, rather than using a temporary directory and two-pass execution makes it’s distributed versions significantly faster for repeated execution, and reduces disk over head tremendously.

Unfortunately, it does (did) not support bundling of files on 64-bit installations. I think I’ve resolved that (in fact, I know I’ve resolved that if I use VS 2008), but if I’m already rebuilding large volumes of the project from source I’d like to try to reduce the number of VC++ Redist installers I need to provide to my customers. Our products are currently built with VS 2010, so I’d like to get all of the projects I depend on building with the same compiler (a lofty goal).

So far, I’ve built my own copy of 64-bit cPython from sources, so my next step is to try to build wxPython and wxWidgets. As near I can tell, I’ve accomplished that as well - running build-wxpython.py completes as expected:

sys.argv = [’–install’, ‘–unicode’, ‘–extra_make=TARGET_CPU=AMD64’]

wxWidgets directory is: C:\dev\wx\wxWidgets
wxWidgets build options: [’–wxpython’, ‘–jobs=2’, ‘–unicode’, ‘–extra_make=“TARGET_CPU=AMD64”’]
creating wx/msw/setup.h from setup0.h

setting build options…
nmake.exe -f makefile.vc UNICODE=1 OFFICIAL_BUILD=1 COMPILER_VERSION=100 SHARED=1 MONOLITHIC=0 USE_OPENGL=1 USE_GDIPLUS=1 BUILD=release “TARGET_CPU=AMD64”

… … <lots of compiler messages. Warnings, but no Errors> … …
Removing c:\dev\cpython\Lib\site-packages\wx-2.9.5-msw\wxPython-2.9.5.0-py2.7.egg-info
Writing c:\dev\cpython\Lib\site-packages\wx-2.9.5-msw\wxPython-2.9.5.0-py2.7.egg-info

warning: wx_install: path file ‘c:\dev\cpython\Lib\site-packages\wx-2.9.5-msw.pth’ not created

package init file ‘wx\lib\pubsub\pubsub2_init_.py’ not found (or not a regular file)
package init file ‘wx\tools\XRCed\plugins_init_.py’ not found (or not a regular file)

writing list of installed files to ‘installed_files.txt’
**** c:\dev\cpython\pcbuild\amd64\python.exe -u C:\dev\wx\wxPython\distrib\makemo.py
------------ BUILD FINISHED ------------

There were a number of adjustments I had to make along the way. This change was necessary: http://wiki.wxwidgets.org/Compiling_using_MS_VC%2B%2B. I’m not certain if it’s a side-effect of using my own compiled version of Python, or if it’s related to something else on the sandbox I’m using, but I also had to manually set the os.environ[‘CPU’] value to get one of the scripts to find the correct library directory, had to manually define #_UNICODE in one of the wxWidgets projects, added a couple lines in getVisCVersion to recognize VS 2010, etc. Everything feels pretty minor (I’ll definitely submit what I think are relevant changes if I get it going fully). It’s been a slow process, but I seem to be making headway. Unfortunately though, based on what I can see, at this point I should have wx available in my python. These same steps worked when I was in the sandbox where I’m using VS2008. On my VS 2010 machine I get this when I attempt to import wx:

Traceback (most recent call last):
File “”, line 1, in

File “wx_init_.py”, line 45, in
from wx._core import *
File “wx_core.py”, line 4, in
import core
ImportError: No module named core

If I check my site-packages directory it certainly looks like core.pyd is in place:

C:\dev\cpython\Lib\site-packages\wx-2.9.5-msw>dir wx_c*
Volume in drive C has no label.
Volume Serial Number is 4457-89FA

Directory of C:\dev\cpython\Lib\site-packages\wx-2.9.5-msw\wx

03/20/2013 09:27 AM 139,264 _calendar.pyd

03/20/2013 09:27 AM 226,304 _combo.pyd
03/19/2013 02:28 PM 342,163 _controls.py
03/20/2013 09:52 AM 449,642 _controls.pyc
03/20/2013 09:27 AM 1,294,336 controls.pyd

03/19/2013 02:28 PM 652,451 _core.py
03/20/2013 09:52 AM 849,993 _core.pyc
03/20/2013 09:26 AM 1,462,272 core.pyd
8 File(s) 5,416,425 bytes
0 Dir(s) 65,815,478,272 bytes free

So, now I’m kind of at a loss. Not wanting to give up, I went as far as downloading the currently available binary installer for wxPython 2.8 for Python 2.7 64-bit. I had to get my custom version of python registered in Windows (this site made that easy: http://effbot.org/zone/python-register.htm), then was able to successfully install wxPython 2.8 Unicode. After doing so, attempts to import wx produce the same error.

So, that’s a ton to start off with, sorry for writing a novel. I figure it’s better to provide lots of background so you know where I’m at instead of having to go back and forth a dozen times. Thanks for reading, and thanks in advance for any advice or suggestions.

–Dan

Daniel Casper wrote:

Unfortunately
though, based on what I can see, at this point I should have wx
available in my python. These same steps worked when I was in the
sandbox where I'm using VS2008. On my VS 2010 machine I get this when I
attempt to import wx:

    Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "wx\__init__.py", line 45, in <module>
         from wx._core import *
       File "wx\_core.py", line 4, in <module>
         import _core_
    ImportError: No module named _core_

  If I check my site-packages directory it certainly looks like
_core_.pyd is in place:

From the traceback it looks like it is trying to load from a wx package in the current working directory, not from site-packages. Try doing it from some other CWD besides the wxPython source folder and see if it works there.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org

Robin,

Thanks for getting back to me. The issue seems to persist no matter what my current working directory is:

Python 2.7.3+ (default, Mar 20 2013, 00:47:45) [MSC v.1600 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.

import os
os.getcwd()
‘C:\Documents and Settings\Administrator’

import wx
Traceback (most recent call last):
File “”, line 1, in
File “c:\dev\cpython\lib\site-packages\wx-2.9.5-msw\wx_init_.py”, line 45, in
from wx._core import *
File “c:\dev\cpython\lib\site-packages\wx-2.9.5-msw\wx_core.py”, line 4, in
import core
ImportError: DLL load failed: The specified module could not be found.

Let me know what you think, or if there are other things worth trying. I can also scrap the VM state and try to work through my steps again so they’re a bit better documented if you think it’d help. Thanks,

–Dan

···

On Wednesday, March 20, 2013 6:25:03 PM UTC-6, Robin Dunn wrote:

Daniel Casper wrote:

Unfortunately

though, based on what I can see, at this point I should have wx

available in my python. These same steps worked when I was in the

sandbox where I’m using VS2008. On my VS 2010 machine I get this when I

attempt to import wx:

Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "wx\__init__.py", line 45, in <module>
     from wx._core import *
   File "wx\_core.py", line 4, in <module>
     import _core_
ImportError: No module named _core_

If I check my site-packages directory it certainly looks like

core.pyd is in place:

From the traceback it looks like it is trying to load from a wx package
in the current working directory, not from site-packages. Try doing it
from some other CWD besides the wxPython source folder and see if it
works there.


Robin Dunn

Software Craftsman

http://wxPython.org

g.d.d.c wrote:

Robin,

Thanks for getting back to me. The issue seems to persist no matter what
my current working directory is:

    Python 2.7.3+ (default, Mar 20 2013, 00:47:45) [MSC v.1600 64 bit
    (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
     >>> import os
     >>> os.getcwd()
    'C:\\Documents and Settings\\Administrator'
     >>> import wx
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "c:\dev\cpython\lib\site-packages\wx-2.9.5-msw\wx\__init__.py",
    line 45, in <module>
    from wx._core import *
    File "c:\dev\cpython\lib\site-packages\wx-2.9.5-msw\wx\_core.py",
    line 4, in <module>
    import _core_
    ImportError: DLL load failed: The specified module could not be found.
     >>>

Let me know what you think, or if there are other things worth trying. I
can also scrap the VM state and try to work through my steps again so
they're a bit better documented if you think it'd help. Thanks,

For that error you can load the _core_.pyd file into a tool called Dependency Walker and it will show what DLLs it is unable to find.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org

Sure thing. It appears to be missing these four:

WXBASE295U_NET_VC100_X64.DLL
WXBASE295U_VC100_X64.DLL
WXMSW295U_ADV_VC100_X64.DLL
WXMSW295U_CORE_VC100_X64.DLL

Those exist in the \lib folder under my wxWidgets source tree where I’d expect them to, but they don’t appear to have linked correctly? There are notes in the build docs for setting %WXWIN%, but from what I could tell that was for finding the sources during compile time if you weren’t using parallel svn checkouts (I am). Thanks for all your help,

–Dan

···

On Thursday, March 21, 2013 1:01:27 AM UTC-6, Robin Dunn wrote:

g.d.d.c wrote:

Robin,

Thanks for getting back to me. The issue seems to persist no matter what

my current working directory is:

Python 2.7.3+ (default, Mar 20 2013, 00:47:45) [MSC v.1600 64 bit
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> import os
 >>> os.getcwd()
'C:\\Documents and Settings\\Administrator'
 >>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\dev\cpython\lib\site-packages\wx-2.9.5-msw\wx\__init__.py",
line 45, in <module>
from wx._core import *
File "c:\dev\cpython\lib\site-packages\wx-2.9.5-msw\wx\_core.py",
line 4, in <module>
import _core_
ImportError: DLL load failed: The specified module could not be found.
 >>>

Let me know what you think, or if there are other things worth trying. I

can also scrap the VM state and try to work through my steps again so

they’re a bit better documented if you think it’d help. Thanks,

For that error you can load the core.pyd file into a tool called
Dependency Walker and it will show what DLLs it is unable to find.


Robin Dunn

Software Craftsman

http://wxPython.org

g.d.d.c wrote:

Sure thing. It appears to be missing these four:

WXBASE295U_NET_VC100_X64.DLL
WXBASE295U_VC100_X64.DLL
WXMSW295U_ADV_VC100_X64.DLL
WXMSW295U_CORE_VC100_X64.DLL

Those exist in the \lib folder under my wxWidgets source tree where I'd
expect them to, but they don't appear to have linked correctly?

They (and the other wx*.dll files there) need to either be copied to the wx package folder alongside the .pyd files, or the folder they are in needs to be added to the PATH.

There
are notes in the build docs for setting %WXWIN%, but from what I could
tell that was for finding the sources during compile time if you weren't
using parallel svn checkouts

Yep, that is just needed for build-time.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org

Most interesting - I … definitely don’t recall doing that in the other sandbox for VS2008, but adding that lib folder to the path gets me working. Now to test my py2exe changes and see how close I am. Thanks so much for all your help Robin!

–Dan

···

On Thursday, March 21, 2013 10:56:29 AM UTC-6, Robin Dunn wrote:

g.d.d.c wrote:

Sure thing. It appears to be missing these four:

WXBASE295U_NET_VC100_X64.DLL

WXBASE295U_VC100_X64.DLL

WXMSW295U_ADV_VC100_X64.DLL

WXMSW295U_CORE_VC100_X64.DLL

Those exist in the \lib folder under my wxWidgets source tree where I’d

expect them to, but they don’t appear to have linked correctly?

They (and the other wx*.dll files there) need to either be copied to the
wx package folder alongside the .pyd files, or the folder they are in
needs to be added to the PATH.

There

are notes in the build docs for setting %WXWIN%, but from what I could

tell that was for finding the sources during compile time if you weren’t

using parallel svn checkouts

Yep, that is just needed for build-time.


Robin Dunn

Software Craftsman

http://wxPython.org