Installation and Testing
Installation via pip 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
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.
$ SETUPTOOLS_USE_CYTHON=1 pip install --user .
After the successful execution of the command, the you can import and use the compiled library as follows:
1# Importing NURBS module
2from geomdl.core import NURBS
3# Importing visualization module
4from geomdl.visualization import VisMPL as vis
5
6# Creating a curve instance
7crv = NURBS.Curve()
8
9# Make a quadratic curve
10crv.degree = 2
11
12#######################################################
13# Skipping control points and knot vector assignments #
14#######################################################
15
16# Set the visualization component and render the curve
17crv.vis = vis.VisCurve3D()
18crv.render()
Before the Cython compilation, please make sure that you have a valid compiler installed for your operating system.