Skip to content
Nathan Jensen edited this page Aug 16, 2015 · 33 revisions

Build

CPython extensions generally need to be built with the same compiler that built Python. That's usually MSVC. MSVC needs to be installed prior to building Jep.

New in 3.3: Jep can be built on Windows with python setup.py build.

Known Issues

Therefore, unless you are an expert at building on Windows and want to help solve some of these issues, you will need Microsoft Visual Studio. Microsoft Visual Studio Express is available for free. You will also need to set the JAVA_HOME environment variable in the system settings.

The setup.py build should produce a jep.pyd file and rename it to jep.dll. pyd files are very similar to DLLs. If Python were to load the library, we'd probably want a pyd file, but since the library will be loaded from Java, we need a DLL. The DLL will retain a manifest in the file so the operating system can load it correctly. If by chance you somehow end up with both jep.pyd and jep.dll, you must remove the jep.pyd file as it will get loaded first and will not work correctly.

Alternative (deprecated) build: Open Jep as a project in Microsoft Visual Studio and build within Visual Studio. The windows directory exists to support this alternative. If using a version of Jep prior to 3.3, this is the recommended way to build on Windows.

Work In Progress

This section is a work in progress. To date I know of three people who have pulled this off: Dave, Gunther, and Nikolas. I am attempting to follow all the steps and document them myself. Do not consider this section as official at this time as I have not successfully built on Windows. ~Nate

CPython extensions generally need to be built with the same compiler that built Python. That's usually MSVC, and MSVC needs to be installed prior to building Jep, but sadly it's not that simple. You must build with very specific versions of MSVC for this to work correctly. And you must install extra packs if you want 64-bit. To think that you once thought building for Linux could be difficult, and then you tried to build CPython extensions for Windows.

Any deviation from this (i.e. MinGW or a different version of MSVC) is at your own risk. If you manage to successfully build with variations and have a working and stable Jep, we'd love to hear about it.

The steps are different depending on if you want to build Jep for Python 2 or Python 3.

Python 2 Jep Build Setup

The official Python was built with Microsoft Visual Studio Express 2008, so you should build Jep with that. It is freely available and also known as MSVC 9.0. Finding a download link can be difficult, here are some that are working:

64-bit Python 2 Jep Build Setup

If you want to build 64-bit, you will need another install.

  1. You need to download the Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1. It is very important that you use this download with .NET Framework 3.5, the installer with .NET Framework 4 will not work as it assumes Visual Studio 2010.
  2. When you run the installer, it will prompt you about what to install. You need to install the following:
    • Windows Headers and Libraries
    • Visual C++ Compilers
    • Win32 Development Tools (under Windows Development Tools)
  3. Copy C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars64.bat to C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat.

Python 3 Jep Build Setup

The official Python was built with Microsoft Visual Studio Express 2010, so you should build Jep with that. It is freely available and also known as MSVC 10.0. Finding a download link can be difficult, here are some that are working:

64-bit Python 3 Jep Build Setup

If you want to build 64-bit, you may need more installs.

  1. You need to download the Microsoft Windows SDK for Windows 7 and .NET Framework 4. It is very important that you use this download with .NET Framework 4, the installer with .NET Framework 3.5 will not work as it assumes Visual Studio 2008.
  2. When you run the installer, it will prompt you about what to install. You need to install the following:
    • Windows Native Code Development
      • Windows Headers and Libraries
      • Tools
      • Visual C++ Compilers
  3. You can't build this with an ordinary command prompt. Instead go to Start -> All Programs -> Microsoft Windows SDK 7.1 -> Windows SDK 7.1 Command Prompt.

Building

Presuming you completed the steps above for your version of Python, you should be ready to build Jep. You might want to make a virtualenv to keep things isolated, and if you wanted numpy support you should install it now if it's not already installed. An easy way to get a numpy install working on Windows is to download a wheel from this page: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy If you want to install the wheel, use pip install --no-index --find-links=${dir/containing/wheel}.

To run the build, from the jep dir use python setup.py build. If all goes well you will end up with a build dir with some jars, a jep.pyd, and a jep.bat file. Running python setup.py install will place the files in their appropriate locations:

  • jep python files will be installed to Python's Lib/site-packages/jep
  • jep jar will be installed to python's Lib/site-packages/jep
  • jep.pyd will be renamed jep.dll and installed to Python's Lib/site-packages/jep
  • jep.bat will be installed to Python's Scripts dir

Now you should be able to run python setup.py test if you'd like to test it, or simply run jep to use the interactive interpreter.

Further Help

Should you diverge from this path, or get stuck, someone else may have run into the same problems as you. The following stack overflow pages are quite useful for trying to build CPython extensions on Windows:

Clone this wiki locally