Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 56 additions & 16 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,63 @@
C64 Emulator Package
"""

__version__ = "0.1.0"
from __future__ import annotations

from .emulator import C64
from .cpu import CPU6502
from .memory import MemoryMap
from .cpu_state import CPUState, CIATimer
from .debug import UdpDebugLogger
from .ui import TextualInterface
from .server import EmulatorServer
from typing import TYPE_CHECKING, Any

__version__ = "1.0.1"

__all__ = [
'C64',
'CPU6502',
'MemoryMap',
'CPUState',
'CIATimer',
'UdpDebugLogger',
'TextualInterface',
'EmulatorServer',
"C64",
"CPU6502",
"MemoryMap",
"CPUState",
"CIATimer",
"UdpDebugLogger",
"TextualInterface",
"EmulatorServer",
]

if TYPE_CHECKING:
from .cpu import CPU6502
from .cpu_state import CPUState, CIATimer
from .debug import UdpDebugLogger
from .emulator import C64
from .server import EmulatorServer
from .ui import TextualInterface


def __getattr__(name: str) -> Any:
if name == "C64":
from .emulator import C64

return C64
if name == "CPU6502":
from .cpu import CPU6502

return CPU6502
if name == "MemoryMap":
from .memory import MemoryMap

return MemoryMap
if name == "CPUState":
from .cpu_state import CPUState

return CPUState
if name == "CIATimer":
from .cpu_state import CIATimer

return CIATimer
if name == "UdpDebugLogger":
from .debug import UdpDebugLogger

return UdpDebugLogger
if name == "TextualInterface":
from .ui import TextualInterface

return TextualInterface
if name == "EmulatorServer":
from .server import EmulatorServer

return EmulatorServer
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
3 changes: 2 additions & 1 deletion emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
from .debug import UdpDebugLogger
from .memory import MemoryMap
from .roms import REQUIRED_ROMS
from .ui import TextualInterface
from .iec_bus import IECBus
from .drives.tcp_drive_client import TcpDriveClient
from .drives.iec_backend import IECDriveBackend
Expand Down Expand Up @@ -121,6 +120,8 @@ def __init__(
rust_hybrid_vic = vic_emulation == "accurate-rust"
self.memory = MemoryMap()
if interface_factory is None:
from .ui import TextualInterface

self.interface = TextualInterface(self)
else:
self.interface = interface_factory(self)
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "c64py"
version = "0.1.0"
version = "1.0.1"
description = "A Commodore 64 emulator implemented in Python with a text-based interface."
readme = "README.md"
requires-python = ">=3.9"
Expand All @@ -18,7 +18,7 @@ dependencies = [
"tomli>=2.0.0; python_version<\"3.11\"",
]
classifiers = [
"Development Status :: 3 - Alpha",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
Expand All @@ -29,7 +29,7 @@ classifiers = [
]

[project.urls]
Homepage = "https://github.com/luar/c64py"
Homepage = "https://github.com/cyberplant/c64py"

[project.scripts]
c64py = "c64py.C64:main"
Expand Down
6 changes: 3 additions & 3 deletions rust/c64py-core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/c64py-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "c64py_rust_core"
version = "0.1.0"
version = "1.0.1"
edition = "2021"
Comment thread
cyberplant marked this conversation as resolved.
rust-version = "1.83"
description = "Optional native fast-path core for c64py (PyO3 extension)"
Expand Down
27 changes: 27 additions & 0 deletions test/test_headless_imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Headless import guards (PyPy Docker smoke test has no textual/pygame)."""

from __future__ import annotations

import builtins
import importlib


def _block_textual_import(name, *args, **kwargs):
if name == "textual" or name.startswith("textual."):
raise AssertionError(f"unexpected textual import: {name!r}")
return _REAL_IMPORT(name, *args, **kwargs)


_REAL_IMPORT = builtins.__import__


def test_c64py_config_import_without_textual(monkeypatch) -> None:
monkeypatch.setattr(builtins, "__import__", _block_textual_import)
importlib.import_module("c64py.config")


def test_emulator_headless_factory_without_textual(monkeypatch) -> None:
monkeypatch.setattr(builtins, "__import__", _block_textual_import)
from c64py.emulator import C64

C64(interface_factory=lambda _emu: None, vic_emulation="fast")
Loading