Skip to content

Installation

This page details how to setup a Python virtual environment using uv to install and run AFMSlicer.

Virtual Environment

We recommend using uv to install and manage your virtual environments but you do not have to. Other options such virtualenvwrapper and MiniForge also allow you to create and manage virtual environments but are not covered here.

Install uv

uv has excellent instructions on how to install the software on different operating systems.

Create a Virtual Environment

To create a virtual environment you should create a directory for undertaking your work, change directory into it and then us uv venv --python 3.11.

NB Because of a performance regression in one of TopoStats dependencies, the package Topoly TopoStats only supports Python 3.10 and 3.11. The developers are aware and are hoping this will be resolved in the near future.

mkdir AFMSlicer
cd AFMSlicer
uv venv --python 3.11

You can now activate the environment and check that your are using the python binary from that environment.

source .venv/bin/activate
which python
python --version

You should see output similar to the following although the first line will depend on your operating system and the path where you created the afm_slicing programme.

/home/user/work/AFMSlicer
Python 3.11.13

If you use direnv to activate virtual environments automatically when you enter them you can add the following to .envrc to activate the environment from within the AFMSlicer directory.

echo "#!/bin/bash\nsource .venv/bin/activate" > .envrc

PyPI

Currently AFMSlicer has not been packaged and released to PyPi, when this changes instructions will be added.

Development

AFMSlicer is in the early stages of development and as such must be installed from the GitHub repository along with development versions of its dependency TopoStats. The steps involved in installing the development version are described below and require that you install and use uv to set things up.

  1. Clone the AFMSlicer repository.
  2. Clone the TopoStats repository.
  3. Switch to the ns-rse/1102-switching-to-TopoStats-class branch on TopoStats.
  4. Activate the virtual environment and synchronise it.
  5. Install the development version of TopoStats under the virtual environment (this will pull in the AFMReader dependency automatically).
  6. Install AFMSlicer.
cd ~/work/
git clone git@github.com:ns-rse/AFMSlicer.git
git clone git@github.com:AFM-SPM/TopoStats.git
cd TopoStats
git checkout ns-rse/1102-switching-to-TopoStats-class
git pull
cd ../AFMSlicer
source .venv/bin/activate
uv sync
uv pip install -e ../TopoStats/.
uv pip install -e ".[dev,tests]"