Adding numpy module to python build

edited November 2015 in General
Hello,
Does anybody know how to add the numpy module to the KLayout build (with Python 3.4). Any chance to add that module without recompiling the Klayout build?
thanks, Jonas

Comments

  • edited November -1

    To add to this, I am interested in creating geometries containing thousands of points. For example, chirped & apodized spiral Bragg grating waveguides. Presently we do calculations in Matlab, save the coordinates to a file, and import them into the layout tool. Not very efficient.

    It would be nice to have a PCell with calculations efficiently done in Python.

  • edited November -1

    Hi all,

    in general you don't need to recompile KLayout. But you may need to recompile numpy.

    Here is what I know:

    • Linux: when you build or install KLayout for one of the distributions, KLayout shares the Python installation with the system. So installing numpy is as easy as installing the appropriate python package. On Ubuntu 14 for example the packages are "python3-numpy" for Python 3.4 or "python-numpy" for Python 2.7.
    • Linux with custom Python version: you'll need to build numpy within the Python installation KLayout was built against. Usually this is done with easy_install from the source egg.
    • Windows: KLayout for windows comes with Python 3.4 that was built with Visual Studio 2010. You can download the Python installation that was used for the build here: http://178.77.72.242/downloads/Python34.zip. Using this installation and provided you have installed Visual Studio 2010, you should be able to build the modules you require. For installation, it should be sufficient to copy the respective files to one folder listed in KLayout's "sys.path" variable. If you're lucky there is a numpy binary distribution available already and you can simply install it from that distribution.
    • Regarding MacOS I can't tell much. Maybe the build options are limited so there is a good chance to find a binary distribution which you just need to copy to the right place.

    Matthias

  • edited November 2015
    Some updates for Windows: Downloading the precompiled numpy module from Christoph Gohlke's Unofficial Windows Binaries for Python Extension Packages website worked:

    http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy (The following package worked for me: numpy-1.9.3+mkl-cp34-none-win_amd64.whl)
    Copy the 'numpy' folder into %KLayout Install Path%/lib/python/Lib/site-packages

    jf
  • edited November -1

    excellent!

    any other Windows problems? the recursive shape one, probably?

Sign In or Register to comment.