-
Notifications
You must be signed in to change notification settings - Fork 16
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
Bug: Dependency to Import mapping on the qiskit
package does not include the qiskit
import name
#176
Comments
I'm guessing there's something weird about |
I started digging more into this... The
|
For the record,
|
continuing my deep dive into the obscure packaging practices of Python... What is
|
FWIW, I've added this comment to a similar issue in the |
Created python/importlib_metadata#437 to have |
The python-algortihms project highlights an outstanding issue in FawltyDeps: Placeholder packages. As discussed in issue #176, these are packages that don't provide the expected import name (or any import name at all), but instead depend on other packages (transitive dependencies) which will then supply the relevant import name. The first example we came across of such a package (in #176) was qiskit. Another example is tensorflow, but only on Windows: On Windows the tensorflow package is a 1.9kB placeholder that depends on tensorflow-intel (266MB) to bring in the actual meat. (On POSIX, the tensorflow package itself contains everything.) We make two changes to our real_projects test for python-algorithms: 1. We add the posix_only flag to the all_reqs_installed experiment, to prevent it from running on Windows. Its expected results would be different there (because of tensorflow-intel). 2. We add a new experiment, some_reqs_customized, which uses a custom_mapping to resolve qiskit and tensorflow. The remaining requirements are installed (as in the previous experiment). This yields the "best" FawltyDeps result for this project. The remaining undeclared/unused dependencies are presumed to be true positives for this project.
The python-algortihms project highlights an outstanding issue in FawltyDeps: Placeholder packages. As discussed in issue #176, these are packages that don't provide the expected import name (or any import name at all), but instead depend on other packages (transitive dependencies) which will then supply the relevant import name. The first example we came across of such a package (in #176) was qiskit. Another example is tensorflow, but only on Windows: On Windows the tensorflow package is a 1.9kB placeholder that depends on tensorflow-intel (266MB) to bring in the actual meat. (On POSIX, the tensorflow package itself contains everything.) We make two changes to our real_projects test for python-algorithms: 1. We add the posix_only flag to the all_reqs_installed experiment, to prevent it from running on Windows. Its expected results would be different there (because of tensorflow-intel). 2. We add a new experiment, some_reqs_customized, which uses a custom_mapping to resolve qiskit and tensorflow. The remaining requirements are installed (as in the previous experiment). This yields the "best" FawltyDeps result for this project. The remaining undeclared/unused dependencies are presumed to be true positives for this project.
The python-algortihms project highlights an outstanding issue in FawltyDeps: Placeholder packages. As discussed in issue #176, these are packages that don't provide the expected import name (or any import name at all), but instead depend on other packages (transitive dependencies) which will then supply the relevant import name. The first example we came across of such a package (in #176) was qiskit. Another example is tensorflow, but only on Windows: On Windows the tensorflow package is a 1.9kB placeholder that depends on tensorflow-intel (266MB) to bring in the actual meat. (On POSIX, the tensorflow package itself contains everything.) We make two changes to our real_projects test for python-algorithms: 1. We add the posix_only flag to the all_reqs_installed experiment, to prevent it from running on Windows. Its expected results would be different there (because of tensorflow-intel). 2. We add a new experiment, some_reqs_customized, which uses a custom_mapping to resolve qiskit and tensorflow. The remaining requirements are installed (as in the previous experiment). This yields the "best" FawltyDeps result for this project. The remaining undeclared/unused dependencies are presumed to be true positives for this project.
The python-algortihms project highlights an outstanding issue in FawltyDeps: Placeholder packages. As discussed in issue #176, these are packages that don't provide the expected import name (or any import name at all), but instead depend on other packages (transitive dependencies) which will then supply the relevant import name. The first example we came across of such a package (in #176) was qiskit. Another example is tensorflow, but only on Windows: On Windows the tensorflow package is a 1.9kB placeholder that depends on tensorflow-intel (266MB) to bring in the actual meat. (On POSIX, the tensorflow package itself contains everything.) We make two changes to our real_projects test for python-algorithms: 1. We add the posix_only flag to the all_reqs_installed experiment, to prevent it from running on Windows. Its expected results would be different there (because of tensorflow-intel). 2. We add a new experiment, some_reqs_customized, which uses a custom_mapping to resolve qiskit and tensorflow. The remaining requirements are installed (as in the previous experiment). This yields the "best" FawltyDeps result for this project. The remaining undeclared/unused dependencies are presumed to be true positives for this project.
FWIW, there seems to be a recent (2024-02-15) change in qiskit upstream: Starting from v1.0.0 qiskit now does provide the It would seem that the entire qiskit issue simply goes away when qiskit >= v1.0 is used... |
qiskit v1.0 starts to declare the qiskit import name (see issue #176 for details about the weirdness that precedes v1.0). This changes the behavior of our real_projects test of the Algortihms project. qiskit has also dropped support for Python 3.7 (since v0.44), hence it is easier for us to keep our tests (which need to work with Python 3.7) running on the older version, for now.
The python-algortihms project highlights an outstanding issue in FawltyDeps: Placeholder packages. As discussed in issue #176, these are packages that don't provide the expected import name (or any import name at all), but instead depend on other packages (transitive dependencies) which will then supply the relevant import name. The first example we came across of such a package (in #176) was qiskit. Another example is tensorflow, but only on Windows: On Windows the tensorflow package is a 1.9kB placeholder that depends on tensorflow-intel (266MB) to bring in the actual meat. (On POSIX, the tensorflow package itself contains everything.) We make two changes to our real_projects test for python-algorithms: 1. We add the posix_only flag to the all_reqs_installed experiment, to prevent it from running on Windows. Its expected results would be different there (because of tensorflow-intel). 2. We add a new experiment, some_reqs_customized, which uses a custom_mapping to resolve qiskit and tensorflow. The remaining requirements are installed (as in the previous experiment). This yields the "best" FawltyDeps result for this project. The remaining undeclared/unused dependencies are presumed to be true positives for this project.
qiskit v1.0 starts to declare the qiskit import name (see issue #176 for details about the weirdness that precedes v1.0). This changes the behavior of our real_projects test of the Algortihms project. qiskit has also dropped support for Python 3.7 (since v0.44), hence it is easier for us to keep our tests (which need to work with Python 3.7) running on the older version, for now.
The python-algortihms project highlights an outstanding issue in FawltyDeps: Placeholder packages. As discussed in issue #176, these are packages that don't provide the expected import name (or any import name at all), but instead depend on other packages (transitive dependencies) which will then supply the relevant import name. The first example we came across of such a package (in #176) was qiskit. Another example is tensorflow, but only on Windows: On Windows the tensorflow package is a 1.9kB placeholder that depends on tensorflow-intel (266MB) to bring in the actual meat. (On POSIX, the tensorflow package itself contains everything.) We make two changes to our real_projects test for python-algorithms: 1. We add the posix_only flag to the all_reqs_installed experiment, to prevent it from running on Windows. Its expected results would be different there (because of tensorflow-intel). 2. We add a new experiment, some_reqs_customized, which uses a custom_mapping to resolve qiskit and tensorflow. The remaining requirements are installed (as in the previous experiment). This yields the "best" FawltyDeps result for this project. The remaining undeclared/unused dependencies are presumed to be true positives for this project.
The python-algortihms project highlights an outstanding issue in FawltyDeps: Placeholder packages. As discussed in issue #176, these are packages that don't provide the expected import name (or any import name at all), but instead depend on other packages (transitive dependencies) which will then supply the relevant import name. The first example we came across of such a package (in #176) was qiskit. Another example is tensorflow, but only on Windows: On Windows the tensorflow package is a 1.9kB placeholder that depends on tensorflow-intel (266MB) to bring in the actual meat. (On POSIX, the tensorflow package itself contains everything.) We make two changes to our real_projects test for python-algorithms: 1. We add the posix_only flag to the all_reqs_installed experiment, to prevent it from running on Windows. Its expected results would be different there (because of tensorflow-intel). 2. We add a new experiment, some_reqs_customized, which uses a custom_mapping to resolve qiskit and tensorflow. The remaining requirements are installed (as in the previous experiment). This yields the "best" FawltyDeps result for this project. The remaining undeclared/unused dependencies are presumed to be true positives for this project.
FawltyDeps v0.3.1
When running FawltyDeps (in the customary FawltyDeps env) on the Algorithms project, the lists of unused deps and undeclared imports do not contain the
qiskit
package as it is both used and declared:Excerpt:
As FawltyDeps defaults to identity mapping in this instance, the import and dependency name get matched.
When I tried installing all declared dependencies of Algorithms (+FawltyDeps) in a new environment, I got
qiskit
in the list of undeclared and unused:Looking at the json output, I got:
No
qiskit
to be seen in theimport_names
!When I tried to import
qiskit
in Python in that venv, however, it worked without problem!I thought for a second that
qiskit
might be exposed by other packages in the environment, but in that case it would have been matched and it wouldn't have appeared in the undeclared imports.I tried importing
qiskit
in the FawltyDeps-only environment and Python couldn't find it (as expected).I haven't dug deeper than that. My next step would be to see how Python's import finder managed to find
qiskit
in the 2nd environment in the first place.The text was updated successfully, but these errors were encountered: