shish / rosettaboy

A gameboy emulator in several different languages
MIT License
469 stars 22 forks source link

pyproject.toml? #121

Open shish opened 1 year ago

shish commented 1 year ago

I hear this is the Modern(tm) way to define python projects and dependencies?

Seems more sensible than using a shell script to download random package versions o.o

Bobronium commented 1 year ago

Hello! I've stumbled upon your project while reading through MyPy release notes and checking out relater PRs.

I must tell, I find this python codebase better than in 99% of python projects I've seen written by people who don't use python professionally.

I'd like to give you some direction on this issue that you might consider useful.

You can start by checking out https://github.com/pypa/hatch

This wil also allow to just pip install . on the project.

And https://github.com/ofek/hatch-mypyc, a plugin for Hatch, will allow to compile the project with mypyc upon installation (btw, MyPy 1.0.0 with match statement support is out)

On top of that, you'll be able to hatch build && hatch publish it as a package to pypi.org.

Few things to note: you should rename package name from src to something more telling, e.g. rosettaboy.

If you'd like to keep src as a sources container, you can instead create a subdir with a package name. But imports should still start with the package name (so in both scenarious if you end up choosing rosettaboy as a package name, imports should look like from rosettaboy.cpu import CPU and so on, regardless of whether you end up with ./src/rosettaboy or just ./rosettaboy).

Bobronium commented 1 year ago

Oh, and I forgot to say thank you! ❤️

I want to learn Rust for a long time and this project is definitelly going to be useful as a reference.

shish commented 1 year ago

Thank you for the pointers, I will check out hatch now, and update mypy to 1.0 :D

The package directory being named src is mostly just for keeping in-line with the other implementations who all use eg src/cpu.cpp, src/cpu.rs, etc -- I know it's frowned upon (and might even cause problems if we ever wanted to publish as a package that other people can install), but I think if it's only ever going to be run locally from a git checkout, then it won't break anything? (I'm not opposed to changing it, but right now I appreciate being able to eg fix a bug across CPU implementations with vim */src/cpu.* ^^)

Bobronium commented 1 year ago

Hmm, understood. Another option would be to use: https://hatch.pypa.io/latest/config/build/#rewriting-paths

However, it will still (probably) require to rename src to new package name in imports.