WIP: [python] Introduce `packages` option
General info
Feature name:
- ghcr.io/devcontainers/features/python
Attached related issue:
- https://github.com/devcontainers/images/issues/856
Description:
This PR introduces a new option - packages. The new option receives a comma-spread string as input. The input contains packages that should be installed during the feature installation process.
User experience
The user can specify a package version that would be installed. Usage examples:
Example 1:
{
"ghcr.io/devcontainers/features/python:1": {
"version": "3.10.12",
"packages": "torch,request,aiohttp"
},
}
Note: In this example, the feature installs the latest versions available in PIP.
Example 2:
{
"ghcr.io/devcontainers/features/python:1": {
"version": "3.10.12",
"packages": "cryptography==41.0.4,urllib3==1.26.18"
},
}
Note: In this case, the feature install versions were explicitly pointed out in the devcontainer.json.
Installation process
The feature already contains the install_user_package function. Considering new functionality, the function should be updated, and the installation process should be split into two steps:
- Uninstall the older package version if it was installed or shipped with Python;
- Install the new package version;
The installation folder will be resolved based on the user under which the feature is installed:
- root: packages will be installed in Python's
site-packagesfolder; - non-root users: packages will be installed in the user's
site-packagesfolder;
Changelog
-
Added info about
packagesandadditionalVersionsinputs; -
Introduced the
packagesoption:- Added logic to handle
packagesinput; - Implemented the
install_python_packagefunction to replace theinstall_user_packagefunction; - The
sudo_iffunction moved to theutils.shfile;
- Added logic to handle
-
Added tests to cover new functionality;
Checklist:
- [ ] Checked that applied changes work as expected