Skip to content
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

hooks: hydra: add work-around for python < 3.10 and PyInstaller >= 5.8 #760

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

rokm
Copy link
Member

@rokm rokm commented Jul 11, 2024

Under python < 3.10, hydra's plugin manager continues to use deprecated PEP-302 functionality that was removed from PyInstaller's PyiFrozenImporter in PyInstaller 5.8 (pyinstaller/pyinstaller#7344.). At run-time, this results in AttributeError: 'PyiFrozenImporter' object has no attribute 'find_module'.

As a work-around, check python version and PyInstaller version, and if using python < 3.10 and PyInstaller >= 5.8, set module collection mode for hydra._internal.core_plugins and hydra_plugins packages to py to collect their modules as source .py files only. This way, they end up handled by python's built-in finder/importer, instead of PyInstaller's PyiFrozenImporter.

Under python < 3.10, `hydra`'s plugin manager continues to use
deprecated PEP-302 functionality that was removed from PyInstaller's
`PyiFrozenImporter` in PyInstaller 5.8 (pyinstaller/pyinstaller#7344.).
At run-time, this results in `AttributeError: 'PyiFrozenImporter'
object has no attribute 'find_module'`.

As a work-around, check python version and PyInstaller version,
and if using python < 3.10 and PyInstaller >= 5.8, set module
collection mode for `hydra._internal.core_plugins` and
`hydra_plugins` packages to `py` to collect their modules as
source .py files only. This way, they end up handled by python's
built-in finder/importer, instead of PyInstaller's `PyiFrozenImporter`.
@rokm
Copy link
Member Author

rokm commented Jul 11, 2024

@rokm rokm merged commit 2d3b566 into pyinstaller:master Jul 12, 2024
2 checks passed
@rokm rokm deleted the hook-hydra-workaround-for-old-python branch July 12, 2024 09:38
github-actions bot pushed a commit to wxx9248/Pickle-Rush that referenced this pull request Aug 12, 2024
…4.8 (#108)

Bumps
[pyinstaller-hooks-contrib](https://github.com/pyinstaller/pyinstaller-hooks-contrib)
from 2024.7 to 2024.8.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/pyinstaller/pyinstaller-hooks-contrib/releases">pyinstaller-hooks-contrib's
releases</a>.</em></p>
<blockquote>
<h2>v2024.8</h2>
<p>Please see the <a
href="https://www.github.com/pyinstaller/pyinstaller-hooks-contrib/tree/v2024.8/CHANGELOG.rst">changelog</a>
for more details</p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/pyinstaller/pyinstaller-hooks-contrib/blob/master/CHANGELOG.rst">pyinstaller-hooks-contrib's
changelog</a>.</em></p>
<blockquote>
<h2>2024.8 (2024-08-09)</h2>
<p>New hooks</p>
<pre><code>
* Add a hook for ``cmocean``, which has text data files.
(`[#769](pyinstaller/pyinstaller-hooks-contrib#769)

&lt;https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/769&gt;`_)
* Add a hook for ``pydicom``, which has hidden imports.
(`[#776](pyinstaller/pyinstaller-hooks-contrib#776)

&lt;https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/776&gt;`_)
* Add a hook for ``tzwhere``, which has data files.
(`[#772](pyinstaller/pyinstaller-hooks-contrib#772)

&lt;https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/772&gt;`_)
* Add hook for ``monai`` to collect its source .py files for
TorchScript/JIT.

(`[#778](pyinstaller/pyinstaller-hooks-contrib#778)

&lt;https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/778&gt;`_)
* Add hooks for ``itk`` to work around the package's requirements about
the ``itk/Configuration`` directory.
(`[#778](pyinstaller/pyinstaller-hooks-contrib#778)

&lt;https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/778&gt;`_)
* Added hooks for the ``trame`` suite of libraries, which has data files
and
hidden imports.
(`[#775](pyinstaller/pyinstaller-hooks-contrib#775)

&lt;https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/775&gt;`_)
<p>Updated hooks
</code></pre></p>
<ul>
<li>Rework the OpenSSL version check in <code>cryptography</code> hook
to fix
compatibility with <code>cryptography</code> 43.0.0.
(<code>[#768](pyinstaller/pyinstaller-hooks-contrib#768)
&lt;https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/768&gt;</code>_)</li>
<li>Update <code>hydra</code> hook to include work-around for
<code>hydra</code>'s plugin
manager, which under python &lt; 3.10 (still) uses deprecated PEP-302
that was removed from PyInstaller's <code>PyiFrozenImporter</code> in
PyInstaller 5.8. When building using python <!-- raw HTML omitted -->=
5.8,
the modules collected from <code>hydra._internal.core_plugins</code> and
<code>hydra_plugins</code> packages are now collected as source .py
files only;
this way, they are handled by built-in python's finder/importer instead
of PyInstaller's <code>PyiFrozenImporter</code>.
(<code>[#760](pyinstaller/pyinstaller-hooks-contrib#760)
&lt;https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/760&gt;</code>_)</li>
<li>Update <code>imageio_ffmpeg</code> hook for compatibility with
<code>imageio-ffmpeg</code>
0.5.0 and later.
(<code>[#766](pyinstaller/pyinstaller-hooks-contrib#766)
&lt;https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/766&gt;</code>_)</li>
<li>Update <code>pyexcel_ods</code> hook to add missing hidden import
and add tests.

(<code>[#779](pyinstaller/pyinstaller-hooks-contrib#779)
&lt;https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/779&gt;</code>_)</li>
</ul>
<p>Project &amp; Process</p>
<pre><code>
* Released sdists and tagged GitHub source archives contain the
changelog
&lt;/tr&gt;&lt;/table&gt; 
</code></pre>
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/pyinstaller/pyinstaller-hooks-contrib/commit/c1affefbe2bb8a35ecd05f6779727eec5b70eec5"><code>c1affef</code></a>
Release v2024.8</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller-hooks-contrib/commit/1f84e9b0b985a8b47fbb92e16c2c115191545041"><code>1f84e9b</code></a>
Fix release verion bumper</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller-hooks-contrib/commit/46b318260d89f1da5f95962d262b09f25fb0d56c"><code>46b3182</code></a>
Add hooks for trame (<a
href="https://redirect.github.com/pyinstaller/pyinstaller-hooks-contrib/issues/775">#775</a>)</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller-hooks-contrib/commit/4324d79432311672d7fb6970266e9b63fe3780ff"><code>4324d79</code></a>
Add hooks for ITK and MONAI (<a
href="https://redirect.github.com/pyinstaller/pyinstaller-hooks-contrib/issues/778">#778</a>)</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller-hooks-contrib/commit/7e6c20f983aae10f3750766adc2efc89bc100c42"><code>7e6c20f</code></a>
Update hook for pyexcel_ods (<a
href="https://redirect.github.com/pyinstaller/pyinstaller-hooks-contrib/issues/779">#779</a>)</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller-hooks-contrib/commit/28151eae3bc6f026c26469e0960e4aad5d689b17"><code>28151ea</code></a>
Add hook for pydicom (<a
href="https://redirect.github.com/pyinstaller/pyinstaller-hooks-contrib/issues/776">#776</a>)</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller-hooks-contrib/commit/3bec1611b2a49976973dc5e8b526cbd88b977c2e"><code>3bec161</code></a>
Scheduled weekly dependency update for week 31 (<a
href="https://redirect.github.com/pyinstaller/pyinstaller-hooks-contrib/issues/774">#774</a>)</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller-hooks-contrib/commit/39e1cdd75f71a6b89c297f1f6ace9bb942a21020"><code>39e1cdd</code></a>
Add hook for tzwhere (<a
href="https://redirect.github.com/pyinstaller/pyinstaller-hooks-contrib/issues/771">#771</a>)</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller-hooks-contrib/commit/c0d694c8b9b83fffb9d5d308e9ef6b851ca7179f"><code>c0d694c</code></a>
Scheduled weekly dependency update for week 30 (<a
href="https://redirect.github.com/pyinstaller/pyinstaller-hooks-contrib/issues/770">#770</a>)</li>
<li><a
href="https://github.com/pyinstaller/pyinstaller-hooks-contrib/commit/cd3e5e25247d4ae6225b2458872087a3557f1a62"><code>cd3e5e2</code></a>
Add hook for cmocean (<a
href="https://redirect.github.com/pyinstaller/pyinstaller-hooks-contrib/issues/769">#769</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/pyinstaller/pyinstaller-hooks-contrib/compare/2024.7...v2024.8">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pyinstaller-hooks-contrib&package-manager=pip&previous-version=2024.7&new-version=2024.8)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants