Skip to content

Commit 6eb6554

Browse files
nehalkpatelclaude
andauthored
Restructure Python package to follow best practices (#22)
Reorganize the Python emulator to follow Python Packaging Authority (PyPA) guidelines and the "src layout" pattern. This makes the package structure more professional, standard, and maintainable. Changes: - Move Python modules from src/ to src/host_emulator/ - Update package configuration in pyproject.toml with explicit package location - Update all imports from "from src import" to "from host_emulator import" - Maintain proper src layout to prevent accidental import of development version New structure: py/host-emulator/ ├── src/ │ └── host_emulator/ ← Proper package name (underscores for Python) │ ├── __init__.py │ ├── common.py │ ├── emulator.py │ ├── i2c.py │ ├── pin.py │ └── uart.py ├── tests/ └── pyproject.toml This structure follows: - PEP 420 (Implicit Namespace Packages) - PyPA packaging best practices - Src layout pattern for proper isolation All 29 tests continue to pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 63520fd commit 6eb6554

9 files changed

Lines changed: 3 additions & 3 deletions

File tree

py/host-emulator/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version = "0.1.0"
44
description = ""
55
authors = ["Nehal Patel <hereisnehal@gmail.com>"]
66
readme = "README.md"
7+
packages = [{include = "host_emulator", from = "src"}]
78

89
[tool.poetry.dependencies]
910
python = "^3.11"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

py/host-emulator/tests/conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import pathlib
22
import subprocess
33

4+
from host_emulator import DeviceEmulator
45
from pytest import fixture
56

6-
from src import DeviceEmulator
7-
87

98
def pytest_addoption(parser):
109
parser.addoption(

py/host-emulator/tests/test_blinky.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from time import sleep
22

3-
from src import Pin
3+
from host_emulator import Pin
44

55
pin_stats = {}
66

0 commit comments

Comments
 (0)