-
Notifications
You must be signed in to change notification settings - Fork 69
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
Editable installs improvements #569
Conversation
bf80201
to
b989bae
Compare
b989bae
to
3092827
Compare
075cd39
to
54dc58c
Compare
Thanks for this PR! I gave in a go to see whether that would fix the issue we were seeing in scikit-learn where some of our tests are using Right now if I try to run the problematic test with pytest, I get an error Let me know if I can provide additional information! Full stack-trace
|
Thanks for testing. I cut some corners in the implementation. It seems that pytest uses one of the interfaces I haven't implemented. I'll add it when I find a moment. |
Great, let me know if there is something I can help with! |
5b21a86
to
c9e3058
Compare
Add support for the exclude_dirs and exclude_files arguments of install_subdir() Meson function. Extend editable install tests to cover this functionality and a more complex package layout.
c9e3058
to
8f19aec
Compare
@lesteve Can you try again, please? |
Great! This seems to fix both #557 (comment) and #568. |
48f8a5f
to
e29e9a3
Compare
I just saw that this was added on the 0.16.0 milestone, which is great news, let me know if there is anything I can do to help move it forward! |
Yes, I hope we can get this in and released soon. I need to finish testing and reviewing; holidays interfered a bit. I'll try to finalize my review in the next couple of days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very close. I did a fair bit of testing; it's definitely a large improvement. For PyWavelets it fixed an issue, for NumPy and SciPy the tests got more accurate. There is one hiccup with pkgutil.walk_packages
, I commented inline about what I think the problem is.
mesonpy/_editable.py
Outdated
ispkg = True | ||
if modname and '.' not in modname: | ||
yielded.add(modname) | ||
yield prefix + modname, ispkg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've found one issue where pkgutil.walk_packages
returns directories with files in it that get installed with install_subdir
but don't have an __init__.py
. According to the docs, only modules should be returned.
It looks like the condition here should include an is_dir
part, and if it's a directory then ispkg
must be True for this to be yielded. Although not sure if that will mess with namespace packages; this is handled in the find_spec
function higher up, but not in this iter_modules
.
I ran into this in both NumPy and SciPy, where the test_public_api.py::test_all_modules_are_expected
tests turn up a few of these non-package directories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. My understanding was that namespace packages should be returned too. I even added test to check that this was the case. However, I've just tested and they are indeed not returned. Let me fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @rgommers. The issue with namespace packages should be fixed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test failures are due to mesonbuild/meson#12920
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I can confirm that it works now with both numpy and scipy, and from some more debug printing it seems to function exactly as expected.
Test failures with Meson master shouldn't be blocking here, so let's get this in.
e29e9a3
to
063e6b7
Compare
Set the __path__ module attribute to a placeholder path. Because how editable installs are implemented, this cannot correspond to the filesystem path for the package. And add a sys.path_hook that recognizes this paths and returns a path loader that implements iter_modules(). This allows pkgutil.iter_packages() to work properly. Fixes mesonbuild#557. Fixes mesonbuild#568.
063e6b7
to
4924a5a
Compare
Since the mechanism for editable installations was improved in mesonbuild/meson-python#569 and subsequently released in meson-python v0.16.0, this bumps the minimum version for it for use during compilation.
Since the mechanism for editable installations was improved in mesonbuild/meson-python#569 and subsequently released in meson-python v0.16.0, this bumps the minimum version for it for use during compilation.
No description provided.