Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyproject.toml? #121

Open
shish opened this issue Feb 6, 2023 · 4 comments
Open

pyproject.toml? #121

shish opened this issue Feb 6, 2023 · 4 comments
Labels
python Python-specific

Comments

@shish
Copy link
Owner

shish commented Feb 6, 2023

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

@shish shish added the python Python-specific label Feb 6, 2023
@Bobronium
Copy link

Bobronium commented Feb 7, 2023

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
Copy link

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
Copy link
Owner Author

shish commented Feb 7, 2023

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Python-specific
Projects
None yet
Development

No branches or pull requests

2 participants