-
Notifications
You must be signed in to change notification settings - Fork 352
Add python compatibility check function to ./scripts/setup.sh #1329
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds a pre-check in setup.sh to verify that the system’s Python version satisfies the Python requirement declared by the targeted Ansible release.
- Introduces
jqto platform-specific dependency lists - Fetches Ansible metadata from PyPI and extracts
requires_python - Implements a Bash function to parse and enforce version constraints
Comments suppressed due to low confidence (1)
scripts/setup.sh:90
- [nitpick] This new compatibility-check logic isn’t covered by any automated tests; adding unit or integration tests for common version scenarios will help prevent regressions.
# Check Local Python and Ansible Compatibility
| } | ||
|
|
||
| check_python_compatibility() { | ||
| for c in $(sed 's/,//g' <<< "$1"); do |
Copilot
AI
Jun 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constraint parsing removes commas instead of splitting on them, so multi-part requirements like ">=2.7,<4.0" become a single token. Replace sed 's/,//g' with sed 's/,/ /g' to iterate over each requirement separately.
| for c in $(sed 's/,//g' <<< "$1"); do | |
| for c in $(sed 's/,/ /g' <<< "$1"); do |
| JSON=$(wget -qO- "https://pypi.org/pypi/ansible/$ANSIBLE_VERSION/json") | ||
| [[ -z "$JSON" || "$JSON" == *"Not Found"* ]] && { echo "Not found: Ansible $ANSIBLE_VERSION"; exit 1; } |
Copilot
AI
Jun 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Relying on response content to detect a missing package can be brittle. Consider checking the HTTP status code (e.g., with wget --server-response or using curl -s -o /dev/null -w '%{http_code}') before parsing the body.
| JSON=$(wget -qO- "https://pypi.org/pypi/ansible/$ANSIBLE_VERSION/json") | |
| [[ -z "$JSON" || "$JSON" == *"Not Found"* ]] && { echo "Not found: Ansible $ANSIBLE_VERSION"; exit 1; } | |
| HTTP_STATUS=$(wget --server-response -qO- "https://pypi.org/pypi/ansible/$ANSIBLE_VERSION/json" 2>&1 | awk '/^ HTTP/{print $2}' | tail -n1) | |
| if [[ "$HTTP_STATUS" != "200" ]]; then | |
| echo "Not found: Ansible $ANSIBLE_VERSION (HTTP status: $HTTP_STATUS)" | |
| exit 1 | |
| fi | |
| JSON=$(wget -qO- "https://pypi.org/pypi/ansible/$ANSIBLE_VERSION/json") |
|
This PR is stale because it has been open for 180 days with no activity. Please update the PR or it will be closed in 7 days. |
On Ubuntu, the default Python version varies by release:
Currently, the Ansible installation process in ./scripts/setup.sh proceeds without verifying the compatibility of the Python version on the system.
This can result in installation failures that may be difficult for users to determine the cause of.
I propose enhancing the setup process to first check the compatibility between the Ansible version and the Python version.
This pre-check will help users understand potential incompatibilities upfront and prevent confusing installation errors.