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

Allow users to re-enable the old onedir layout #7968

Merged
merged 6 commits into from Sep 30, 2023

Conversation

rokm
Copy link
Member

@rokm rokm commented Sep 30, 2023

Allow users to re-enable the old onedir layout (without contents directory) by settings the --contents-directory option (or the equivalent contents_directory argument to EXE in the .spec file) to ..

Clean up and document the multipackage dependency extration code
in an attempt to make it easier to read.

When determining the parent directory of the current exectuable
(the former `homepath_parent`, now `this_executable_dir`), use
`executablename` member of `ARCHIVE_STATUS` instead of `homepath`,
as the latter is affected by the contents-directory option while
the former is not. (And this seems to work for onefile builds
because `homepath` there is also affected by contents-directory,
even through it should be not).

Remove the useless else-if branch, whose condition is now
identical to that of the preceding if condition. It was very likely
unused even in its original form, where it attempted to find the
dependency by jumping to the parent directory of the directory
containing the executable, and then applying relative path to the
other executable. However, this relative path should already
encode the relative relation between the executables (accounting
for all four possible combinations regaring build types), and as
such jumping one directory higher would never work.

Fix the path check for the external .PKG archive (side-load mode).
Such archive is located next to the executable, and is not a subject
to contents-directory setting.
Allow pyi-contents-directory option to be unset, which re-enables
the old layout for onedir builds, where files are placed next to
the executable (instead of placing them into sub-directory).
Copy link
Member

@bwoodsend bwoodsend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't see a use for this beyond accommodating broken code

@bwoodsend bwoodsend linked an issue Sep 30, 2023 that may be closed by this pull request
Allow user to re-enable old onedir layout without contents
directory. This can be done by setting `contents_directory`
argument to `EXE` in the spec to either ".", "", or None (all
three values are effectively mapped to None, which prevents
the `pyi-contents-directory` bootloader option from being set).
On command line, the equivalent can be achieved by passing "."
to `--contents-directory` command-line option.
Append contents-directory path to homepath member of ARCHIVE_STATUS
only in onedir mode (i.e., if we do not need to extract the
archive).

This implies that we need to check whether extraction is required
when we open the archive (before homepath is set), so move the
corresponding code into `pyi_arch_setup`.
Test for `..` as an invalid contents-directory option instead of
`.`, which is now valid.
Add a basic test with --contents-directory=. that checks if
`sys._MEIPASS` == `os.path.dirname(sys.executable)`, which should
be the case in the legacy onedir layout.
@rokm
Copy link
Member Author

rokm commented Sep 30, 2023

I still don't see a use for this beyond accommodating broken code

Indeed. But we can spend our time on better things than arguing this point with the users (or having to implement dubious work-arounds such as support for collection outside of the _MEIPASS).

@rokm rokm merged commit bc51355 into pyinstaller:develop Sep 30, 2023
18 checks passed
@rokm rokm deleted the optional-old-onedir-layout branch September 30, 2023 19:58
@CarlGao4
Copy link

CarlGao4 commented Oct 6, 2023

Hello, when can we see this feature to be released?

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.

Make it possible to put files outside of contents_diretory
3 participants