Skip to content

Declare all package data in setup.cfg instead of in setup_package.py files#9729

Merged
astrofrog merged 2 commits intoastropy:masterfrom
astrofrog:package-data-setup-cfg
Dec 18, 2019
Merged

Declare all package data in setup.cfg instead of in setup_package.py files#9729
astrofrog merged 2 commits intoastropy:masterfrom
astrofrog:package-data-setup-cfg

Conversation

@astrofrog
Copy link
Member

@astrofrog astrofrog commented Dec 6, 2019

This is a self-contained subset of changes related to the APE A roadmap for package infrastructure without astropy-helpers. This PR as-is is ready for review, and does not actually require removing astropy-helpers to work, though I think we should maybe wait until Tuesday to merge since that's when we'll be discussing the APE in Socorro.

This moves the declaration of package data from get_package_data in setup_package.py files to instead be in the setup.cfg file. The documentation updates are in #9726 and are difficult to disentangle from other documentation updates, so let's keep that separate.

@astrofrog astrofrog added this to the v4.1 milestone Dec 6, 2019
@astropy-bot astropy-bot bot added the wcs label Dec 6, 2019
@astrofrog astrofrog added the zzz 💤 astropy-helpers-removal archived: PRs and issues related to the removal of astropy-helpers label Dec 6, 2019
scikit-image

[options.package_data]
* = data/*, data/*/*, data/*/*/*, data/*/*/*/*, data/*/*/*/*/*, data/*/*/*/*/*/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who are you so wise in the way of science?!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦆

source = join('cextern', 'wcslib', 'C', header)
dest = join('astropy', 'wcs', 'include', 'wcslib', header)
if newer_group([source], dest, 'newer'):
shutil.copy(source, dest)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to figure out how to reproduce this behavior with setup.cfg, this is what's causing the test failure currently

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and as a side note, the reason I didn't pick this up sooner is that the test that exercises this is set to skip if certain env variables aren't set, and this was the case with tox since env vars have to be whitelisted)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this looks all rather complicated; is the library created in astropy.wcs used outside of astropy?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to make it so that other packages could create C extensions linked against the bundled WCSLIB in astropy but not sure if anyone uses it!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we document this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, so it is a bit like numpy.get_include(). Though indeed we should then make sure it always points to the correct include files, either that of the system or of astropy.

@astrofrog
Copy link
Member Author

Ok so here's the weird thing - the way the code was written to copy over the WCSLIB header files was such that if astropy was compiled against a system WCSLIB library, the header files were not copied, which I guess would affect the astropy debian package. So presumably that means that third party packages that want to build extensions against the bundled version of WCSLIB would need to check if the header files are present in astropy and figure out how to link against the system library if not. I'm curious whether we know if anyone is using this. Is this something makes sense to continue supporting? @nden do you know of any cases?

@saimn
Copy link
Contributor

saimn commented Dec 10, 2019

There is also the MANIFEST.in file, which is currently used, and provides more options to include or exclude data (e.g. graft astropy could probably replace the recursive globbing ?).
https://setuptools.readthedocs.io/en/latest/setuptools.html#including-data-files
https://python-packaging.readthedocs.io/en/latest/non-code-files.html

Also of interest : package_data is only used when building binary packages. But I'm not sure if this is (still) true. edit: as confirmed by @astrofrog this is no longer true.

Generally I think people advice against using package-data, e.g. https://blog.ionelmc.ro/2014/06/25/python-packaging-pitfalls/#forgetting-package-data

@nden
Copy link
Contributor

nden commented Dec 10, 2019

I believe drizzlepac uses those header files
https://github.com/spacetelescope/drizzlepac/blob/master/setup.py#L39

@nden
Copy link
Contributor

nden commented Dec 10, 2019

It looks like they are used also in modeling for wrapping the projections.

@mhvk
Copy link
Contributor

mhvk commented Dec 10, 2019

Sounds like we're now in for ensuring there are links to system libraries in place...

@nden
Copy link
Contributor

nden commented Dec 10, 2019

Just to clarify, I think the original idea was to provide a way for external software to link to wcslib so that system libraries are not necessary to install. I think this is the preferred way some users work. The ability to link to system libraries was added later. I believe it was requested by OS maintainers but I may be wrong.

@astrofrog
Copy link
Member Author

I've opened #9752 for whether get_include should return system headers in some cases (I think that's beyond the scope of this PR)

@mhvk
Copy link
Contributor

mhvk commented Dec 10, 2019

Yes, let's solve one thing at a time! As is, linking with system libraries might work for most people anyway, since one usually does include a standard -I/usr/include etc.
And certainly the current approach seems right: if we provide a library to link against, we should also provide its header.

@astrofrog
Copy link
Member Author

Regarding using MANIFEST.in and include_package_data, I don't have a strong opinion on this, and the setuptools documentation gives both this and the current approach as options. In the interest of moving this forward, since this currently works as-is, can we consider merging this and then making the switch to MANIFEST.in in a separate issue/PR? (my priority is to get rid of unnecessary setup_package.py files). Note that the comment about package_data only working for binary packages is no longer, true, what we do here is strictly equivalent to MANIFEST.in.

So for now, can we go ahead with this PR? If so I'll open an issue regarding switching to MANIFEST.in.

@mhvk
Copy link
Contributor

mhvk commented Dec 18, 2019

Yes, let's get this in - very nice not to have to worry about setup_package any more!

@mhvk mhvk added the zzz 💤 merge-when-ci-passes Do not use: We have auto-merge option now. label Dec 18, 2019
Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, since somehow that hadn't happened yet.

@astrofrog
Copy link
Member Author

I'm going to go ahead and merge this since it was approved - and APE 17 has been merged. I've opened a new issue to discuss whether to consider switching to using MANIFEST.in: #9801

@astrofrog astrofrog merged commit 59f8ab4 into astropy:master Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog-entry-needed Ready-for-final-review Refactoring wcs zzz 💤 astropy-helpers-removal archived: PRs and issues related to the removal of astropy-helpers zzz 💤 merge-when-ci-passes Do not use: We have auto-merge option now.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants