Skip to content

Installation

There are a number of different options for installing LayOpt depending on whether you want to just use a stable release, a development version or contribute to development.

Once installed please refer to the usage instructions.

Virtual Environment

It is recommended that you use a Python Virtual Environment to install LayOpt. There are many options available but a good choice, used in the development of LayOpt, is uv. Create a directory for your work and after installing uv create a virtual environment.

# Create a directory
mkdir LayOpt
# Change directory
cd LayOpt
# Create a virtual Environment
uv venv

PyPI

Released versions are available for installation from PyPI. Ideally you should use a Python Virtual Environment (see above).

# Plain virtual environment
pip install layopt
# uv virtual environment
uv pip install layopt

Pre-releases

If you wish to try pre-releases, denoted by suffixes of the form a# for alpha releases, b# for beta and rc# for release candidates you should include the specific version when calling pip. For example to install the 0.1.0a1 (first alpha release of version 0.1.0) you would use...

# Plain virtual environment
pip install layopt==0.1.0a1
# uv virtual environment
uv pip install layopt==0.1.0a1

Rhino and Grasshopper Users

Warning

If you are using Rhino and/or the Grasshopper plugin/extension to run Python code then you may encounter some problems. The solutions to these are described below.

Minimum Python Version

LayOpt has been developed using a minimum Python version requirement of >= 3.12 due to the end of life scheduled for various versions. The current stable release of Rhino (8.0) only supports Python 3.9. The developers are however targeting Python 3.13 as the minimum version for the imminent Rhino 9.0 release and the Beta version already includes this support. You should therefore use the Beta version (or >= 9.0 once released) if you wish to use LayOpt.

Locale Issues

Users have identified some issues with setting locales when the Pandas package is imported. LayOpt uses Pandas to handle building data frames of results which are written to .csv output files and so you may encounter this issue.

If you this issue then you should follow the advice in the thread and set your locale explicitly to en_US before explicitly importing pandas. Sample code from the linked thread is shown below.

import locale

locale.setlocale(locale.LC_ALL, "en_US")

import pandas

If you encounter this problem and this doesn't resolve it please seek assistance in the Rhino forums.

GitHub

You can use pip to install the package directly from GitHub. This allows you to install a specific branch or commit to test out new functionality that is under development. In your Virtual Environment run...

# Install from HEAD of main branch
pip install git@https://github.com/ICAIR-Sheffield/LayOpt
# Install a specific <branch>
pip install git@https://github.com/ICAIR-Sheffield/LayOpt.git@<branch>

Development

Contributions are welcome. If you are considering contributing to the development of LayOpt and are not a collaborator of the repository then you should fork to your account first and then clone from there.

We use uv package manager to develop LayOpt. To install this software clone the repository and make sure you have uv installed.

# Clone using SSH
git clone git@github.com:ICAIR-Sheffield/LayOpt.git
# Clone using https
git clone https://github.com/ICAIR-Sheffield/LayOpt.git
# Change directory
cd LayOpt
# Create a virtual Environment
uv venv
# Synchronise the virtual environment (installs dependencies)
uv sync
# Install development dependencies
uv pip install --group dev
# Install pre-commit hooks
pre-commit install

Style and Linting

We use a number of pre-commit hooks to ensure the codebase follows the PEP8 style guide and functions/methods, classes and modules are documented using numpydoc Style. After installing the pre-commit hooks you will find when making a commit that the hooks are run against the changes being submitted. Sometimes the hooks will reformat the files to ensure they follow the guidelines, but not all changes can, or should, be applied automatically and you will have to review the output and make the changes, stage and commit (--amend) to ensure the hooks pass.

Of particular note is ensuring the typehints are consistent as we use mypy to run static type checking against the code base. For details of all hooks used see the .pre-commit-config.yaml file in the repository.