Skip to content

Move to src layout #44

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

Open
agriyakhetarpal opened this issue Mar 11, 2025 · 2 comments
Open

Move to src layout #44

agriyakhetarpal opened this issue Mar 11, 2025 · 2 comments

Comments

@agriyakhetarpal
Copy link
Member

Instead of the "flat" layout, we should use the "src" layout.

More here: https://www.pyopensci.org/python-package-guide/package-structure-code/python-package-structure.html#the-src-layout-and-testing

@rth
Copy link
Member

rth commented Mar 15, 2025

is that it ensures tests are run against the installed version of your package rather than the files in your package working directory

I'm not opposed to it, but I find this is rather debatable, and most Python packages don't do this.
For packages that don't have c-extensions (like this one) it's not really an issue that needs solving IMO. Also it obfuscates the list of files on github. Like if I go to https://github.com/numpy/numpy the source code is somewhere in the numpy folder. If it's moved in src/numpy, I have one extra useless dir to go though before ending up on the file I need. Same in an IDE.

For pyodide src makes sense because it's a complex project. But for simple python projects the simpler it is the better.

I really appreciate you doing the maintenance though! So if you want to do it, go for it :)

@agriyakhetarpal
Copy link
Member Author

Thanks, @rth. It is usually recommended that if one were to start a new package today, they should almost always go with this format rather than a flat one. However, I agree with your point about the src/ dir being redundant! Also, not being a compiled package does help not require it.

BTW, I would say that NumPy here isn't the best example. The reason it hasn't migrated (or been able to migrate, rather) to an src/ layout has been its popularity and corresponding inertia owing to its big contributor base—it has almost 200 open PRs at any time, and switching a bunch of files overnight would cause disruptions on virtually every open PR, and troubles with beginner contributors as it's difficult for them to (and can't be expected of them to) address conflicts that span across moved files.

So, I'll leave this issue open in the meantime, and we can consider choosing the option where the vote sways to in case anyone else from our team has any thoughts. :)

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

No branches or pull requests

2 participants