Skip to content

Commit be81db8

Browse files
Use poetry and dev container
1 parent 44ab70b commit be81db8

10 files changed

+264
-32
lines changed

.gitignore

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
*.pyc
22
*.pyo
3+
34
.idea
5+
.vscode
6+
47
.DS_Store
8+
59
build
610
dist
711
docs/_build
8-
MANIFEST
9-
pylibftdi.egg-info
10-
.coverage
11-
htmlcov
12-
.hg
12+
13+
.venv

.hgignore

-13
This file was deleted.

Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Defines an ubuntu-based dev container for development and testing of pylibftdi
2+
3+
# As well as providing poetry etc, this pre-installs the required libftdi1-2
4+
# package, providing libftdi 1.5 (as of Ubuntu 22.04) and all its dependencies.
5+
6+
FROM ubuntu:22.04
7+
WORKDIR /app
8+
RUN \
9+
apt-get update; \
10+
apt-get install -y libftdi1-2 python3-minimal python3-pip python3-poetry vim; \
11+
ln -s /usr/bin/python3 /usr/bin/python; # Workaround for https://github.com/python-poetry/poetry/issues/6371
12+
13+
# Use in-project venvs so subsequent `poetry install` operations are quick
14+
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
15+
# Required for `poetry shell` to detect the shell
16+
ENV SHELL=/bin/bash
17+
18+
CMD ["bash"]

MANIFEST.in

-2
This file was deleted.

Makefile

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Basic development functions for pylibftdi.
2+
3+
# Example:
4+
# make container && make lint && make test && make build
5+
6+
.PHONY: all
7+
all: container test lint build
8+
9+
.PHONY: container
10+
container:
11+
docker build -t pylibftdi-dev:latest .
12+
13+
.PHONY: build
14+
build:
15+
docker run -t -v $$PWD:/app -w /app pylibftdi-dev:latest poetry build
16+
17+
.PHONY: test
18+
test:
19+
docker run -t -v $$PWD:/app -w /app pylibftdi-dev:latest bash -c 'poetry install && poetry run pytest'
20+
21+
.PHONY: lint
22+
lint:
23+
docker run -t -v $$PWD:/app -w /app pylibftdi-dev:latest bash -c 'poetry install && (poetry run ruff src tests; poetry run mypy src)'
24+
25+
.PHONY: shell
26+
shell:
27+
# Drop into a poetry shell where e.g. `python3 -m pylibftdi.examples.list_devices` etc can be run
28+
docker run -it -v $$PWD:/app -w /app pylibftdi-dev:latest bash -ic 'poetry install && poetry shell'
29+
30+
.PHONY: clean
31+
clean:
32+
# Ideally this would remove all relevant dev containers too...
33+
rm -rf dist/ .venv/

poetry.lock

+179
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+25-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
[project]
1+
[tool.poetry]
22
name = "pylibftdi"
33
version="0.20.0"
4-
readme = "README.rst"
54
description = "Pythonic interface to FTDI devices using libftdi."
5+
license = "MIT"
66
authors = [
7-
{name = "Ben Bass", email = "benbass@codedstructure.net"}
7+
"Ben Bass <benbass@codedstructure.net>",
88
]
9-
license = {file = "LICENSE.txt"}
10-
requires-python = ">=3.7.0"
11-
dependencies = []
9+
readme = "README.rst"
10+
homepage = "https://github.com/codedstructure/pylibftdi"
11+
repository = "https://github.com/codedstructure/pylibftdi"
12+
documentation = "https://pylibftdi.readthedocs.io/en/latest/"
1213
keywords = [
1314
"ftdi",
1415
"libftdi",
@@ -33,17 +34,29 @@ classifiers = [
3334
"Topic :: System :: Hardware",
3435
]
3536

36-
[project.urls]
37-
repository = "https://github.com/codedstructure/pylibftdi"
38-
documentation = "https://pylibftdi.readthedocs.io/en/latest/"
39-
changelog = "https://github.com/codedstructure/pylibftdi/blob/main/CHANGES.txt"
37+
[build-system]
38+
requires = ["poetry-core>=1.0.0"]
39+
build-backend = "poetry.core.masonry.api"
40+
41+
[tool.poetry.dependencies]
42+
python = ">=3.7.0"
4043

41-
[bdist_wheel]
42-
universal = 1
44+
[tool.poetry.dev-dependencies]
45+
pytest = "^7.3.1"
46+
ruff = "^0.0.263"
47+
mypy = "^1.2.0"
4348

4449
[tool.ruff]
4550
select = ["E", "W", "F", "B", "I", "UP", "PL"]
4651
ignore = [
4752
"PLR2004", # Magic value used in comparison
4853
"PLR0913", # Too many arguments to function call
4954
]
55+
56+
[tool.pytest.ini_options]
57+
pythonpath = [
58+
"src", ".",
59+
]
60+
addopts = [
61+
"--import-mode=importlib",
62+
]

tests/test_bitbang.py

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from pylibftdi import FtdiError
1717
from pylibftdi.bitbang import BitBangDevice
18+
1819
from tests.test_common import CallCheckMixin, LoopDevice
1920

2021

tests/test_device.py

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from pylibftdi import FtdiError
1717
from pylibftdi.device import Device
18+
1819
from tests.test_common import CallCheckMixin, LoopDevice
1920

2021
# and now some test cases...

tests/test_serial.py

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import unittest
1515

1616
from pylibftdi.serial_device import SerialDevice
17+
1718
from tests.test_common import CallCheckMixin, LoopDevice
1819

1920

0 commit comments

Comments
 (0)