← Back to team overview

kicad-developers team mailing list archive

Re: Python scripting cmake build macros.

 

On 01/31/2013 11:36 AM, Brian Sidebotham wrote:
>
>
>
> On 24 January 2013 22:42, Brian Sidebotham <brian.sidebotham@xxxxxxxxx
> <mailto:brian.sidebotham@xxxxxxxxx>> wrote:
>
>     A quick test to build wxPython with a freshly compiled python-mingw with binascii
>     package results in the next problem. One that looks a bit more fundamental to sort out:
>
>     This is what I get compiling the most basic of extension with this python-mingw, the
>     error is the same when trying to build wxPython too:
>
>     KiCad-WinbuilderC:\kicad-winbuilder-dev\kicad-winbuilder\src\wx\testmodule>python
>     setup.py build -c mingw32
>     running build
>     running build_ext
>     Warning: Can't read registry to find the necessary compiler setting
>     Make sure that Python modules _winreg, win32api or win32con are installed.
>     building 'hello' extension
>     C:\kicad-winbuilder-dev\kicad-winbuilder\env\mingw\bin\gcc.exe -mno-cygwin -mdll
>      -O -Wall -IC:\kicad-winbuilder-dev\kicad-winbuilder\env\python\include -IC:\kic
>     ad-winbuilder-dev\kicad-winbuilder\env\python\PC -c testmodule.c -o build\temp.w
>     in32-2.7\Release\testmodule.o
>     Traceback (most recent call last):
>       File "setup.py", line 8, in <module>
>         ext_modules = [module1])
>       File "C:\kicad-winbuilder-dev\kicad-winbuilder\env\python\lib\python2.7\distut
>     ils\core.py", line 152, in setup
>         dist.run_commands()
>       File "C:\kicad-winbuilder-dev\kicad-winbuilder\env\python\lib\python2.7\distut
>     ils\dist.py", line 953, in run_commands
>         self.run_command(cmd)
>       File "C:\kicad-winbuilder-dev\kicad-winbuilder\env\python\lib\python2.7\distut
>     ils\dist.py", line 972, in run_command
>         cmd_obj.run()
>       File "C:\kicad-winbuilder-dev\kicad-winbuilder\env\python\lib\python2.7\distut
>     ils\command\build.py", line 127, in run
>         self.run_command(cmd_name)
>       File "C:\kicad-winbuilder-dev\kicad-winbuilder\env\python\lib\python2.7\distut
>     ils\cmd.py", line 326, in run_command
>         self.distribution.run_command(command)
>       File "C:\kicad-winbuilder-dev\kicad-winbuilder\env\python\lib\python2.7\distut
>     ils\dist.py", line 972, in run_command
>         cmd_obj.run()
>       File "C:\kicad-winbuilder-dev\kicad-winbuilder\env\python\lib\python2.7\distut
>     ils\command\build_ext.py", line 340, in run
>         self.build_extensions()
>       File "C:\kicad-winbuilder-dev\kicad-winbuilder\env\python\lib\python2.7\distut
>     ils\command\build_ext.py", line 449, in build_extensions
>         self.build_extension(ext)
>       File "C:\kicad-winbuilder-dev\kicad-winbuilder\env\python\lib\python2.7\distut
>     ils\command\build_ext.py", line 499, in build_extension
>         depends=ext.depends)
>       File "C:\kicad-winbuilder-dev\kicad-winbuilder\env\python\lib\python2.7\distut
>     ils\ccompiler.py", line 624, in compile
>         self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
>       File "C:\kicad-winbuilder-dev\kicad-winbuilder\env\python\lib\python2.7\distut
>     ils\cygwinccompiler.py", line 164, in _compile
>         extra_postargs)
>       File "C:\kicad-winbuilder-dev\kicad-winbuilder\env\python\lib\python2.7\distut
>     ils\ccompiler.py", line 925, in spawn
>         spawn(cmd, dry_run=self.dry_run)
>       File "C:\kicad-winbuilder-dev\kicad-winbuilder\env\python\lib\python2.7\distut
>     ils\spawn.py", line 36, in spawn
>         _spawn_nt(cmd, search_path, dry_run=dry_run)
>       File "C:\kicad-winbuilder-dev\kicad-winbuilder\env\python\lib\python2.7\distut
>     ils\spawn.py", line 69, in _spawn_nt
>         rc = os.spawnv(os.P_WAIT, executable, cmd)
>     AttributeError: 'module' object has no attribute 'spawnv'
>
>     Basically it's down to not having pywin32 installed or any other win32api module.
>     The trouble is they all seem to require compiling with msvc.
>
>     I've run out of time again.
>
>     Best Regards, Brian.
>
>
>
> Hi Guys,
>
> Sorry I missed most of the discussion today, but appear to have dropped and bomb before
> I stopped following!
>
> The mail I sent above details the tie-in with pywin32, although I notice now upon
> re-reading that this may just be python's distutils trying to access the registry and
> failing.
>
> I am assuming here that we need to execute this python build using the new python-mingw
> executable on windows to compile wxPython? I don't see how that part can be done under
> Linux?
>
> This is entirely where the link to pywin32 came from - which is essentially distutils
> rather than wxPython.


This sounds like just another windows specific sickness that needs to be rooted out of
distutils with a patch during the python build.  If linux python's distutils can work
without a windows registry, why cannot windows?

Admittedly my vision and goals are different than those who have worked on python in the
past.  But they are probably not that different than the guy who had a whack at
python-mingw. 

Basically mine its this: 1) no Microsoft, 2) please bring in the next solution possibility
please.


=====================

For reasons fully unknown to me I have spent some time on python 2.7.3 source.  I suppose
it is for my Windows KiCad friends, and a subconscious desire to extent my reputation as a
world famous programmer, out beyond my household.

But in one day and one night I was able to create a big ass patch against 2.7.3 which adds
*significantly* to the CMake-ability patch we found earlier for 2.7.1.

I can now build windows-x86_64 and windows-x86_32 python-mingw, short a few extensions. 
Of course on linux.  I have to bring in two more external packages, and am doing so with
ExternalProject_Add() using CMake.  That will enable the full set of stock python
extensions for windows.  One of these I have done before in my commercial products.

Some external projects use "configure", and although I hate it, I am only willing to use
it on linux.  This means the patch to python 2.7.3 will only work on linux, but builds
windows binaries.

I see that pywin32 has over 9,000 downloads per week.  Maybe I will actually become world
famous supplying python-mingw binaries for windows-32 and windows-64.  If I succeed, I
will put these binaries on the kicad-pcb.org site.  If I do not, then you never read
this.  Or I say "enough" and pass the token.

Success might entail creating a more generic python for windows, not one that needs to
access the friggin registry.  It's a 3 step dance, this would be only the first step, but
during this step decisions can be made about how distutils works.  Yes, done only on linux
for windows.  The build process can be fully controlled, if you are willing to replace it.

It is just me walking the talk I said two weeks ago.

But why so much talk?

Dick



Follow ups

References