The switch to use pkg_resources breaks frozen builds #3259

Closed
opened 2019-10-03 17:56:40 +00:00 by cypher · 3 comments
cypher commented 2019-10-03 17:56:40 +00:00
Owner

PR #646 introduced a change that broke "frozen" builds of Tahoe-LAFS (i.e., standalone executables generated by PyInstaller, cx_Freeze, and the like). Specifically, because "frozen" python interpreters run outside of and without a traditional setuptools-based packaging environment, the pkg_resources.get_distribution(appname) call will fail as follows when running under a "frozen" interpreter:

Traceback (most recent call last):
  File "tahoe.py", line 23, in <module>
    from twisted.python.procutils import which
  File "/tmp/pip-install-Om4he9/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 395, in load_module
  File "site-packages/allmydata/scripts/runner.py", line 9, in <module>
  File "/tmp/pip-install-Om4he9/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 395, in load_module
  File "site-packages/allmydata/version_checks.py", line 29, in <module>
  File "site-packages/pkg_resources/__init__.py", line 481, in get_distribution
  File "site-packages/pkg_resources/__init__.py", line 357, in get_provider
  File "site-packages/pkg_resources/__init__.py", line 900, in require
  File "site-packages/pkg_resources/__init__.py", line 786, in resolve
pkg_resources.DistributionNotFound: The 'tahoe-lafs' distribution was not found and is required by the application
[23457] Failed to execute script tahoe

Conditionally skipping this call when running under a frozen interpreter will allow the execution of the application to continue as intended (as is already being done elsewhere in the version_checks module -- e.g., here).

[PR #646](https://github.com/tahoe-lafs/tahoe-lafs/pull/646) introduced a change that broke "frozen" builds of Tahoe-LAFS (i.e., standalone executables generated by [PyInstaller](wiki/PyInstaller), cx_Freeze, and the like). Specifically, because "frozen" python interpreters run outside of and without a traditional setuptools-based packaging environment, the [pkg_resources.get_distribution(*appname*)](https://github.com/tahoe-lafs/tahoe-lafs/blob/eb751baeef935f02bbdc1b1ed7ce8774d5e47be1/src/allmydata/version_checks.py#L29) call will fail as follows when running under a "frozen" interpreter: ``` Traceback (most recent call last): File "tahoe.py", line 23, in <module> from twisted.python.procutils import which File "/tmp/pip-install-Om4he9/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 395, in load_module File "site-packages/allmydata/scripts/runner.py", line 9, in <module> File "/tmp/pip-install-Om4he9/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 395, in load_module File "site-packages/allmydata/version_checks.py", line 29, in <module> File "site-packages/pkg_resources/__init__.py", line 481, in get_distribution File "site-packages/pkg_resources/__init__.py", line 357, in get_provider File "site-packages/pkg_resources/__init__.py", line 900, in require File "site-packages/pkg_resources/__init__.py", line 786, in resolve pkg_resources.DistributionNotFound: The 'tahoe-lafs' distribution was not found and is required by the application [23457] Failed to execute script tahoe ``` Conditionally skipping this call when running under a frozen interpreter will allow the execution of the application to continue as intended (as is already being done elsewhere in the `version_checks` module -- e.g., [here](https://github.com/tahoe-lafs/tahoe-lafs/blob/eb751baeef935f02bbdc1b1ed7ce8774d5e47be1/src/allmydata/version_checks.py#L324)).
tahoe-lafs added the
packaging
normal
defect
n/a
labels 2019-10-03 17:56:40 +00:00
tahoe-lafs added this to the 1.14.0 milestone 2019-10-03 17:56:40 +00:00
cypher commented 2019-10-03 19:02:04 +00:00
Author
Owner
PR: <https://github.com/tahoe-lafs/tahoe-lafs/pull/661>
Chris Wood <chris@leastauthority.com> commented 2019-10-09 19:32:10 +00:00
Author
Owner

In 710af06/trunk:

Skip pkg_resources.get_distribution call if frozen

Fixes: ticket:3259
In [710af06/trunk](/tahoe-lafs/trac-2024-07-25/commit/710af066d2e175db7d8197006087aa3c4f00f59d): ``` Skip pkg_resources.get_distribution call if frozen Fixes: ticket:3259 ```
tahoe-lafs added the
fixed
label 2019-10-09 19:32:10 +00:00
Chris Wood <chris@leastauthority.com> closed this issue 2019-10-09 19:32:10 +00:00
GitHub <noreply@github.com> commented 2019-10-09 19:32:10 +00:00
Author
Owner

In 91dd27b/trunk:

Merge pull request #661 from crwood/3259.frozen-pkg_resources-fix

Skip pkg_resources.get_distribution call if frozen

Fixes: ticket:3259
In [91dd27b/trunk](/tahoe-lafs/trac-2024-07-25/commit/91dd27b0f9f33e7b46a320b05cfb2262640ec992): ``` Merge pull request #661 from crwood/3259.frozen-pkg_resources-fix Skip pkg_resources.get_distribution call if frozen Fixes: ticket:3259 ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: tahoe-lafs/trac-2024-07-25#3259
No description provided.