-
Notifications
You must be signed in to change notification settings - Fork 101
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
regression: passlib doesnt work with py2exe #144
Comments
If I explicitly add the missing files it works: |
Thanks for reporting this. To some extent, this is the expected behavior of 0.11, as doing so allows to include just a sub-package, which is extremely useful for large packages (e.g. GUI bindings like That being said, this appears to be a bug to me, as |
So in 0.11 there is no way to include an entire package? Was not aware of this change in behaviour. |
The change happened because now we use the reference implementation of CPython >>> import passlib
>>> passlib
<module 'passlib' from '/Users/alberto/test/venv/lib/python3.9/site-packages/passlib/__init__.py'>
>>> passlib.handlers
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'passlib' has no attribute 'handlers'
>>> from passlib import handlers
>>> handlers
<module 'passlib.handlers' from '/Users/alberto/test/venv/lib/python3.9/site-packages/passlib/handlers/__init__.py'> CPython This change is not explicitly mentioned in the release notes because, to some extent, the previous behavior was incorrect (or not conform to Python) and now we switched to the expected behavior. |
Problem is there's a lot of ways to import packages in Python What is the difference between packages= and includes= options then? |
I am well aware of the amount of creative solutions in the Python ecosystem...
Not necessarily, see below.
First, Therefore, we see errors only in packages that do not use regular import mechanisms, either because the import is not performed in Python but rather in C, or they use a non-standard import system, or, like the case of As I wrote in the first comment, I need to investigate why both CPython |
I'm not following you regarding the functional difference between a module and a package in this context. I'd argue that having a very blunt method for including an entire package without relying on scanning for imports is useful. We could always run into a package that does the imports in way that cannot be scanned and a "smart" hook cannot be written for it. The packages= option used to just such a "stupid" option. But configureable. |
This is a fair objections for this case, but not for the case of e.g.
I am not saying it is not useful, I am just questioning the balance between our need for it and its implementation and maintenance cost. There is no reference implementation, as Switching our module finder to the reference implementation solved all these problems (and probably more) at once, but of course it reduced our wiggle room for extending it blindly. This is primarily why I am in principle against introducing more features in That being said, if you want, you can give it a try into reimplementing this feature, as I'd consider a PR that passes CI and does not tamper excessively with the vendor |
Going back to the issue at hand, I'd say a hook in this case is the preferred solution, as the "import chain" of Fortunately, the hook can be as simple as: def hook_passlib(finder, module):
depth = getattr(finder,"recursion_depth_passlib", 0)
if depth == 0:
finder.recursion_depth_passlib = depth + 1
finder.import_package("passlib.handlers")
finder.recursion_depth_passlib = depth Note that |
OK thanks for getting into this and let me know if I can help (test the fix?) In any case I don't know enough about how py2exe works to actually have an opinion about the best implementation. If it works, it works. |
Fixed in 0.12.0.0 |
Just ran across a bug in py2exe where it doesn't add passlib automatically and even including passlib in the packages option doesn't help.
See the following code:
It runs under python 3.9 with the following pip reqs:
If I package it using the following py2exe script it works in py2exe 0.10.2.1 but it fails with the most recent py2exe version (0.11.1.1):
For some reason only a couple of files are added from passlib instead of the whole package
The text was updated successfully, but these errors were encountered: