---
title: Python
summary: Install the bimworks package from the private Python index with uv, Poetry or pip, pinned to that index, and check that it imports.
order: 45
languages: [python]
status: draft
terms: [sdk, api-token]
see-also: [reference/sdk/python, reference/sdk, how-to/install/php, api]
---

# Python

For Python developers. The Python [[term:sdk|SDK]] is one of the OpenAPI SDKs ([[page:reference/sdk]]): it is generated from the [[page:api|OpenAPI document]], like the PHP SDK, and is published on the private index `https://pypi.bim.works/simple/`. Your company portal has the credentials, or ask support@bimbase.nl.

## Before you start

- Python 3 and one of uv, Poetry or pip.
- Credentials for `https://pypi.bim.works`.

## 1. Pin the package to the BIM.works index

The client depends on public packages (pydantic, urllib3 and a few more), so pypi.org stays configured as well. Your tool must take `bimworks` itself from the BIM.works index only: a tool that merges what both indexes offer installs whichever has the highest version, and a look-alike package on another index would then win. Each of the three setups below pins the package; never use a bare `--extra-index-url` for it.

### uv

```text {#uv}
[project]
dependencies = ["bimworks==3.0.0"]

[[tool.uv.index]]
name = "bimworks"
url = "https://pypi.bim.works/simple/"
explicit = true

[tool.uv.sources]
bimworks = { index = "bimworks" }
```

`explicit = true` means only packages that name the index come from it. Give uv the credentials in the environment (or in `~/.netrc`):

```shell {#uv-credentials}
export UV_INDEX_BIMWORKS_USERNAME='[your username]'
export UV_INDEX_BIMWORKS_PASSWORD='[your password]'
uv sync
```

`uv.lock` records the file's address and hash; commit it.

### Poetry

```text {#poetry}
[[tool.poetry.source]]
name = "bimworks"
url = "https://pypi.bim.works/simple/"
priority = "explicit"

[tool.poetry.dependencies]
bimworks = { version = "3.0.0", source = "bimworks" }
```

```shell {#poetry-credentials}
poetry config http-basic.bimworks '[your username]' '[your password]'
```

### pip

pip cannot pin one package to one index. Use a requirements file in which every line carries the hash of the file it allows, made against the BIM.works index (for example with `pip-compile --generate-hashes` from pip-tools), so that any other file is refused. Keep the credentials in `~/.netrc` rather than in the index address:

```text {#netrc}
machine pypi.bim.works
login [your username]
password [your password]
```

```shell {#pip}
pip install --require-hashes --index-url https://pypi.bim.works/simple/ --extra-index-url https://pypi.org/simple/ -r requirements.txt
```

## 2. Pick the version

Use the version that matches your BIM.works server (the version pill at the top of this page is the server's), written the Python way: `3.0.0-b.120` is `3.0.0b120`. pip and uv skip pre-releases unless you name the exact version or allow them (`pip install --pre`, `uv add --prerelease allow`); Poetry needs `allow-prereleases = true` on the dependency.

## Check

```shell {#check}
python -c "import bimworks; print(bimworks.__version__)"
```

It prints the version you installed. Then run the program below: it logs in with your [[term:api-token|API token]] and prints the UUID of your root node. Every example of the Python SDK has these four steps ([[page:reference/sdk/python#example-shape]]).

```sdk-example {#check-login}
operation: GetRootNodeUuid
languages: python
```

Next: [[page:how-to/auth/log-in-with-an-api-token]].
