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

Use a src/ layout #114

Closed
kousu opened this issue Feb 1, 2021 · 1 comment
Closed

Use a src/ layout #114

kousu opened this issue Feb 1, 2021 · 1 comment

Comments

@kousu
Copy link
Contributor

kousu commented Feb 1, 2021

Repeating the advice I found for spinalcordtoolbox/spinalcordtoolbox#3161:

You should do git mv dcm2bids src/dcm2bids, and fix up all things that breaks. Not doing this means any code run from the root of the directory (which is..most dev code) will use the uninstalled version, and that will not always be correct, particularly when trying to use relative imports or package-installed data. #110 is exactly the sort of bug this quirk (bug? problem?) of python leads to, and src/ is a workaround for it.

See:

Your tests do not run against the package as it will be installed by its users. They run against whatever the situation in your project directory is.

But this is not just about tests: the same is true for your application. The behavior can change completely once you package and install it somewhere else.

The first link summarizes a PyPA summit from last year:

  • single module packages should use flat layout.
    *REPL breaks when using src/ (you can't import module) and we considered this to be an important detail for first-time packagers who only want to share a script.
  • Anything beyond a single module being packaged, should use the src/ directory.
@arnaudbore
Copy link
Contributor

We will not take this path in the futur but #200 will help the overall organisation.

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