Skip to content
Snippets Groups Projects
Unverified Commit 86de86b5 authored by Benjamin Cumming's avatar Benjamin Cumming Committed by GitHub
Browse files

prepare for PyPi upload (#1001)

Some small changes to facilitate smooth PyPi integration:
* update the Python installation guide
* update the license file
* add a `setup.cfg`
* add a stub for the Python readme
parent f5567d2a
No related branches found
No related tags found
No related merge requests found
Copyright (c) 2016, Eidgenössische Technische Hochschule Zürich and Copyright 2016-2020 Eidgenössische Technische Hochschule Zürich and Forschungszentrum Jülich GmbH.
Forschungszentrum Jülich GmbH.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
...@@ -3,87 +3,67 @@ ...@@ -3,87 +3,67 @@
Python Python
====== ======
Arbor provides access to all of the C++ library's functionality in Python, Arbor's Python wrapper will be the most convenient interface for most users.
which is the only interface for many users.
The getting started guides will introduce Arbor via the Python interface.
To test that Arbor is available, try the following in a `Python 3 <python2_>`_ interpreter: Getting Arbor
-------------
.. code-block:: python
>>> import arbor The easiest way to get Arbor is with
>>> print(arbor.__config__) `pip <https://packaging.python.org/tutorials/installing-packages>`_:
{'mpi': True, 'mpi4py': True, 'gpu': False, 'version': '0.2.3-dev'}
>>> print(arbor.__version__)
0.2.3-dev
The dictionary ``arbor.__config__`` contains information about the Arbor installation. .. code-block:: bash
This can be used to check that Arbor supports features that you require to run your model,
or even to dynamically decide how to run a model.
Single cell models like do not require parallelism like
that provided by MPI or GPUs, so the ``'mpi'`` and ``'gpu'`` fields can be ``False``.
Performance pip3 install arbor
--------------
The Python interface can incur significant memory and runtime overheads relative to C++ It is also possible to use Setuptools directly on a local copy of the source code:
during the *model building* phase, however simulation performance is the same
for both interfaces.
.. _python2: .. code-block:: bash
Python 2
----------
Python 2 reached `end of life <https://pythonclock.org/>`_ in January 2020. # use setuptools and python directly
Arbor only officially supports Python 3.6 and later, and all examples in the git clone https://github.com/arbor-sim/arbor.git --recursive
documentation are in Python 3. While it is possible to install and run Arbor python3 install ./arbor/setup.py
using Python 2.7 by setting the ``PYTHON_EXECUTABLE`` variable when
:ref:`configuring CMake <install-python>`, support is only provided for using
Arbor with Python 3.6 and later.
Installing .. note::
------------- Arbor's Setuptools process simplifies installation for common configurations
on laptops and workstations by calling CMake under the hood.
Before starting Arbor needs to be installed with the Python interface enabled. To install Arbor on a HPC cluster, or to configure Arbor with system-specific
The easiest way to get started with the Python interface is to install Arbor using options, we recommend using the :ref:`CMake build process <installarbor>`.
`pip <https://packaging.python.org/tutorials/installing-packages>`_.
Installing with pip requires two steps: To test that Arbor is available in Python, try the following in a `Python 3 <python2_>`_ interpreter
**(1)** Obtain Arbor source code from GitHub; to see information about the version and enabled features:
**(2)** then use pip to compile and install the Arbor package in one shot.
.. code-block:: bash .. code-block:: python
git clone https://github.com/arbor-sim/arbor.git --recursive >>> import arbor
# use pip (recommended) >>> print(arbor.__version__)
pip3 install ./arbor >>> print(arbor.__config__)
# use setuptools and python directly
python3 install ./arbor/setup.py
This will install Arbor as a site-wide package with only multi-threading enabled. Advanced Options
^^^^^^^^^^^^^^^^^^
To enable more advanced forms of parallelism, the following flags can optionally By default Arbor is installed with multi-threading enabled.
be passed to the pip install command: To enable more advanced forms of parallelism, the following optional flags can
be used to configure the installation:
* ``--mpi``: enable mpi support (requires MPI library). * ``--mpi``: Enable MPI support (requires MPI library).
* ``--gpu``: enable nvidia cuda support (requires cudaruntime and nvcc). * ``--gpu``: Enable NVIDIA CUDA support (requires cudaruntime and nvcc).
* ``--vec``: enable vectorization. This might require carefully choosing the ``--arch`` flag. * ``--vec``: Enable vectorization. This might require choosing an appropriate architecture using ``--arch``.
* ``--arch``: cpu micro-architecture to target. By default this is set to ``native``. * ``--arch``: CPU micro-architecture to target. By default this is set to ``native``.
If calling ``setup.py`` the flags must to come after ``install`` on the command line, If calling ``setup.py`` the flags must come after ``install`` on the command line,
and if being passed to pip they must be passed via ``--install-option``. The examples and if being passed to pip they must be passed via ``--install-option``. The examples
below demonstrate this for both pip and ``setup.py``, with pip being our recommend method. below demonstrate this for both pip and ``setup.py``.
Vanilla install with no additional options/features enabled: **Vanilla install** with no additional features enabled:
.. code-block:: bash .. code-block:: bash
pip3 install ./arbor pip3 install arbor
python3 ./arbor/setup.py install python3 ./arbor/setup.py install
Enable MPI support. This might require loading an MPI module or setting the ``CC`` and ``CXX`` **With MPI support**. This might require loading an MPI module or setting the ``CC`` and ``CXX``
:ref:`environment variables <install-mpi>`. :ref:`environment variables <install-mpi>`:
.. code-block:: bash .. code-block:: bash
...@@ -95,11 +75,10 @@ Compile with :ref:`vectorization <install-vectorize>` on a system with SkyLake ...@@ -95,11 +75,10 @@ Compile with :ref:`vectorization <install-vectorize>` on a system with SkyLake
.. code-block:: bash .. code-block:: bash
pip3 install --install-option='--vec' --install-option='--arch=skylake' ./arbor pip3 install --install-option='--vec' --install-option='--arch=skylake' arbor
python3 ./arbor/setup.py install --vec --arch=skylake python3 ./arbor/setup.py install --vec --arch=skylake
Compile with support for NVIDIA GPUs. This requires that the :ref:`CUDA toolkit <install-gpu>` **Enable NVIDIA GPUs**. This requires the :ref:`CUDA toolkit <install-gpu>`:
is installed and the CUDA compiler nvcc is available:
.. code-block:: bash .. code-block:: bash
...@@ -107,9 +86,9 @@ is installed and the CUDA compiler nvcc is available: ...@@ -107,9 +86,9 @@ is installed and the CUDA compiler nvcc is available:
python3 ./arbor/setup.py install --gpu python3 ./arbor/setup.py install --gpu
.. Note:: .. Note::
Installation takes a while because pip has to compile the Arbor C++ library and Setuptools compiles the Arbor C++ library and
wrapper, which takes a few minutes. Pass the ``--verbose`` flag to pip wrapper, which can take a few minutes. Pass the ``--verbose`` flag to pip
to see the individual steps being preformed if concerned that progress to see the individual steps being performed if you are concerned that progress
is halting. is halting.
.. Note:: .. Note::
...@@ -121,23 +100,45 @@ is installed and the CUDA compiler nvcc is available: ...@@ -121,23 +100,45 @@ is installed and the CUDA compiler nvcc is available:
and installation. and installation.
.. Note:: .. Note::
If there is an error installing with pip you want to report, To report problems installing with pip,
run pip with the ``--verbose`` flag, and attach the output (along with run pip with the ``--verbose`` flag, and attach the output (along with
the pip command itself) to a ticket on the the pip command itself) to a ticket on
`Arbor GitHub <https://github.com/arbor-sim/arbor/issues>`_. `Arbor's issues page <https://github.com/arbor-sim/arbor/issues>`_.
For example, ``pip3 install --install-option='--mpi' --verbose .``.
Dependencies Dependencies
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
If a downstream dependency of Arbor that requires Arbor be built with If a downstream dependency requires Arbor be built with
a specific feature enabled, use ``requirements.txt`` to a specific feature enabled, use ``requirements.txt`` to
`define the constraints <https://pip.pypa.io/en/stable/reference/pip_install/#per-requirement-overrides>`_. `define the constraints <https://pip.pypa.io/en/stable/reference/pip_install/#per-requirement-overrides>`_.
For example, a package that depends on `arbor` would version 0.3 or later For example, a package that depends on `arbor` version 0.3 or later
with MPI support would add the following to its requirements. with MPI support would add the following to its requirements:
.. code-block:: python .. code-block:: python
arbor >= 0.3 --install-option='--gpu' \ arbor >= 0.3 --install-option='--gpu' \
--install-option='--mpi' --install-option='--mpi'
Performance
--------------
The Python interface can incur significant memory and runtime overheads relative to C++
during the *model building* phase, however simulation performance is the same
for both interfaces.
.. _python2:
Python 2
----------
Python 2 reached `end of life <https://pythonclock.org/>`_ in January 2020.
Arbor only provides support for Python 3.6 and later.
.. note::
It might be possible to install and run Arbor
using Python 2.7 by setting the ``PYTHON_EXECUTABLE`` variable when
:ref:`configuring CMake <install-python>`.
However, Arbor is not tested against Python 2.7, and we won't be able
to provide support.
# Arbor
The Arbor Python package is a wrapper around the high-performance C++ library Arbor, for
constructing and running simulations multi-compartment neuron models, from single cell models
to large networks.
Documentation is available online at [Read the Docs](https://arbor.readthedocs.io/en/latest/python.html).
[Submit a ticket](https://github.com/arbor-sim/arbor) if you have any questions or want help.
[metadata]
description-file = python/readme.md
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment