Convert to src layout#7
Conversation
Move diffusion_model.py into src/diffusion_model/ as a package, splitting the __main__ block into a separate __main__.py. Update pyproject.toml to use the setuptools package finder for src/ and add pytest pythonpath configuration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
I’d prefer not to move the implementation directly into I generally try to keep
For from diffusion_model._cli import main
if __name__ == "__main__":
raise SystemExit(main())The CLI code itself should be wrapped in a
I’m also hesitant about adding this to [tool.pytest.ini_options]
pythonpath = ["src"]I’d rather have tests run against the installed package so packaging errors are caught during testing and adding
Adding |
|
@mcflugen Thank you for reviewing this PR. Everything worked, but it had a bad smell. Would you like to make changes, or would prefer I do so? |
You go for it! |
I asked Claude to convert the Python source in this repository from a single-file layout to a src layout. This is what it came up with:
diffusion_model.pyintosrc/diffusion_model/__init__.pyas an installable package__main__block intosrc/diffusion_model/__main__.pysopython -m diffusion_modelcontinues to work
pyproject.tomlto use the setuptoolspackages.finddiscoverer pointed atsrc/, andadd
pythonpath = ["src"]for pytest.venv/to.gitignoreI think it's curious that Claude put all the functions into the module definition file
__init__.py, but I guess it makes sense instead of having a named module likemodel.pyand a stub definition file that imports functions from the named module file.