Working with the code

Install dependencies

It’s assumed a Python 3 environment with pip is installed. Additionally, the project uses poetry as its build tool; install that as well.

Windows

Make sure the swig executable is in your PATH.

macOS

brew install swig

Linux (Debian-based distributions)

sudo apt install swig libu2f-udev pcscd libpcsclite-dev

Install yubikey-manager from source

Clone the repository:

git clone https://github.com/Yubico/yubikey-manager.git
cd yubikey-manager

Install via poetry:

poetry install

Show available commands:

poetry run ykman --help

Show information about inserted YubiKey:

poetry run ykman info

Run ykman in DEBUG mode:

poetry run ykman --log-level DEBUG info

Code Style & Security

This project uses Black and Flake8 for code style, mypy for static type checking, and Bandit for security linting. These are invoked with a pre-commit hook.

To use these:

pip install pre-commit black flake8 bandit mypy
pre-commit install

Unit tests

To run unit tests:

poetry run pytest

Integration tests

Warning
ONLY run these on dedicated developer keys, as it will permanently delete data on the device(s)!

To run integration tests, indicate the serial number (given by ykman list) of the YubiKey to test with. Make sure no other YubiKey is connected when running the test!

poetry run pytest --device 123456

To run the tests over NFC, place the YubiKey to test on an NFC reader, and indicate both the reader and the serial number of the YubiKey:

poetry run pytest --reader HID --device 123456

The integration test suite will automatically identify which test cases can be run with the attached YubiKey.

Packaging

For third-party packaging, use the source releases and signatures available here.