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

fix: make ansible-core an optional extra-dependency #631

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .woodpecker/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ steps:
image: docker.io/library/python:3.12
commands:
- pip install poetry poetry-dynamic-versioning -qq
- poetry install
- poetry install -E ansible-core
- poetry run ruff format --check --diff ./${CI_REPO_NAME//-/}
environment:
PY_COLORS: "1"
Expand All @@ -19,7 +19,7 @@ steps:
image: docker.io/library/python:3.12
commands:
- pip install poetry poetry-dynamic-versioning -qq
- poetry install
- poetry install -E ansible-core
- poetry run ruff ./${CI_REPO_NAME//-/}
environment:
PY_COLORS: "1"
2 changes: 1 addition & 1 deletion .woodpecker/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ variables:
group: pytest
commands:
- pip install poetry poetry-dynamic-versioning -qq
- poetry install
- poetry install -E ansible-core
- poetry version
- poetry run ${CI_REPO_NAME} --help
environment:
Expand Down
2 changes: 1 addition & 1 deletion Containerfile.multiarch
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ADD dist/ansible_doctor-*.whl /

RUN apk --update add --virtual .build-deps build-base libffi-dev openssl-dev && \
pip install --upgrade --no-cache-dir pip && \
pip install --no-cache-dir $(find / -name "ansible_doctor-*.whl") && \
pip install --no-cache-dir $(find / -name "ansible_doctor-*.whl")[ansible-core] && \
rm -f ansible_doctor-*.whl && \
rm -rf /var/cache/apk/* && \
rm -rf /root/.cache/
Expand Down
7 changes: 7 additions & 0 deletions ansibledoctor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""Provide version information."""

__version__ = "0.0.0"

import sys

try:
import ansible # noqa
except ImportError:
sys.exit("ERROR: Python requirements are missing: 'ansible-core' not found.")
9 changes: 4 additions & 5 deletions ansibledoctor/utils/yamlhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from contextlib import suppress

import ruamel.yaml
import yaml
from ansible.parsing.yaml.loader import AnsibleLoader

import ansibledoctor.exception
Expand All @@ -28,10 +27,10 @@ def parse_yaml_ansible(yamlfile):
loader = AnsibleLoader(yamlfile)
data = loader.get_single_data() or []
except (
yaml.parser.ParserError,
yaml.scanner.ScannerError,
yaml.constructor.ConstructorError,
yaml.composer.ComposerError,
ruamel.yaml.parser.ParserError,
ruamel.yaml.scanner.ScannerError,
ruamel.yaml.constructor.ConstructorError,
ruamel.yaml.composer.ComposerError,
) as e:
message = (
f"{e.context} in line {e.context_mark.line}, column {e.context_mark.line}\n"
Expand Down
7 changes: 4 additions & 3 deletions docs/content/setup/pip.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ title: Using pip

```Shell
# From PyPI as unprivileged user
$ pip install ansible-doctor --user
$ pip install ansible-doctor[ansible-core] --user

# .. or as root
$ sudo pip install ansible-doctor
$ sudo pip install ansible-doctor[ansible-core]

# From Wheel file
$ pip install https://github.com/thegeeklab/ansible-doctor/releases/download/v0.1.1/ansible_doctor-0.1.1-py2.py3-none-any.whl
# Please check first whether a newer version is available.
$ pip install https://github.com/thegeeklab/ansible-doctor/releases/download/v3.1.4/ansible_doctor-3.1.4-py2.py3-none-any.whl[ansible-core]
```
17 changes: 10 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ pathspec = "0.12.1"
python = "^3.8.0"
python-json-logger = "2.0.7"
"ruamel.yaml" = "0.18.5"
ansible-core = "^2.13"
ansible-core = {version = "2.13.13", optional = true}

[tool.poetry.extras]
ansible-core = ["ansible-core"]

[tool.poetry.scripts]
ansible-doctor = "ansibledoctor.cli:main"
Expand Down