Repository: zpieslak/mobilus-client (language: python)

Issue:
Create PyPI package
Create a package and deploy it to pypi


Discussion / hints:

Fix patch:
diff --git a/.coveragerc b/.coveragerc
deleted file mode 100644
index be3ebb0..0000000
--- a/.coveragerc
+++ /dev/null
@@ -1,8 +0,0 @@
-[report]
-exclude_lines =
-    @abstractmethod
-
-[run]
-omit =
-    */proto/*
-    tests/*
diff --git a/.gitignore b/.gitignore
index 62f8624..07d6cae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 __pycache__
 tmp
 .coverage
+.tool-versions
diff --git a/.mypy.ini b/.mypy.ini
deleted file mode 100644
index 3eb4b6b..0000000
--- a/.mypy.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[mypy]
-strict = True
-
-[mypy-factory]
-ignore_missing_imports = True
diff --git a/README.md b/README.md
index 28b0ca7..53e8931 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 ## Mobilus Cosmo GTW Client
 
-![test workflow](https://github.com/zpieslak/mobilus-client-private/actions/workflows/test.yml/badge.svg)
+![test workflow](https://github.com/zpieslak/mobilus-client/actions/workflows/test.yml/badge.svg)
 
 This code provides a native Python client for the Mobilus Cosmo GTW. It connects directly to the gateway's MQTT broker and sends message commands to control the associated devices. The connection is established locally, so the client must be run on the same network as the gateway. Currently, the only tested and supported devices are radio shutters (Mobilus COSMO 2WAY).
 
@@ -10,9 +10,9 @@ More information can be found on [blog post](https://codegyver.com/2024/09/22/mo
 
 ## Installation
 
-Install the required dependencies using pip:
+Install the module with pip:
 
-    pip install -r requirements.txt
+    pip install mobilus-client
 
 ## Usage
 
@@ -53,11 +53,17 @@ Verbose mode can be enabled with the `--verbose` flag:
 
 The client is tested with Mobilus Cosmo GTW with shutter devices only (COSMO 2WAY). It is possible that it will work with other devices, but it is not guaranteed. The purpose of the client is to provide a simple way to control the devices without the need to use the official Mobilus Cosmo GTW web interface or app, and to integrate it with open-source systems like Home Assistant. I am not affiliated with Mobilus, and the client is provided as is.
 
-## Running the tests
+## Development
 
-Install test requirements:
+Clone the repository and navigate to the project directory.
+Install the package in editable mode with the following command:
 
-    pip install -r requirements-test.txt
+    pip install -e .[test]
+
+Check mypy and flake8 with the following commands:
+
+    mypy .
+    flake8 .
 
 The tests can be run with the following command:
 
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..b32fee7
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,59 @@
+[build-system]
+requires = ["hatchling", "hatch-vcs"]
+build-backend = "hatchling.build"
+
+[project]
+name = "mobilus-client"
+dynamic = ["version"]
+description = "Python client for Mobilus Cosmo GTW"
+readme = "README.md"
+license = { file = "LICENSE" }
+authors = [{ name = "Zbigniew Pieślak", email = "zpieslak@gmail.com" }]
+dependencies = [
+    "paho-mqtt~=1.6.0",
+    "cryptography~=43.0",
+    "protobuf==5.28.1",
+]
+requires-python = ">=3.9"
+
+[project.optional-dependencies]
+test = [
+    "coverage~=7.0",
+    "factory-boy~=2.0",
+    "flake8~=7.0",
+    "mypy~=1.0",
+    "mypy-protobuf~=3.0",
+    "types-paho-mqtt~=1.0",
+    "types-protobuf~=5.28.0",
+]
+
+[project.urls]
+homepage = "https://github.com/zpieslak/mobilus-client"
+issues = "https://github.com/zpieslak/mobilus-client/issues"
+
+[tool.hatch.version]
+source = "vcs"
+
+[tool.hatch.build]
+exclude = [
+    ".*",
+    "tests/*",
+]
+
+[tool.mypy]
+strict = true
+
+[[tool.mypy.overrides]]
+module = "factory"
+ignore_missing_imports = true
+
+[tool.coverage.run]
+omit = [
+    "*/proto/*",
+    "tests/*",
+]
+
+[tool.coverage.report]
+exclude_lines = [
+    "@abstractmethod",
+]
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644
index b949548..0000000
--- a/requirements.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-paho-mqtt==1.6.1
-cryptography==43.0.1
-protobuf==5.28.1


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 24cddab..5209048 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -23,7 +23,7 @@ jobs:
       with:
         python-version: ${{ matrix.python-version }}
     - name: Install dependencies
-      run: pip install -r requirements.txt -r requirements_test.txt
+      run: pip install -e .[test]
     - name: Lint with flake8
       run: flake8 . --count --statistics
     - name: Lint with mypy
diff --git a/requirements_test.txt b/requirements_test.txt
deleted file mode 100644
index 98067db..0000000
--- a/requirements_test.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-coverage==7.6.1
-factory-boy==2.12.0
-flake8==7.1.1
-mypy==1.11.2
-mypy-protobuf==3.6.0
-types-paho-mqtt==1.6.0.20240321
-types-protobuf==5.27.0.20240907