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

archive: fix stored paths when building under MSYS #5569

Merged
merged 1 commit into from Feb 27, 2021

Conversation

rokm
Copy link
Member

@rokm rokm commented Feb 19, 2021

When building CArchive package under MSYS, os.path.sep is Unix-style forward clash separator that is incompatible with bootloader (which on Windows expects back slash separators). Therefore, if we are on Windows and os.path.sep is forward slash, os.path.normpath() in CTOC.add() needs to be followed by explicit replacement of forward slashes with back slashes.

Otherwise, bootloader fails to extract nested files from archive in onefile builds that are created in MSYS environment.

Fixes second part of the issue reported in #5560.

When building CArchive package under MSYS, os.path.sep is Unix-style
forward clash separator that is incompatible with bootloader (which
on Windows expects back slash separators). Therefore, if we are on
Windows and os.path.sep is forward slash, os.path.normpath() in
CTOC.add() needs to be followed by explicit replacement of forward
slashes with back slashes.

Otherwise, bootloader fails to extract nested files from archive in
onefile builds that are created in MSYS environment.
@rokm rokm force-pushed the fix-msys-onefile-extraction branch from a07e5ea to 2bafa18 Compare February 19, 2021 12:52
@rokm rokm marked this pull request as ready for review February 21, 2021 17:42
@Legorooj
Copy link
Member

Interesting... I was under the impression that windows supported / as a path seperator.

@bwoodsend bwoodsend merged commit d772654 into pyinstaller:develop Feb 27, 2021
@rokm
Copy link
Member Author

rokm commented Feb 27, 2021

Interesting... I was under the impression that windows supported / as a path seperator.

Windows probably does, but our bootloader supports only \ as path separator on Windows:

#ifdef _WIN32
#define PYI_PATHSEP ';'
#define PYI_CURDIR '.'
#define PYI_SEP '\\'
/*
* For some functions like strcat() we need to pass
* string and not only char.
*/
#define PYI_SEPSTR "\\"
#define PYI_PATHSEPSTR ";"
#define PYI_CURDIRSTR "."
#else
#define PYI_PATHSEP ':'
#define PYI_CURDIR '.'
#define PYI_SEP '/'
#define PYI_SEPSTR "/"
#define PYI_PATHSEPSTR ":"
#define PYI_CURDIRSTR "."
#endif

For example, pyi_path_dirname on Windows essentially searches for last occurrence of PYI_SEP, so with gi/_gi-cpython-38.dll from #5560, it came up empty...

@rokm rokm deleted the fix-msys-onefile-extraction branch February 27, 2021 10:00
@Legorooj
Copy link
Member

ah so it's a limitation of the bootloader, not the OS. of course.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
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

3 participants