From 3cbeefa15d4c2a1771d39f4ac03cc50fab5fd49e Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Thu, 21 Dec 2023 13:06:45 +0200 Subject: [PATCH 1/2] Convert build to Hatch Co-authored-by: Ofek Lev Co-authored-by: Pierre Fersing Signed-off-by: Aarni Koskela --- MANIFEST.in | 10 ------- Makefile | 8 +++--- README.rst | 2 +- pyproject.toml | 74 +++++++++++++++++++++++++++++++++++++++++++++++- requirements.txt | 1 - setup.cfg | 8 ------ setup.py | 57 ------------------------------------- tox.ini | 2 +- 8 files changed, 79 insertions(+), 83 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 47e30838..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,10 +0,0 @@ -include edl-v10 epl-v20 -include README.rst -include CONTRIBUTING.md -include setup.py -include notice.html -include LICENSE.txt -include about.html - -recursive-include src *.py -recursive-include examples *.py diff --git a/Makefile b/Makefile index 16cc9179..52672ee5 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,9 @@ PYTHON?=python3 .PHONY : all clean clean-build clean-pyc clean-test install test upload all : - $(PYTHON) ./setup.py build install : all - $(PYTHON) ./setup.py install --root=${DESTDIR} + $(PYTHON) -m pip install -e . clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts @@ -32,8 +31,9 @@ clean-test: ## remove test and coverage artifacts rm -fr htmlcov/ test : - $(PYTHON) setup.py test + $(PYTHON) -m pytest . $(MAKE) -C test test upload : test - $(PYTHON) ./setup.py sdist upload + $(PYTHON) -m hatch build + $(PYTHON) -m hatch publish diff --git a/README.rst b/README.rst index b5f51424..b6eef0e8 100644 --- a/README.rst +++ b/README.rst @@ -67,7 +67,7 @@ Once you have the code, it can be installed from your repository as well: :: cd paho.mqtt.python - python setup.py install + pip install -e . To perform all test (including MQTT v5 test), you also need to clone paho.mqtt.testing in paho.mqtt.python folder:: diff --git a/pyproject.toml b/pyproject.toml index 54f37420..35347905 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,75 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "paho-mqtt" +dynamic = ["version"] +description = "MQTT version 5.0/3.1.1 client class" +readme = "README.rst" +# see https://lists.spdx.org/g/Spdx-legal/topic/request_for_adding_eclipse/67981884 +# for why Eclipse Distribution License v1.0 is listed as BSD-3-Clause +license = "EPL-2.0 OR BSD-3-Clause" +requires-python = ">=3.7" +authors = [ + { name = "Roger Light", email = "roger@atchoo.org" }, +] +keywords = [ + "paho", +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved", + "Natural Language :: English", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Communications", + "Topic :: Internet", +] +dependencies = [] + +[project.optional-dependencies] +proxy = [ + "PySocks", +] + +[project.urls] +Homepage = "http://eclipse.org/paho" + +[tool.hatch.version] +path = "src/paho/mqtt/__init__.py" + +[tool.hatch.build.targets.sdist] +include = [ + "src/paho", + "/examples", + "/tests", + "about.html", + "CONTRIBUTING.md", + "edl-v10", + "epl-v20", + "LICENSE.txt", + "notice.html", + "README.rst", +] + +[tool.hatch.build.targets.wheel] +packages = [ + "src/paho", +] + +[tool.pytest.ini_options] +addopts = ["-r", "xs"] +testpaths = "tests src" + [tool.ruff] line-length = 167 @@ -28,4 +100,4 @@ extend-select = [ "F841", "I", "S", -] +] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 4a81f733..3d97aec2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ pylama==7.7.1 pytest==5.2.2; python_version >= '3.0' -pytest-runner==5.2 tox==3.14.0 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 71ce170d..00000000 --- a/setup.cfg +++ /dev/null @@ -1,8 +0,0 @@ -[aliases] -test=pytest -[tool:pytest] -addopts=-r xs -testpaths=tests src -[pylama] -linters=pyflakes -skip=tests/* diff --git a/setup.py b/setup.py deleted file mode 100644 index f00ceb43..00000000 --- a/setup.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import sys - -from setuptools import find_packages, setup - -sys.path.insert(0, 'src') -from paho.mqtt import __version__ - -with open('README.rst', 'rb') as readme_file: - readme = readme_file.read().decode('utf-8') - -requirements = [] -test_requirements = ['pytest', 'pylama'] -needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv) -setup_requirements = ['pytest-runner'] if needs_pytest else [] -extra_requirements = {'proxy': ['PySocks']} - -setup( - name='paho-mqtt', - version=__version__, - description='MQTT version 5.0/3.1.1 client class', - long_description=readme, - author='Roger Light', - author_email='roger@atchoo.org', - url='http://eclipse.org/paho', - packages=find_packages('src'), - package_dir={'': 'src'}, - include_package_data=True, - install_requires=requirements, - python_requires='>=3.7', - license='Eclipse Public License v2.0 / Eclipse Distribution License v1.0', - zip_safe=False, - keywords='paho', - classifiers=[ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'License :: OSI Approved', - 'Operating System :: MacOS :: MacOS X', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX', - 'Natural Language :: English', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Topic :: Communications', - 'Topic :: Internet', - ], - test_suite='tests', - tests_require=test_requirements, - setup_requires=setup_requirements, - extras_require=extra_requirements -) diff --git a/tox.ini b/tox.ini index e45da21e..5d190e17 100644 --- a/tox.ini +++ b/tox.ini @@ -11,7 +11,7 @@ allowlist_externals = make commands = ruff . - python setup.py test + pytest make -C test test [testenv:lint] From 8da0ff98f7be0da6e1615baee6993d1c8fec9b7e Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Thu, 21 Dec 2023 13:07:52 +0200 Subject: [PATCH 2/2] CI: add workflow to build package Signed-off-by: Aarni Koskela --- .github/workflows/build.yml | 16 ++++++++++++++++ pyproject.toml | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..3d35af11 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,16 @@ +name: build +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: 3 + - run: pip install build + - run: python -m build . + - uses: actions/upload-artifact@v4 + with: + name: dist + path: dist diff --git a/pyproject.toml b/pyproject.toml index 35347905..c70ec7b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,7 +62,8 @@ include = [ ] [tool.hatch.build.targets.wheel] -packages = [ +sources = ["src"] +include = [ "src/paho", ]