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

Seasonal cleanup #8126

Merged
merged 14 commits into from
Nov 26, 2023
Merged

Seasonal cleanup #8126

merged 14 commits into from
Nov 26, 2023

Conversation

rokm
Copy link
Member

@rokm rokm commented Nov 26, 2023

Assorted clean up in various parts of codebase:

  • fix the test failures seen in makespec: Use portable path separators #8116
  • fix a PytestReturnNotNoneWarning by refactoring a test in modulegraph's test suite
  • use importlib.util.decode_source to decode source .py files and remove the modulegraph.util.guess_encoding
  • remove modulegraph.zipio module (we do not support zipped eggs anymore)
  • clean up modulegraph.find_modules.get_implies - get rid of python2-only modules
  • remove python2-specific code in modulegraph code and its test suite
  • remove some modulegraph code that is not used anywhere except for its test suite
  • mop up the remaining PEP 597 EncodingWarning that are under our control
  • replace pkgutil.find_loader in PyInstaller.utils.hooks.get_module_file_attribute due to deprecation warning in 3.12

Change the Analysis.toc filename matching pattern in
data-vs-binary-reclassification tests from `Analysis-??.toc`
to `Analysis-*.toc` to account for numbers beyond 99, which
can (and do) occur on our CI.
Fix a PytestReturnNotNoneWarning caused by one of the tests
returning an modulegraph instance for use in another test.
Refactor the code into a helper (non-test) function and two
tests using it.
Remove `modulegraph._compat` as we have no reason for carrying
python2-specific code. Similarly, remove dead codepaths for
out-of-support python versions from the main `modulegraph` module.
Use `importlib.util.decode_source` to decode source of input .py
scripts. This also alleviates the need to worry about UTF8 BOM
marker. Also, we do not need to append the newline anymore; since
python 3.2, `compile` with 'exec' mode does not have to end in a
newline anymore.

Also use `decode_source` when reading code of modules and scanning
them for the SWIG identification line.

Remove the `modulegraph.util.guess_encoding`, its test suite, and
remaining use in sqlalchemy hook.
Aside from its corresponding test suite, the only use of
functionality from this module was `zipio.listdir` in
`_find_all_submodules`, which seems to be called by
`_import_importable_package_submodules` to deal with
`from ... import *` statements.

As we do not support zipped eggs anymore, this should be
superfluous. If it turns out to break "portable" python on
Windows (which has stdlib modules in a .zip file), we can
bring back just the minimal required part of the code.
Remove python2-specific stuff from `get_implies`, and clean up
its general structure.
Remove some more functions from modulegraph that appear to be
used only in its test suite, and thus have no real purpose.
Remove bunch of python2-specific code from the modulegraph
test suite.
Add encoding='utf8' to `objdump` process call in binary-vs-data
classification on linux, to silence an `EncodingWarning`.
The `pkgutil.find_loader` function emits a deprecation warning
starting with python 3.12. So instead obtain the module's spec
(`importlib.util.find_spec`) and the loader from its `loader`
attribute.

Extend the handled error types to include `TypeError` and
`ValueError`, which were previously turned into `ImportError`
by `pkgutil.find_loader` behind the scenes.
When trying to determine the type of Tcl/Tk installation on
macOS by reading the `init.tcl` file, assume the UTF-8 encoding
instead if trying to query it via `locale.getpreferredencoding`
to avoid an `EncodingWarning`.
@rokm rokm merged commit 494bfad into pyinstaller:develop Nov 26, 2023
18 checks passed
@rokm rokm deleted the seasonal-cleanup branch November 26, 2023 15:24
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants