Repository navigation
Don't require astropy to be importable at setup.py time - #8402
Conversation
|
🔥 🔥 🔥 🔥 🔥 🔥 🔥 🔥 |
|
There are a few issues with the builds that don't rely on setup.py commands, so I'll investigate that shortly, but I think this is related to other changes in astropy-helpers (related to build_ext). So feel free to review the PR as if there were no CI failures :) Note to self: the issue is related to pypa/setuptools#1317 - that is because we import |
|
Nope. |
|
@pllim - what did you do, and is your astropy_helpers submodule up to date? It looks like you are using an old version of astropy-helpers. Unless you are referring to one of the CI results, in which case as mentioned above the 32-bit failure is expected. |
|
Oh... I didn't read the note about 32 bit, I just saw "feel free to review the PR as if there were no CI failures". Besides 32-bit, Travis, html-docs, and mpldev also failed. Is that also expected? |
|
Just want to say that this is my favorite PR. |
|
The WCS changes look fine. Though I didn't install and test locally. |
|
@pllim - for now yes, I need astropy/astropy-helpers#452 for things to work properly. |
| # LOCAL | ||
| from astropy import log | ||
| from astropy.io import fits | ||
| from . import _docutil as __ |
There was a problem hiding this comment.
Not really a review comment, but I never understood the rationale for importing things this way. Is there a good reason for using __ as the module name?
There was a problem hiding this comment.
I have no idea and I found it veeeery confusing
There was a problem hiding this comment.
as a way to show it's super private, and no one outside should use any of that functionality? If that's not the purpose, then I'm confused as well. 😕
|
I would say this deserves a mention in the changelog under "other changes" |
bsipocz
left a comment
There was a problem hiding this comment.
Overall looks very neat. I had only one minor comment, and also would like to see a full green CI before approval and merging.
| raise | ||
| else: | ||
| _wcs = None | ||
| from . import docstrings as docutils |
There was a problem hiding this comment.
can we call it something else then docutils? Not that I plan to spend much time around in wcs, but it always confuses me when a name of an existing package is used as an alias for something else.
e1cdda3 to
3db2ff6
Compare
Codecov Report
@@ Coverage Diff @@
## master #8402 +/- ##
==========================================
+ Coverage 86.78% 86.79% +0.01%
==========================================
Files 387 386 -1
Lines 58123 58090 -33
Branches 1060 1060
==========================================
- Hits 50440 50422 -18
+ Misses 7068 7053 -15
Partials 615 615
Continue to review full report at Codecov.
|
|
The CI is now passing! 🎉 - this is now ready for final reviewing (I think we should make sure it has several approvals before merging though as it's a reasonably significant change) |
pllim
left a comment
There was a problem hiding this comment.
Definitely cleaner! And the changes does not seem to break wcs docstring magic.
bsipocz
left a comment
There was a problem hiding this comment.
It all looks good to me, and all my concerns were addressed, too.
eteq
left a comment
There was a problem hiding this comment.
I also think this is a very good idea, but I have one concern (well, technically two, but it's really sort of an "either do A or if not, change B" thing) about the exception-raising - see inline.
One other related thing which doesn't necessarily need to hold up the PR but we probably want to keep in mind given these changes: We also use the _ASTROPY_SETUP_ trick in the package template right now, right? Do we want to it from there as well? It's possible that some affiliated package depends on this in some subtle way (a la the wcs change required here), but we probably want to discourage this at least for new packages moving forward, at least? (If not also help fix old ones...)
|
@eteq - good catch! Astropy needs to be importable by affiliated packages when they run |
2a48694 to
b0d2899
Compare
…thout importing the rest of astropy
…be importable at build-time
…UP_ to prevent imports at setup time
b0d2899 to
b884da9
Compare
|
I wonder whether there is any long term open issue that this would close :) We need to keep on eye on them when triaging and close them :) |
|
I restarted the docs build because it looked unrelated but want to be sure. Other than that this looks good, but just to confirm - @astrofrog , did you mean to reject my suggestion of a re-classing of the exception, or just miss it above? (It's ok either way, I just want to make sure it was intended and not missed since I buried it in an inline comment with some other stuff...) |
|
@eteq the docs build could fail now due to the linkchecking. While it's being revised separately any failures related to that should be ignored. |
Co-Authored-By: astrofrog <[email protected]>
|
@eteq - I approved your suggestion, sorry I missed that before! |
One of my missions currently is to try and reduce the complexity of the very idiosyncratic infrastructure that we've accumulated over the lifetime of the project. One of these in particular is the fact that until now packages have had to be importable at setup.py time even if they contain C extensions, which requires the convoluted approach of defining the
__ASTROPY_SETUP__builtin and making sure that every single C extension we import is conditional on this variable.In the past, the reason why astropy needed to be importable is because astropy-helpers and the
setup_package.pyfiles tried to importastropy.versionat various points in the process, though this then grew to include other files. After a series of pull requests in recent weeks, astropy-helpers should now no longer import the whole package (although packages might still do this to themselves) - instead if it really needs to access the version, then for now it uses theimport_filefunction which allows us to import specific files without importing the whole package. This PR now extends this kind of work to the core package to make sure that when we do need to import other files during the setup process, we useimport_filerather than importing e.g.astropy.versiondirectly.I should note the following changes in particular:
For the WCS module, I had to rearrange one of the files to facilitate this approach, but overall this doesn't require too many changes, mostly just combining two files.
We formerly imported astropy in the setup.py file to get
__minimum_numpy_version__, but this PR changes that to define the numpy requirement properly in setup.cfg. This does mean duplication for now, but I would argue that since we define the requirement properly in setup.cfg/setup.py, we should consider getting rid of the definition of__minimum_numpy_version__and the check for the numpy version inastropy/__init__.py, since that is no longer really necessary (when astropy is installed with pip or conda, a compatible version of numpy will be installed)Currently I raise an exception in
astropy/__init__.pyif astropy is imported during the setup process. I had intended for that to just be a temporary thing to make sure this all works properly, but it might actually just make sense to keep it to prevent regressions.Note that the 32-bit CircleCI build will fail but that's just because for some reason it uses astropy-helpers from master not this PR, so let's just ignore that failure.