Setup#

Check that you have a virtual environment with Python 3.8 or above installed.

Python versions and virtual environments

Virtual environments are an essential tool because they isolate a project’s dependencies from the rest of the environment. You can build different Python versions with pyenv, while pyenv-virtualenv helps manage virtual environments (for example, automatically activating the right environment if you place a .python-version file at the repository’s root).

Basic Setup#

Install opda via pip:

$ pip install opda

Or, if you’re interested in development, clone the repo and do an --editable install:

$ git clone https://github.com/nicholaslourie/opda.git
$ cd opda
$ pip install --editable .

The --editable option automatically updates the package when you change the source code. Editable installs require pip v21.3 or higher.

Optional Dependencies#

Opda has several optional dependencies. Most optional dependencies need to be installed with pip v21.2 or higher.

Install any of the following if you want to:

opda[experiments]

Use the experiments package (available only in checkouts of the repo):

$ pip install .[experiments]
opda[nbs]

Run notebooks available in the nbs/ directory:

$ pip install opda[nbs]
opda[test]

Run the tests.

$ pip install opda[test]
opda[lint]

Run the linter (when developing or extending opda):

$ pip install opda[lint]
opda[docs]

Build the documentation.

$ pip install opda[docs]
opda[package]

Build the distribution package.

$ pip install opda[package]
opda[ci]

Run continuous integration commands using nox:

$ pip install opda[ci]

You can also install any combination or all of the above:

$ pip install opda[ci,docs,experiments,lint,nbs,package,test]

For local development setups, use a . in place of opda in all of the above.

See Usage and Development for more information on how to use these dependencies.

Python Versions#

Opda uses tools like nox to test itself against the Python versions it supports. To develop opda, you must install these Python versions. They can be found in the package’s metadata:

>>> from importlib.metadata import metadata
>>> for classifier in metadata("opda").get_all("Classifier"):
...   *prefix, version = classifier.split(" :: ")
...   if prefix != ["Programming Language", "Python"] or "." not in version:
...     continue
...   print(version)
3.8
3.9
3.10
3.11
3.12

To install them, we recommend pyenv:

$ pyenv install 3.8 3.9 3.10 3.11 3.12

After the required versions are installed, make sure they’re available on your PATH. You can do this either globally:

$ pyenv global system 3.8 3.9 3.10 3.11 3.12

Or locally (just within the opda repository):

$ pyenv local opda 3.8 3.9 3.10 3.11 3.12

The above example assumes you have a virtual environment named opda that you wish to activate using pyenv-virtualenv whenever inside the repository. If you have no such virtual environment, then omit opda from the command.