Skip to content

Commit

Permalink
fix: Restructure project for PyPI compatibility
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
iamDyeus committed Oct 22, 2024
1 parent f406c64 commit 1d5dd7d
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 21 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/setup.py → setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions tests/test_app_event_handler.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_auto_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion tests/test_file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
24 changes: 12 additions & 12 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 1d5dd7d

Please sign in to comment.