-
Notifications
You must be signed in to change notification settings - Fork 139
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
Ignore nonexistent paths in iter_modules #917
Conversation
I actually haven't tested this since I haven't figured out how to do that, but I'm pretty sure it's correct and what the implementation in |
Thanks for the PR. You can run the tests using the
Please make sure the test passes and then let me know. Also, can you describe the symptoms of the Django problem, and how to reproduce it? If it causes a crash, please post the stack trace here. Related: #820. |
I'm getting there, but it's pretty complex since you need 4 python versions and 3 java versions.
Sorry, I should have opened an issue first. Django enumerates commands for each Django app by blindly calling |
I agree it's a bit awkward. I recently updated product/README.md, which I hope makes it clear that to run |
The builtin python loaders return an empty list from `iter_modules` for a nonexistent path. Django expects this when it enumerates app management commands. Fixes: chaquo#920
e713260
to
deb7b85
Compare
I was able to build everything now and run the python tests from the app demo. They pass after a fix to pass a list containing the individual path. I opened #920 to document what happens without the change. |
I assume you've looked into this, but have you considered running the python tests as instrumented tests instead of running them from the demo app? I.e., |
True, but you need Java 17 to build the demo app. It's doable, but not straightforward. |
Yes, I'd like to run them in CI, but havent got round to it yet. It was only last week I added CI for the Gradle plugin tests, which are more important to automate because they're so much slower.
At the moment I just run them manually on my own devices or emulators. For each individual commit I use my judgement for which devices are necessary to test on, and then before each release I run them on a full set of devices as listed in release/README.md. |
for path in ("somemissingpackage", "some/missing/package"): | ||
mod_infos = list(pkgutil.iter_modules([path])) | ||
mod_infos = list(pkgutil.iter_modules([f"{murmurhash.__path__[0]}/{path}"])) | ||
self.assertEqual([], mod_infos) |
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.
Similarly to #924, the test didn't reproduce the original problem, because it wasn't passing a path that actually led to an AssetFinder. I've fixed this by making it pass an absolute path.
Thanks! |
I'm bundling Django and it uses
pkgutil.iter_modules
to find management commands provided by Django apps. The problem is that Django runspkg_util.iter_modules([command_dir])
without bothering to check thatcommand_dir
exists. Presumably this is because the builtin python loaders return an empty list fromiter_modules
when the specified directory doesn't exist.The app crashes with a
FileNotFoundError
PyException
during startup.