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

zip: read all non-zip data from --preamble_from file #22

Merged

Conversation

chrisnovakovic
Copy link
Contributor

The zip command's --preamble_from option, as used by Please's python-rules plugin, has strange semantics. The help text says it reads the first line from the given file and uses it as the preamble for the generated zip file, which is true unless the first line is #!/bin/sh, in which case the second line will also be read. The second line of "main" pex files generated by python-rules contain an exec command, allowing them to self-execute with more arguments than would otherwise be supported in a traditional shebang.

Genericise the behaviour of --preamble_from so that it is useful for more than just files that begin with 1 or 2-line shell commands - assume the input is a zip file (a tacit assumption until now), and read all non-zip data from the start of the file and use it as the preamble for the generated zip file.

Because python-rules' pex files are either pure zip files or zip files prepended with a 1 or 2-line shell command, this does not break backwards compatibility with python-rules.

The `zip` command's `--preamble_from` option, as used by Please's
python-rules plugin, has strange semantics. The help text says it reads
the first line from the given file and uses it as the preamble for the
generated zip file, which is true unless the first line is `#!/bin/sh`,
in which case the second line will also be read. The second line of
"main" pex files generated by python-rules contain an `exec` command,
allowing them to self-execute with more arguments than would otherwise
be supported in a traditional shebang.

Genericise the behaviour of `--preamble_from` so that it is useful for
more than just files that begin with 1 or 2-line shell commands - assume
the input is a zip file (a tacit assumption until now), and read all
non-zip data from the start of the file and use it as the preamble for
the generated zip file.

Because python-rules' pex files are either pure zip files or zip files
prepended with a 1 or 2-line shell command, this does not break
backwards compatibility with python-rules.
Copy link
Contributor

Choose a reason for hiding this comment

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

Awwwww

@chrisnovakovic chrisnovakovic merged commit 62f95c1 into please-build:master Oct 21, 2024
2 checks passed
@chrisnovakovic chrisnovakovic deleted the preamble_from-non-zip-data branch October 21, 2024 09:41
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