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

RHOAIENG-11216: Add script to automate the creation of a new Python-based image from an existing one #672

Merged
merged 12 commits into from
Aug 15, 2024
29 changes: 29 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,32 @@ Update the `pandas` library to version `2.2.2` in all files under `./myproject`
./update_library_version.sh ./myproject pandas 2.2.2 'include|this' 'exclude|that' false
```

## new_python_based_image.py

This Python script generates a new folder structure for a Python-based project by copying an existing one and updating Python version references. It performs the following steps:

1. Copy Folder: Duplicates the specified folder structure.
1. Update Python Versions: Replaces occurrences of the source Python version with the target version throughout the folder.
1. Update Lock Files: Executes `pipenv lock` to regenerate lock files based on the new Python version.

If `pipenv lock` encounters errors, manual intervention is required to resolve compatibility issues between dependencies. Review the errors reported by `pipenv` and adjust the dependencies as needed.

### Examples

Create a Python 3.12 version based on the Python 3.9 version for each one that is in the `./base` directory:

```sh
python scripts/new_python_based_image.py --context-dir . --source 3.9 --target 3.12 --match ./base
```

Create a Python 3.11 version based on the Python 3.9 versions for each one that is in the `./jupyter/rocm` directory:

```sh
python scripts/new_python_based_image.py --context-dir . --source 3.9 --target 3.11 --match ./jupyter/rocm
```

Create a Python 3.11 version based on the Python 3.9 version for each one in the repository with `DEBUG` logs enabled:

```sh
python scripts/new_python_based_image.py --context-dir . --source 3.9 --target 3.11 --match ./ --log-level DEBUG
```
Loading