-
Notifications
You must be signed in to change notification settings - Fork 617
WIP: [python] Introduce packages option
#768
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
Draft
Alexander Smolyakov (alexander-smolyakov)
wants to merge
10
commits into
devcontainers:main
Choose a base branch
from
alexander-smolyakov:python-introduce_packages_option
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.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6019361
Add info about `packages` and `additionalVersions` inputs
alexander-smolyakov c53818c
Introduce `packages` option
alexander-smolyakov e0dd23b
Rework function to avoid issues with tokenization
alexander-smolyakov b50f5a3
Add tests
alexander-smolyakov 91ffd5b
[test] Update logic for `packages` input
alexander-smolyakov 5ef0e17
Remove `install_user_package` function
alexander-smolyakov e8fb1f1
[test] Rework `install_python_package` function
alexander-smolyakov 0e06679
Update scenarios.json
alexander-smolyakov d1f43d3
Bump minor version
alexander-smolyakov d77c9ed
Merge branch 'main' into python-introduce_packages_option
alexander-smolyakov 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "id": "python", | ||
| "version": "1.3.1", | ||
| "version": "1.4.1", | ||
| "name": "Python", | ||
| "documentationURL": "https://github.com/devcontainers/features/tree/main/src/python", | ||
| "description": "Installs the provided version of Python, as well as PIPX, and other common Python utilities. JupyterLab is conditionally installed with the python feature. Note: May require source code compilation.", | ||
|
|
@@ -22,6 +22,11 @@ | |
| "default": "os-provided", | ||
| "description": "Select a Python version to install." | ||
| }, | ||
| "additionalVersions": { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We intentionally did not publicize this option just because it was experimental. Also, it was meant only to be used by However, if it works great in different test scenarios then it is worth publicizing 🎉 |
||
| "type": "string", | ||
| "default": "", | ||
| "description": "Enter additional Python versions, separated by commas. Use 'X.Y' or 'X.Y.Z' for a specific version" | ||
| }, | ||
| "installTools": { | ||
| "type": "boolean", | ||
| "default": true, | ||
|
|
@@ -47,6 +52,11 @@ | |
| "default": "", | ||
| "description": "Configure JupyterLab to accept HTTP requests from the specified origin" | ||
| }, | ||
| "packages": { | ||
| "type": "string", | ||
| "default": "", | ||
| "description": "Optional comma separated list of Python packages to install with pip" | ||
| }, | ||
| "httpProxy": { | ||
| "type": "string", | ||
| "default": "", | ||
|
|
||
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,31 @@ | ||
| sudo_if() { | ||
| COMMAND="$*" | ||
| if [ "$(id -u)" -eq 0 ] && [ "$USERNAME" != "root" ]; then | ||
| su - "$USERNAME" -c "$COMMAND" | ||
| else | ||
| $COMMAND | ||
| fi | ||
| } | ||
|
|
||
| install_python_package() { | ||
| INSTALL_UNDER_ROOT="$1" | ||
| PYTHON_PATH="$2" | ||
| PACKAGE="$3" | ||
| VERSION="${4:-""}" | ||
|
|
||
| sudo_if "$PYTHON_PATH" -m pip uninstall --yes "$PACKAGE" | ||
|
|
||
| install_package="${PACKAGE}" | ||
|
|
||
| if [ ! -z "${VERSION}" ]; then | ||
| install_package+="==${VERSION}" | ||
| fi | ||
|
|
||
| if [ "$INSTALL_UNDER_ROOT" = true ]; then | ||
| sudo_if "$PYTHON_PATH" -m pip install --upgrade --no-cache-dir "$install_package" | ||
| else | ||
| sudo_if "$PYTHON_PATH" -m pip install --upgrade --user --no-cache-dir "$install_package" | ||
| fi | ||
|
|
||
| sudo_if "$PYTHON_PATH" -m pip --no-python-version-warning show "$PACKAGE" | ||
| } |
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,23 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| # Optional: Import test library | ||
| source dev-container-features-test-lib | ||
|
|
||
| # Always run these checks as the non-root user | ||
| user="$(whoami)" | ||
| check "user" grep vscode <<< "$user" | ||
|
|
||
| # Check for an installation of JupyterLab | ||
| check "version" jupyter lab --version | ||
|
|
||
| # Check location of JupyterLab installation | ||
| packages="$(python3 -m pip list)" | ||
| check "location" grep jupyter <<< "$packages" | ||
|
|
||
| # Check for git extension | ||
| check "jupyterlab_git" grep jupyterlab_git <<< "$packages" | ||
|
|
||
| # Report result | ||
| reportResults |
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,23 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| # Optional: Import test library | ||
| source dev-container-features-test-lib | ||
|
|
||
| # Always run these checks as the non-root user | ||
| user="$(whoami)" | ||
| check "user" grep vscode <<< "$user" | ||
|
|
||
| # Check for an installation of JupyterLab | ||
| check "version" jupyter lab --version | ||
|
|
||
| # Check location of JupyterLab installation | ||
| packages="$(python3 -m pip list)" | ||
| check "location" grep jupyter <<< "$packages" | ||
|
|
||
| # Check for git extension | ||
| check "jupyterlab_git" grep jupyterlab_git <<< "$packages" | ||
|
|
||
| # Report result | ||
| reportResults |
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/bash | ||
|
|
||
| set -e | ||
|
|
||
| # Optional: Import test library | ||
| source dev-container-features-test-lib | ||
|
|
||
| # Check for an installation of JupyterLab | ||
| check "version" jupyter lab --version | ||
|
|
||
| # Check location of JupyterLab installation | ||
| packages="$(python3 -m pip list)" | ||
| check "location" grep jupyter <<< "$packages" | ||
|
|
||
| # Check for git extension | ||
| check "jupyterlab_git" grep jupyterlab_git <<< "$packages" | ||
|
|
||
| # Report result | ||
| reportResults |
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,23 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| # Optional: Import test library | ||
| source dev-container-features-test-lib | ||
|
|
||
| # Always run these checks as the non-root user | ||
| user="$(whoami)" | ||
| check "user" grep vscode <<< "$user" | ||
|
|
||
| # Check for an installation of JupyterLab | ||
| check "version" jupyter lab --version | ||
|
|
||
| # Check location of JupyterLab installation | ||
| packages="$(python3 -m pip list)" | ||
| check "location" grep jupyter <<< "$packages" | ||
|
|
||
| # Check for git extension | ||
| check "jupyterlab_git" grep jupyterlab_git <<< "$packages" | ||
|
|
||
| # Report result | ||
| reportResults |
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
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.