Building Blocks

31Dec/082

Installing PyAMF 0.4.0rc1 on Windows XP

I wanted to give the latest pyamf a go, but when I used the standard 'setup.py install', the following ominous warning was presented:

error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.

Uh oh! I actually DO have Cygwin installed, but unfortunately this message is a default and not entirely helpful. It did put me on the right path to actually getting it to go.

This webpage has a lot of good information on the subject, and it is where I pulled out these steps:

1. Grab the MingW32 Automated Installer and get it installed. I selected all of the available options as I figured it wouldn't hurt (it didn't)

2. Add the mingw32 binaries to your system path environmental variable (ie c:\mingw32\bin)

3. Tell Python to use mingw32 when it needs to compile a distribution by adding a file called distutils.cfg in this folder: {PYTHON_INSTALL}\lib\distutils\distutils.cfg. The file should contain:

[build]
compiler = mingw32

4. Version number parsing was throwing errors, so you actually have to edit {PYTHON_INSTALL}\lib\distutils\version.py to get it compiled. At line 100 make the following change:

from:

1
2
    version_re = re.compile(r'^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$',
                        re.VERBOSE)

to:

1
2
    version_re = re.compile(r'^(\d+) \. (\d+) (\. (\d+))? (\. (\d+))?$',
                            re.VERBOSE)

now with all that done, just run 'setup.py install' and it should compile as expected. Easy as... I dunno, it is actually kind of confusing, but it works and now I can give pyamf a whirl with the c-ext enabled.

Filed under: pyAMF, python Leave a comment
  • http://pyamf.org Nick Joyce

    (Disclosure – I am one of the devs of PyAMF)

    Yeah this experience could definitely could be improved. Whilst this is a setuptools/distutil/platform specific issue, there are two possible solutions whilst the dev env is sorted out:

    1) Run `python setup.py install –disable-ext` which will disable building the extension altogether. Not useful if you want to explicitly use cpyamf, but will provide a working lib using pure python. Or ..

    2) Download the egg appropriate to your platform/python version – available at http://download.pyamf.org/releases. You should also be able to get the appropriate egg using easy_install. The egg provides a compiled version of cpyamf ready to use.

    Eggs for all platforms/versions that we support are not yet up there – we will add these as we build them.

    Thanks for the great article!

  • http://joelhooks.com Joel Hooks

    I didn’t even notice the compiled releases! I had no trouble what-so-ever on ubuntu. Windows is just tricky because of its nature. It was actually kind of fun to figure out, but I’m a nerd that loves a problem :>