question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Move astropy to ``src`` directory

See original GitHub issue

Description

Having the following package structure is considered much safer.

astropy/
├── pyproject.toml
├── ...
├── src/
│   └── astropy/

Additional context

https://packaging.python.org/en/latest/tutorials/packaging-projects/#creating-the-package-files https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:19 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
saimncommented, Sep 19, 2022

Basically src-layout makes it much easier to test the installed version of a package (and thus to test that the package has been packaged/installed correctly), by ensuring that the package cannot be imported from the local directory. With a flat-layout it can be very difficult to do so, because amongst other of pytest’s way to discover conftest.py and test files.

More info on src-layout: https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure Also ref https://github.com/astropy/package-template/issues/522

For astropy the current way to test the installed package only works because pytest-astropy-header is importing astropy (without needing it) before pytest runs the conftest and test discovery (!!): https://github.com/astropy/pytest-astropy-header/issues/41 (especially https://github.com/astropy/pytest-astropy-header/issues/41#issuecomment-1002705819 which summarizes the thing …) https://github.com/astropy/pytest-astropy-header/pull/43 (nice fix 😄)

I lost hours on this testing the installed package thing for various packages, it’s often painful to do unless you use a src-layout … (for flat-layout it depends if the test files are in the package or not, if using conftest.py in the root directory, and probably other things I forgot). So yeah src-layout may look weird at first but for my mental health it’s now my preferred choice 😉.

1reaction
pllimcommented, Sep 19, 2022

But, we have so many open PRs and stuff… This is something that needs to be coordinated well to happen without making everyone else cry.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration System (astropy.config)
The astropy configuration system is designed to give users control of various parameters used in astropy or affiliated packages without delving into the...
Read more >
Source code for astropy.config.paths
Raises ------ OSError If the home directory cannot be located - usually means you are running Astropy on some obscure platform that doesn't...
Read more >
How to create and maintain an Astropy affiliated package
git submodule add https://github.com/astropy/astropy-helpers.git astropy_helpers ... Move the main source directory to reflect the name of your package.
Read more >
2. The basic structure of a Python package
For example, astropy provides a cookiecutter package template specific to ... The standard method for installing a package from its source directory (the ......
Read more >
PermissionError: [WinError 32] with fits files - Stack Overflow
This warning in the documentation should answer your question (perhaps the warning should be moved elsewhere since it's not specific just to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found