Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@ jobs:
fail-fast: false
matrix:
python: ["3.11", "3.12", "3.13", "3.14"]
env:
UV_PYTHON: ${{ matrix.python }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v2
with:
python-version: "${{ matrix.python }}"

- name: Install pipenv
run: make get-pipenv
- name: Setup uv
uses: astral-sh/setup-uv@v6

- name: Install dependencies
run: make install-deps
Expand All @@ -36,18 +33,10 @@ jobs:
runs-on: "ubuntu-latest"
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- uses: actions/checkout@v2

- name: Setup python
uses: actions/setup-python@v2
with:
python-version: "3.11"

- name: Install pipenv
run: make get-pipenv
- uses: actions/checkout@v4

- name: Install dependencies
run: make install-deps
- name: Setup uv
uses: astral-sh/setup-uv@v6

- name: Publish to PyPI
run: make upload-to-pypi
Expand Down
8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Pipfile.lock
dist.tar

# What follows is based on
Expand Down Expand Up @@ -93,13 +92,6 @@ ipython_config.py
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
Expand Down
3 changes: 0 additions & 3 deletions .isort.cfg

This file was deleted.

1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
17 changes: 13 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
FROM python:3.14

COPY --from=ghcr.io/astral-sh/uv:0.12.17 /uv /uvx /bin/

WORKDIR /app

ADD README.md README.md
ADD setup.py setup.py
ADD src src
COPY pyproject.toml pyproject.toml
COPY uv.lock uv.lock

RUN uv export --frozen --no-dev --no-emit-project -o requirements.txt \
&& uv pip install --system -r requirements.txt

COPY README.md README.md
COPY LICENSE LICENSE
COPY src src

RUN pip install . && rm README.md && rm setup.py && rm -rf src
RUN uv pip install --system --no-deps . \
&& rm -rf src pyproject.toml uv.lock README.md LICENSE requirements.txt

STOPSIGNAL SIGINT

Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022-2026 Enapter

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 13 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ default:

.PHONY: install-deps
install-deps:
pipenv install --dev
uv sync

.PHONY: update-deps
update-deps:
pipenv update --dev
uv sync --upgrade

.PHONY: check
check: lint test
Expand All @@ -17,54 +17,47 @@ lint: lint-black lint-isort lint-pyflakes lint-mypy

.PHONY: lint-black
lint-black:
pipenv run black --check --diff .
uv run black --check --diff .

.PHONY: lint-isort
lint-isort:
pipenv run isort --check .
uv run isort --check .

.PHONY: lint-pyflakes
lint-pyflakes:
pipenv run pyflakes .
uv run pyflakes src tests examples

.PHONY: lint-mypy
lint-mypy:
pipenv run mypy setup.py
pipenv run mypy tests
pipenv run mypy src/enapter
uv run mypy tests
uv run mypy src/enapter

.PHONY: test
test: test-unit test-integration

.PHONY: test-unit
test-unit:
pipenv run pytest -vv --cov --cov-report term-missing tests/unit
uv run pytest -vv --cov=enapter --cov-report term-missing tests/unit

.PHONY: test-integration
test-integration:
pipenv run pytest -vv --capture=no tests/integration

.PHONY: get-pipenv
get-pipenv:
curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python
uv run pytest -vv --capture=no tests/integration

.PHONY: upload-to-pypi
upload-to-pypi: dist
ifndef PYPI_API_TOKEN
$(error PYPI_API_TOKEN is not defined)
endif
@pipenv run twine upload \
--username __token__ \
--password $(PYPI_API_TOKEN) \
$</*
@UV_PUBLISH_TOKEN=$(PYPI_API_TOKEN) uv publish $</*

dist.tar: dist
rm --force $@
tar --create --file $@ $<

.PHONY: dist
dist:
pipenv run python setup.py bdist_wheel
rm -rf dist
uv build

RE_SEMVER = [0-9]+.[0-9]+.[0-9]+(-[a-z0-9]+)?

Expand All @@ -74,6 +67,7 @@ ifndef V
$(error V is not defined)
endif
sed -E -i 's/__version__ = "$(RE_SEMVER)"/__version__ = "$(V)"/g' src/enapter/__init__.py
uv lock
grep -E --files-with-matches --recursive "enapter==$(RE_SEMVER)" README.md examples \
| xargs -n 1 sed -E -i "s/enapter==$(RE_SEMVER)/enapter==$(V)/g"
git add .
Expand Down
22 changes: 0 additions & 22 deletions Pipfile

This file was deleted.

13 changes: 0 additions & 13 deletions opencode.json

This file was deleted.

53 changes: 53 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[project]
name = "enapter"
description = "Enapter Python SDK"
readme = "README.md"
license = "MIT"
license-files = ["LICENSE"]
requires-python = ">=3.11"
authors = [
{ name = "Roman Novatorov", email = "rnovatorov@enapter.com" },
]
dependencies = [
"aiomqtt==2.5.*",
"dnspython==2.8.*",
"json-log-formatter==1.1.*",
"httpx==0.28.*",
]
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/Enapter/python-sdk"

[dependency-groups]
dev = [
"black",
"docker",
"isort",
"mypy",
"pyflakes",
"pytest",
"pytest-asyncio",
"pytest-cov",
"types-docker",
]

[build-system]
requires = ["setuptools>=77"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
package-dir = {"" = "src"}

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.dynamic]
version = { attr = "enapter.__version__" }

[tool.isort]
profile = "black"
known_first_party = ["enapter"]

[tool.pytest.ini_options]
asyncio_mode = "auto"
3 changes: 0 additions & 3 deletions pytest.ini

This file was deleted.

38 changes: 0 additions & 38 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/enapter/mqtt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(
username: str | None = None,
password: str | None = None,
tls_context: ssl.SSLContext | None = None,
task_group: asyncio.TaskGroup | None = None
task_group: asyncio.TaskGroup | None = None,
) -> None:
super().__init__(task_group=task_group)
self._logger = logging.LoggerAdapter(
Expand Down
Loading
Loading