From 1d5dd7d74601a27b20c9b8490df2174e7c5879a2 Mon Sep 17 00:00:00 2001 From: iamDyeus Date: Tue, 22 Oct 2024 20:20:24 +0530 Subject: [PATCH] fix: Restructure project for PyPI compatibility - Remove src directory to simplify project structure - Move tkreload, setup.py, and requirements.txt to root - Update GitHub workflow for successful PyPI deployment - Adjust tests to reflect new directory structure --- .github/workflows/publish.yaml | 3 --- src/requirements.txt => requirements.txt | 0 src/setup.py => setup.py | 4 ++-- tests/test_app_event_handler.py | 4 ++-- tests/test_auto_reload.py | 2 +- tests/test_file_utils.py | 2 +- tests/test_main.py | 24 +++++++++---------- {src/tkreload => tkreload}/__init__.py | 0 .../app_event_handler.py | 0 {src/tkreload => tkreload}/auto_reload.py | 0 {src/tkreload => tkreload}/file_utils.py | 0 {src/tkreload => tkreload}/help.py | 0 {src/tkreload => tkreload}/main.py | 0 {src/tkreload => tkreload}/progress.py | 0 14 files changed, 18 insertions(+), 21 deletions(-) rename src/requirements.txt => requirements.txt (100%) rename src/setup.py => setup.py (94%) rename {src/tkreload => tkreload}/__init__.py (100%) rename {src/tkreload => tkreload}/app_event_handler.py (100%) rename {src/tkreload => tkreload}/auto_reload.py (100%) rename {src/tkreload => tkreload}/file_utils.py (100%) rename {src/tkreload => tkreload}/help.py (100%) rename {src/tkreload => tkreload}/main.py (100%) rename {src/tkreload => tkreload}/progress.py (100%) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 4552245..8a8139f 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -20,18 +20,15 @@ jobs: python-version: '3.x' - name: Install dependencies - working-directory: src run: | python -m pip install --upgrade pip pip install build twine if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Build package - working-directory: src run: python -m build - name: Publish package to PyPI - working-directory: src env: TWINE_USERNAME: "__token__" TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} diff --git a/src/requirements.txt b/requirements.txt similarity index 100% rename from src/requirements.txt rename to requirements.txt diff --git a/src/setup.py b/setup.py similarity index 94% rename from src/setup.py rename to setup.py index a98a4c2..698ff2f 100644 --- a/src/setup.py +++ b/setup.py @@ -2,12 +2,12 @@ import pathlib # Get the long description from the README file -here = pathlib.Path(__file__).parent.parent.resolve() +here = pathlib.Path(__file__).parent.resolve() long_description = (here / 'README.md').read_text(encoding='utf-8') setup( name='tkreload', - version='1.0.1', + version='1.0.0', description='A library that auto reloads your tkinter app whenever file changes are detected.', long_description=long_description, long_description_content_type='text/markdown', diff --git a/tests/test_app_event_handler.py b/tests/test_app_event_handler.py index 2c8eb6d..92d030a 100644 --- a/tests/test_app_event_handler.py +++ b/tests/test_app_event_handler.py @@ -1,6 +1,6 @@ import unittest -from src.tkreload.app_event_handler import AppFileEventHandler -from src.tkreload.auto_reload import AutoReloadManager +from tkreload.app_event_handler import AppFileEventHandler +from tkreload.auto_reload import AutoReloadManager from unittest.mock import Mock, MagicMock from watchdog.events import FileModifiedEvent from rich.console import Console diff --git a/tests/test_auto_reload.py b/tests/test_auto_reload.py index 2a99e56..4800d63 100644 --- a/tests/test_auto_reload.py +++ b/tests/test_auto_reload.py @@ -3,7 +3,7 @@ import os sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'src'))) -from src.tkreload.auto_reload import AutoReloadManager +from tkreload.auto_reload import AutoReloadManager from rich.console import Console diff --git a/tests/test_file_utils.py b/tests/test_file_utils.py index f45e5e8..e2bdc56 100644 --- a/tests/test_file_utils.py +++ b/tests/test_file_utils.py @@ -2,7 +2,7 @@ import os import sys from unittest.mock import patch -from src.tkreload.file_utils import file_exists, clear_terminal +from tkreload.file_utils import file_exists, clear_terminal class TestFileUtils(unittest.TestCase): diff --git a/tests/test_main.py b/tests/test_main.py index d020773..a488c36 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,6 +1,6 @@ import unittest from unittest.mock import patch, Mock, MagicMock -from src.tkreload.main import TkreloadApp, main +from tkreload.main import TkreloadApp, main from rich.console import Console import sys import time @@ -10,8 +10,8 @@ class TestTkreloadApp(unittest.TestCase): - @patch('src.tkreload.main.subprocess.Popen') - @patch('src.tkreload.main.show_progress') + @patch('tkreload.main.subprocess.Popen') + @patch('tkreload.main.show_progress') def test_run_tkinter_app(self, mock_show_progress, mock_popen): app = TkreloadApp('test_app.py') process = Mock() @@ -22,8 +22,8 @@ def test_run_tkinter_app(self, mock_show_progress, mock_popen): mock_popen.assert_called_once_with([sys.executable, 'test_app.py']) self.assertEqual(result, process) - @patch('src.tkreload.main.Observer') - @patch('src.tkreload.main.AppFileEventHandler') + @patch('tkreload.main.Observer') + @patch('tkreload.main.AppFileEventHandler') def test_monitor_file_changes(self, mock_event_handler, mock_observer): app = TkreloadApp('test_app.py') mock_callback = Mock() @@ -33,8 +33,8 @@ def test_monitor_file_changes(self, mock_event_handler, mock_observer): mock_observer().schedule.assert_called_once() mock_observer().start.assert_called_once() - @patch('src.tkreload.main.time.sleep', side_effect=KeyboardInterrupt) - @patch('src.tkreload.main.subprocess.Popen') + @patch('tkreload.main.time.sleep', side_effect=KeyboardInterrupt) + @patch('tkreload.main.subprocess.Popen') def test_start_keyboard_interrupt(self, mock_popen, mock_sleep): app = TkreloadApp('test_app.py') mock_process = Mock() @@ -45,17 +45,17 @@ def test_start_keyboard_interrupt(self, mock_popen, mock_sleep): mock_process.terminate.assert_called_once() - @patch('src.tkreload.main.sys.argv', ['tkreload', 'test_app.py']) - @patch('src.tkreload.main.file_exists', return_value=True) - @patch('src.tkreload.main.TkreloadApp') + @patch('tkreload.main.sys.argv', ['tkreload', 'test_app.py']) + @patch('tkreload.main.file_exists', return_value=True) + @patch('tkreload.main.TkreloadApp') def test_main_function(self, mock_tkreload_app, mock_file_exists): main() mock_file_exists.assert_called_once_with('test_app.py') mock_tkreload_app.assert_called_once_with('test_app.py') mock_tkreload_app().start.assert_called_once() - @patch('src.tkreload.main.sys.argv', ['tkreload']) - @patch('src.tkreload.main.Console') + @patch('tkreload.main.sys.argv', ['tkreload']) + @patch('tkreload.main.Console') def test_main_function_no_file_provided(self, mock_console): with self.assertRaises(SystemExit): main() diff --git a/src/tkreload/__init__.py b/tkreload/__init__.py similarity index 100% rename from src/tkreload/__init__.py rename to tkreload/__init__.py diff --git a/src/tkreload/app_event_handler.py b/tkreload/app_event_handler.py similarity index 100% rename from src/tkreload/app_event_handler.py rename to tkreload/app_event_handler.py diff --git a/src/tkreload/auto_reload.py b/tkreload/auto_reload.py similarity index 100% rename from src/tkreload/auto_reload.py rename to tkreload/auto_reload.py diff --git a/src/tkreload/file_utils.py b/tkreload/file_utils.py similarity index 100% rename from src/tkreload/file_utils.py rename to tkreload/file_utils.py diff --git a/src/tkreload/help.py b/tkreload/help.py similarity index 100% rename from src/tkreload/help.py rename to tkreload/help.py diff --git a/src/tkreload/main.py b/tkreload/main.py similarity index 100% rename from src/tkreload/main.py rename to tkreload/main.py diff --git a/src/tkreload/progress.py b/tkreload/progress.py similarity index 100% rename from src/tkreload/progress.py rename to tkreload/progress.py