Giter VIP home page Giter VIP logo

itkpythonpackage's Introduction

ITKPythonPackage

This project provides a setup.py script that build ITK Python wheels.

ITK is an open-source, cross-platform system that provides developers with an extensive suite of software tools for image analysis.

The Python packages are built daily. To install the ITK Python package:

python -m pip install --upgrade pip
python -m pip install itk -f https://github.com/InsightSoftwareConsortium/ITKPythonPackage/releases/tag/latest

For more information on ITK's Python wrapping, see an introduction in the ITK Software Guide. There are also many downloadable examples documented in Sphinx.

Table of Contents

Automated wheels building with scripts

Steps required to build wheels on Linux, MacOSX and Windows have been automated. The following sections outline how to use the associated scripts.

Linux

On any linux distribution with docker and bash installed, running the script dockcross-manylinux-build-wheels.sh will create 64-bit wheels for both python 2.x and python 3.x in the dist directory.

For example:

$ git clone https://github.com/InsightSoftwareConsortium/ITKPythonPackage.git
[...]

$ ./scripts/dockcross-manylinux-build-wheels.sh
[...]

$ ls -1 dist/
itk-4.11.0.dev20170218-cp27-cp27m-manylinux1_x86_64.whl
itk-4.11.0.dev20170218-cp27-cp27mu-manylinux1_x86_64.whl
itk-4.11.0.dev20170218-cp34-cp34m-manylinux1_x86_64.whl
itk-4.11.0.dev20170218-cp35-cp35m-manylinux1_x86_64.whl
itk-4.11.0.dev20170218-cp36-cp36m-manylinux1_x86_64.whl

MacOSX

First install the Python.org MacOSX Python's. This step requires sudo:

./scripts/macpython-install-python.sh

Then, build the wheels:

$ ./scripts/macpython-build-wheels.sh
[...]

$ ls -1 dist/
itk-4.11.0.dev20170213-cp27-cp27m-macosx_10_6_x86_64.whl
itk-4.11.0.dev20170213-cp34-cp34m-macosx_10_6_x86_64.whl
itk-4.11.0.dev20170213-cp35-cp35m-macosx_10_6_x86_64.whl
itk-4.11.0.dev20170213-cp36-cp36m-macosx_10_6_x86_64.whl

Windows

First, install Microsoft Visual C++ Compiler for Python 2.7, Visual Studio 2015, Git, and CMake, which should be added to the system PATH environmental variable.

Open a PowerShell terminal as Administrator, and install Python:

PS C:\> Set-ExecutionPolicy Unrestricted
PS C:\> iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/scikit-build/scikit-ci-addons/master/windows/install-python.ps1'))

In a PowerShell prompt:

PS C:\Windows> cd C:\
PS C:\> git clone https://github.com/InsightSoftwareConsortium/ITKPythonPackage.git IPP
PS C:\> cd IPP
PS C:\IPP> .\scripts\windows-build-wheels.ps1
[...]

PS C:\IPP> ls dist
    Directory: C:\IPP\dist


    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    -a----         4/9/2017   5:21 PM       59435508 itk-4.11.0.dev20170407-cp27-cp27m-win_amd64.whl
    -a----         4/9/2017  11:14 PM       63274441 itk-4.11.0.dev20170407-cp35-cp35m-win_amd64.whl
    -a----        4/10/2017   2:08 AM       63257220 itk-4.11.0.dev20170407-cp36-cp36m-win_amd64.whl

We need to work in a short directory to avoid path length limitations on Windows, so the repository is cloned into C:\IPP. Also, it is very important to disable antivirus checking on the C:\IPP directory. Otherwise, the build system conflicts with the antivirus when many files are created and deleted quickly, which can result in Access Denied errors. Windows 10 ships with an antivirus application, Windows Defender, that is enabled by default.

sdist

To create source distributions, sdist's, that will be used by pip to compile a wheel for installation if a binary wheel is not available for the current Python version or platform:

$ python setup.py sdist --formats=gztar,zip
[...]

$ ls -1 dist/
itk-4.11.0.dev20170216.tar.gz
itk-4.11.0.dev20170216.zip

Prerequisites

Building wheels requires:

Detailed build instructions

Building ITK Python wheels

Build the ITK Python wheel with the following command:

mkvirtualenv build-itk
pip install -r requirements-dev.txt
python setup.py bdist_wheel

Efficiently building wheels for different version of python

If on a given platform you would like to build wheels for different version of python, you can download and build the ITK components independent from python first and reuse them when building each wheel.

Here are the steps:

  1. Build ITKPythonPackage with ITKPythonPackage_BUILD_PYTHON set to OFF

  2. Build "flavor" of package using:

python setup.py bdist_wheel -- \
  -DITK_SOURCE_DIR:PATH=/path/to/ITKPythonPackage-core-build/ITK-source

Miscellaneous

Written by Jean-Christophe Fillion-Robin and Matt McCormick from Kitware Inc.

It is covered by the Apache License, Version 2.0:

http://www.apache.org/licenses/LICENSE-2.0

For more information about ITK, visit http://itk.org

itkpythonpackage's People

Contributors

espdev avatar jcfr avatar kwrobot avatar thewtex avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.