Skip to content

Commit

Permalink
Correct Earhtly setup file. Extend documentation on its use.
Browse files Browse the repository at this point in the history
Remove preinstalled packages, and use the ones from pyproject instead.
Allow to use podman/docker on user choosing.
  • Loading branch information
szszszsz committed Dec 7, 2022
1 parent ba09737 commit 44437a0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
11 changes: 4 additions & 7 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ build:
RUN apt update && apt install python3 python3-dev make python3-pip python3.10-venv libpcsclite-dev swig -qy
RUN apt install libusb-1.0-0-dev -qy
RUN python3 -m pip install -U pip
RUN python3 -m pip install -U flit pyusb cffi ecdsa intelhex nkdfu python-dateutil requests tqdm urllib3 tlv8
RUN python3 -m pip install -U "nrfutil >=6.1.4,<7"
RUN python3 -m pip install -U "spsdk >=1.7.0,<1.8.0"
RUN python3 -m pip install -U "cryptography >=3.4.4,<37"


# COPY Makefile pynitrokey/ pyproject.toml README.md .
RUN python3 -m pip install -U flit
RUN mkdir pynitrokey
COPY pyproject.toml README.md .
RUN python3 -m flit install --only-deps
COPY . .
RUN make clean
RUN make init
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ init-fedora37:
init: update-venv

ARGS=
.PHONY: run rune
.PHONY: run rune builde
run:
./venv/bin/nitropy $(ARGS)

DOCKER=docker
rune:
podman run --privileged --rm -it --entrypoint /bin/bash pynitrokey
$(DOCKER) run --privileged --rm -it --entrypoint /bin/bash pynitrokey

builde:
earthly +build
Expand Down Expand Up @@ -146,4 +147,3 @@ wine-build/pynitrokey-$(VERSION).msi wine-build/nitropy-$(VERSION).exe:
bash build-wine.sh
#cp wine-build/out/pynitrokey-$(VERSION)-win32.msi wine-build
cp wine-build/out/nitropy-$(VERSION).exe wine-build

19 changes: 19 additions & 0 deletions docs/developer-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ Setting Up The Environment

Use ``make init`` to install ``pynitrokey``, its dependencies and the development tools inside a virtual environment in the ``venv`` folder. This virtual environment is also used by other targets in the Makefile like ``make check``. ``pynitrokey`` is installed in editable mode so that all changes to the source code also apply to the ``nitropy`` executable in the virtual environment. If dependencies are changed, run ``make update-venv`` to update the virtual environment.


By default the development environment is isolated using venv, when set up using ``make init``. To run the ``nitropy`` from there call ``./venv/bin/nitropy``. This can be used as a shortcut ``make run ARGS="nk3 list"``, where ``ARGS`` is an optional argument to pass to ``nitropy``.


Containerized Environment
--------------------

Setting up a proper environment, matching the exact Python version, or having a newer one than it is supported, might be problematic for the development.
For such cases it is handy to have development/test environment containerized, so it does not affect nor need changes in the host OS internals.
For that Earthly tool is used, but any Docker-like tool will work.

The common targets are listed in the main Makefile with the ``e`` suffix:

- ``make builde`` - executes Earthly build process for the pynitrokey container image;
- ``make rune`` - runs Docker container based on the pynitrokey image for a quick tests. Use ``DOCKER=podman`` to call ``podman`` binary instead of the default Docker.

See https://earthly.dev/ for the Earthly setup instructions. Mind, that their binaries currently are not signed and cannot be verified, thus installation to the root directory of the host OS is not advised (on contrary to the claims on their main page). Use Dockerfile directly instead if in doubt.


Linters
-------

Expand Down
2 changes: 1 addition & 1 deletion pynitrokey/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging
import os
import pathlib
import secrets
from functools import partial

import pytest
import secrets
from _pytest.fixtures import FixtureRequest

from pynitrokey.cli.nk3 import Context
Expand Down

0 comments on commit 44437a0

Please sign in to comment.