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

Add support for distributing rules as python packages (pluggy) #4354

Open
wimglenn opened this issue Oct 2, 2024 · 4 comments
Open

Add support for distributing rules as python packages (pluggy) #4354

wimglenn opened this issue Oct 2, 2024 · 4 comments
Labels

Comments

@wimglenn
Copy link
Contributor

wimglenn commented Oct 2, 2024

When developing a custom lint rule as described in Packaging Custom Rules, the lint is not available if installed with pip install -e ./my-custom-lint. The same lint is available (and appears in ansible-lint --list-rules) when doing pip install ./my-custom-lint.

I'm using setuptools and the editable installation mode is the thing with an __editable__ .pth file in site-packages which installs a meta-path finder. Trying all modes with --config-settings editable_mode=compat, --config-settings editable_mode=strict, --config-settings editable_mode=lenient, none of them works.

Maybe relevant: unlike the "normal" install, an editable install doesn't create files under .../site-packages/ansiblelint/rules/custom/. I didn't check how ansible-lint discovers custom rules, but perhaps an entry-point group would be worth considering.

@wimglenn wimglenn added bug new Triage required labels Oct 2, 2024
@alisonlhart alisonlhart changed the title Custom lints can not be installed editable Add support for distributing rules as python packages (pluggy) Oct 30, 2024
@alisonlhart alisonlhart added feature and removed bug new Triage required labels Oct 30, 2024
@alisonlhart
Copy link
Contributor

We have renamed this and changed it to a feature request, as it is not something currently possible with ansible-lint.

@wimglenn
Copy link
Contributor Author

wimglenn commented Oct 30, 2024

@alisonlhart I am confused by the rename / change to a feature request.

Distributing rules as Python packages is already possible, and it is even officially documented at Creating Custom Rules for Ansible Lint, section Packaging Custom Rules. I am using custom rules packages in production already. It's only editable installations which aren’t discovered, and that is clearly a bug. Could you undo this change, or explain what I'm missing here?

@ssbarnea
Copy link
Member

@wimglenn You are right, misssed https://www.ansible.com/blog/creating-custom-rules-for-ansible-lint/ as is not part of upstream docs. In fact the way is documented is not really what I would do these days. Instead I would fully switch to pluggy instead and deprecated the old method. This should sort the problem of editable and many other problems.

@wimglenn
Copy link
Contributor Author

Thank you @ssbarnea, that makes more sense. I agree that a switch to pluggy would be a good idea here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Roadmap
Development

No branches or pull requests

3 participants