Skip to content

Make compiler and assistant proper packages - #16

Merged
s0undsystem merged 1 commit into
mainfrom
refactor/package-layout
Aug 5, 2026
Merged

Make compiler and assistant proper packages#16
s0undsystem merged 1 commit into
mainfrom
refactor/package-layout

Conversation

@s0undsystem

Copy link
Copy Markdown
Owner

Closes #13. Reported by @jim-t-trevenx in #6.

compiler/ had no __init__.py, so reaching it meant putting the directory on sys.path, which both assistant/validator.py and tests/test_compiler.py did. That works until it doesn't: with compiler/ on the path, compile.py is a top-level module named compile, shadowing the builtin for anything that imports it.

What changed

Adds compiler/__init__.py and pyproject.toml. The compiler is now importable as compiler.compile, so the name cannot collide with the builtin, and neither consumer manipulates sys.path to find it. The tests keep a single sys.path entry pointing at the repo root, which is ordinary for running tests without installing, and pip install -e . makes even that redundant.

Nothing that worked before stops working. compile.py tries the package-relative import first and falls back to flat imports when executed as a script, so python compiler/compile.py still runs for the four workflows, the README, and anyone with the habit. python -m compiler.compile and a dlpac-compile console script are the tidier ways in.

requirements.txt now contains -e . instead of restating dependencies. pyproject.toml becomes the single place a version is pinned, and every existing pip install -r requirements.txt (four workflows, README, CONTRIBUTING) installs the project without any of them needing to change. anthropic stays optional, behind a claude extra.

Why this is worth doing

Not correctness, since nothing was broken. Distribution. An installable package is how someone tries this without cloning the repo, which is why I labelled the issue enhancement rather than bug.

Verification

Check Result
python compiler/compile.py (backwards compat) 5 policies
python -m compiler.compile 5 policies
dlpac-compile (console script) 5 policies
tests/test_compiler.py 13/13
tests/test_assistant.py 12/12
DLPAC_BRAIN=dry-run python -m assistant.eval 2/2 drafts
Package imports from a cwd outside the repo OK
import compile resolves to this project No longer possible
Builtin compile() Intact

Test-merged against both open PRs (#14, #15) with no conflicts, and the combined tree passes 18/18 compiler and 12/12 assistant tests.

Closes #13.

compiler/ had no __init__.py, so reaching it meant putting the directory on
sys.path, which assistant/validator.py and tests/test_compiler.py both did. That
works until it doesn't: with compiler/ on the path, compile.py is a top-level
module named `compile`, shadowing the builtin for anything that imports it.

Adds compiler/__init__.py and pyproject.toml. The compiler is now importable as
`compiler.compile`, so the name cannot collide with the builtin, and neither
consumer manipulates sys.path to find it. tests keep one sys.path entry pointing
at the repo root, which is ordinary for running tests without installing, and
`pip install -e .` makes even that redundant.

compile.py still runs directly. It tries the package-relative import first and
falls back to flat imports when executed as a script, so `python
compiler/compile.py` keeps working for the four workflows, the README, and anyone
with the habit. `python -m compiler.compile` and a `dlpac-compile` console script
are the tidier ways in.

requirements.txt now contains `-e .` rather than restating the dependencies.
pyproject.toml is the single place a version is pinned, and every existing
`pip install -r requirements.txt` (four workflows, README, CONTRIBUTING) installs
the project without any of them needing to change. anthropic stays optional,
behind the `claude` extra.

The immediate benefit is distribution rather than correctness, since nothing was
actually broken: an installable package is how someone tries this without
cloning.

Verified: compile succeeds via script, module, and console script; 13/13 compiler
tests; 12/12 assistant tests; assistant dry-run eval 2/2; package imports from a
directory outside the repo; `import compile` no longer resolves to this project;
builtin compile() intact. Test-merged against both open PRs with no conflicts,
and the combined tree passes 18/18 and 12/12.
@s0undsystem
s0undsystem merged commit 448bcfb into main Aug 5, 2026
1 of 2 checks passed
@s0undsystem
s0undsystem deleted the refactor/package-layout branch August 5, 2026 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sys.path manipulation instead of proper packaging

1 participant