-
-
Notifications
You must be signed in to change notification settings - Fork 681
feat(venv): make wheel scripts runnable in venv #3743
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
Open
rickeylev
wants to merge
48
commits into
bazel-contrib:main
Choose a base branch
from
rickeylev:venv.bin.runnable
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+513
−55
Open
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
b4e6496
basic impl
rickeylev c676d6e
fix tests
rickeylev 10ace3b
dont pass select to repo-generated init creation
rickeylev 0fd7c6d
fix testing on workspace
rickeylev 7d2893f
Merge branch 'main' of https://github.com/bazel-contrib/rules_python …
rickeylev 16c5100
format, lint fix
rickeylev 9e53c53
fix pip example
rickeylev 76cc0e0
format
rickeylev 9470aac
test: fix windows paths for whl_with_data test
rickeylev 5b57de2
fix: prevent grouping of top-level bin, include, and data in venvs
rickeylev 103ec9a
fix: add alias for is_venvs_site_packages and add whl_with_data to wo…
rickeylev f41bfda
fix: add WORKSPACE file and export all files in whl_with_data repo
rickeylev fe1ad5f
revert: rename of is_venvs_site_packages and whl_with_data workspace …
rickeylev b35951a
fix: add bazel_skylib to pip_parse_vendored example
rickeylev 52dfac5
fix: add bazel_skylib to multi_python_versions and pip_parse examples
rickeylev 45611a5
docs: add DATA field to VenvSymlinkKind docstring
rickeylev fd6cda6
fix: undefined data_arg in whl_library_targets.bzl
rickeylev 958e61e
fix: robustness in venvs_site_packages_libs_test for Windows paths
rickeylev 194693c
fix: make bin/s3cmd expectation conditional in pip_parse_test.py
rickeylev 82b9acc
refactor: rename is_venvs_site_packages to _is_venvs_site_packages
rickeylev dd2b0b3
pass create_inits() non-selet value, add select value afterwards
rickeylev 3ed727e
change test to enforce windows uses Scripts/Include in venv
rickeylev 7561c72
make pip_parse_test.py work with venv_site_packages
rickeylev 24a94a2
add second wheel with data to test merging/overlap. rename first
rickeylev 1fabeea
format
rickeylev 473966b
revert passing bzlmod/venv_site_packages to pip_parse_test. not neede…
rickeylev dd5d8c2
remove defunct comment
rickeylev 08aeea4
(re)add _yes suffix to is_venv_site_packages config setting
rickeylev 747f7cb
add basis for data overlap test
rickeylev 03da47f
add overlap tests for include, bin; cleanup test
rickeylev de2a11f
format
rickeylev 82e9e2a
make tests pass with workspace
rickeylev cdb2cf1
lint
rickeylev e7ca80d
tests: support whl_from_dir_repo on Windows
rickeylev e16757e
Merge branch 'main' into chore.win.whl.tests
rickeylev e35d1a4
move data scheme to venv root
rickeylev e38fd1c
move cannot_be_linked_directly init earlier
rickeylev 9184bcc
re-add data prefix to pip_parse test. It is verifying the whl_library…
rickeylev db05136
Merge branch 'main' of https://github.com/bazel-contrib/rules_python …
rickeylev 51f614b
handle when directly linking to a file on windows
rickeylev 9681318
always incldue data label
rickeylev 50cc8f0
update changelog
rickeylev cd18acc
cleanup
rickeylev 8c3daaa
Merge branch 'chore.win.whl.tests' into whl.with.data
rickeylev 835d0a9
Merge branch 'main' of https://github.com/bazel-contrib/rules_python …
rickeylev f08b096
feat(venv): make installed wheel scripts runnable
rickeylev ec6926e
feat: make wheel entry points runnable in venv
rickeylev 181c4a5
skip runnable test on windows
rickeylev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| [CmdletBinding()] | ||
| param( | ||
| [Parameter(Position=0, Mandatory=$true)] | ||
| [string]$InFile, | ||
|
|
||
| [Parameter(Position=1, Mandatory=$true)] | ||
| [string]$OutFile | ||
| ) | ||
|
|
||
| if ($InFile.EndsWith(".exe") -or $InFile.EndsWith(".dll")) { | ||
| Copy-Item -Path $InFile -Destination $OutFile | ||
| exit 0 | ||
| } | ||
|
|
||
| $firstLine = Get-Content -Path $InFile -TotalCount 1 -ErrorAction SilentlyContinue | ||
|
|
||
| if ($firstLine -match "^#!python") { | ||
| $content = Get-Content -Path $InFile | Select-Object -Skip 1 | ||
| $wrapper = @' | ||
| #!/bin/sh | ||
| '''exec' "$(dirname "$0")/python3" "$0" "$@" | ||
| ' ''' | ||
|
rickeylev marked this conversation as resolved.
|
||
| '@ | ||
| Set-Content -Path $OutFile -Value $wrapper -Encoding UTF8 | ||
| Add-Content -Path $OutFile -Value $content -Encoding UTF8 | ||
| } else { | ||
| Copy-Item -Path $InFile -Destination $OutFile | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/bin/sh | ||
| set -eu | ||
|
|
||
| IN="$1" | ||
| OUT="$2" | ||
|
|
||
| if head -n 1 "$IN" | grep -q "^#!python"; then | ||
| echo "#!/bin/sh" > "$OUT" | ||
| # Polyglot re-exec gibberish. | ||
| # Shell treats first line's quotes as a quoted command to execute. It then | ||
| # re-execs itself with Python, which treats the triple quoted strings | ||
| # as plain strings and ignores them. | ||
| echo "'''exec' \"\$(dirname \"\$0\")/python3\" \"\$0\" \"\$@\"" >> "$OUT" | ||
|
rickeylev marked this conversation as resolved.
|
||
| echo "' '''" >> "$OUT" | ||
| tail -n +2 "$IN" >> "$OUT" | ||
| else | ||
| cp "$IN" "$OUT" | ||
| fi | ||
| chmod +x "$OUT" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.