Installation and Testing

Installation via pip or conda is the recommended method for all users. Manual method is only recommended for advanced users. Please note that if you have used any of these methods to install NURBS-Python, please use the same method to upgrade to the latest version.

Note

On some Linux and MacOS systems, you may encounter 2 different versions of Python installed. In that case Python 2.x package would use python2 and pip2, whereas Python 3.x package would use python3 and pip3. The default python and pip commands could be linked to one of those. Please check your installed Python version via python -V to make sure that you are using the correct Python package.

Install via Pip

The easiest method to install/upgrade NURBS-Python is using pip. The following commands will download and install NURBS-Python from Python Package Index.

$ pip install --user geomdl

Upgrading to the latest version:

$ pip install geomdl --upgrade

Installing a specific version:

$ pip install --user geomdl==5.0.0

Install via Conda

NURBS-Python can also be installed/upgraded via conda package manager from the Anaconda Cloud repository.

Installing:

$ conda install -c orbingol geomdl

Upgrading to the latest version:

$ conda upgrade -c orbingol geomdl

If you are experiencing problems with this method, you can try to upgrade conda package itself before installing the NURBS-Python library.

Manual Install

The initial step of the manual install is cloning the repository via git or downloading the ZIP archive from the repository page on GitHub. The package includes a setup.py script which will take care of the installation and automatically copy/link the required files to your Python distribution’s site-packages directory.

The most convenient method to install NURBS-Python manually is using pip:

$ pip install --user .

To upgrade, please pull the latest commits from the repository via git pull --rebase and then execute the above command.

Development Mode

The following command enables development mode by creating a link from the directory where you cloned NURBS-Python repository to your Python distribution’s site-packages directory:

$ pip install --user -e .

Since this command only generates a link to the library directory, pulling the latest commits from the repository would be enough to update the library to the latest version.

Checking Installation

If you would like to check if you have installed the package correctly, you may try to print geomdl.__version__ variable after import. The following example illustrates installation check on a Windows PowerShell instance:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\> python
Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import geomdl
>>> geomdl.__version__
'4.0.2'
>>>

Testing

The package includes tests/ directory which contains all the automated testing scripts. These scripts require pytest installed on your Python distribution. Then, you can execute the following from your favorite IDE or from the command line:

$ pytest

pytest will automatically find the tests under tests/ directory, execute them and show the results.

Compile with Cython

To improve performance, the Core Library of NURBS-Python can be compiled and installed using the following command along with the pure Python version.

$ pip install --user . --install-option="--use-cython"

This command will generate .c files (i.e. cythonization) and compile the .c files into binary Python modules.

The following command can be used to directly compile and install from the existing .c files, skipping the cythonization step:

$ pip install . --install-option="--use-source"

To update the compiled module with the latest changes, you need to re-cythonize the code.

To enable Cython-compiled module in development mode;

$ python setup.py build_ext --use-cython --inplace

After the successful execution of the command, the you can import and use the compiled library as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Importing NURBS module
from geomdl.core import NURBS
# Importing visualization module
from geomdl.visualization import VisMPL as vis

# Creating a curve instance
crv = NURBS.Curve()

# Make a quadratic curve
crv.degree = 2

#######################################################
# Skipping control points and knot vector assignments #
#######################################################

# Set the visualization component and render the curve
crv.vis = vis.VisCurve3D()
crv.render()

Before Cython compilation, please make sure that you have Cython module and a valid compiler installed for your operating system.

Docker Containers

A collection of Docker containers is provided on Docker Hub containing NURBS-Python, Cython-compiled core and the command-line application. To get started, first install Docker and then run the following on the Docker command prompt to pull the image prepared with Python v3.5:

$ docker pull idealabisu/nurbs-python:py35

On the Docker Repository page, you can find containers tagged for Python versions and Debian (no suffix) and Alpine Linux (-alpine suffix) operating systems. Please change the tag of the pull command above for downloading your preferred image.

After pulling your preferred image, run the following command:

$ docker run --rm -it --name geomdl -p 8000:8000 idealabisu/nurbs-python:py35

In all images, Matplotlib is set to use webagg backend by default. Please follow the instructions on the command line to view your figures.

Please refer to the Docker documentation for details on using Docker.