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

dconf - Try to find a Python interpreter that has gi.repository.GLib #6491

Merged
merged 5 commits into from
May 8, 2023

Conversation

jikamens
Copy link
Contributor

@jikamens jikamens commented May 4, 2023

SUMMARY

If we're invoked in a Python interpreter that doesn't have access to gi.repository.GLib, try to find one that does and respawn the task in that interpreter.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

dconf

ADDITIONAL INFORMATION

As suggested by @felixfontein in #6049 (comment) .

jikamens added 2 commits May 4, 2023 17:40
If we're invoked in a Python interpreter that doesn't have access to
`gi.repository.GLib`, try to find one that does and respawn the task
in that interpreter.
@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module plugins plugin (any type) labels May 4, 2023
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-6 labels May 5, 2023
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

Copy link
Collaborator

@russoz russoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed feelings about this "respawning" business - it feels like a McGyver solution to a problem that should not happen if the execution environment is built properly to begin with with.

That being said, I see that same mechanism used in apt_repo, apt, dnf, dnf5, package_facts and yum, as well as in c.g.portage.

If we must, a slightly better way of doing this IMO would be to encapsulate that module-search-and-respawn logic into a function, drop it in module_utils.respawn and use it in all those modules, instead of repeating that same code everywhere.

@jikamens
Copy link
Contributor Author

jikamens commented May 7, 2023

You're not wrong, but I would prefer not to have the work to refactor how this gets done piled onto me and hold up getting this change merged when I'm not a major contributor to the project and I'm just trying to make my module solve this problem the way that, as you pointed out, many other modules already solve it.

@felixfontein
Copy link
Collaborator

Mixed feelings about this "respawning" business - it feels like a McGyver solution to a problem that should not happen if the execution environment is built properly to begin with with.

That doesn't work since the Python libraries this module (and others you mentioned) need are part of the system libraries and only available for the system Python interpreter, and cannot be installed for any other Python interpreter without major hacks. Respawning is the least worst solution to this problem.

@felixfontein felixfontein merged commit 9f3c86a into ansible-collections:main May 8, 2023
@patchback
Copy link

patchback bot commented May 8, 2023

Backport to stable-6: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-6/9f3c86a589b556d9016b04027aae79e43bc21df4/pr-6491

Backported as #6504

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label May 8, 2023
patchback bot pushed a commit that referenced this pull request May 8, 2023
…6491)

* dconf - Try to find a Python interpreter that has gi.repository.GLib

If we're invoked in a Python interpreter that doesn't have access to
`gi.repository.GLib`, try to find one that does and respawn the task
in that interpreter.

* ChangeLog fragment for #6491

* Update changelogs/fragments/6491-dconf-respawn.yml

Co-authored-by: Felix Fontein <[email protected]>

* Simplify import code

* Get rid of ModuleNotFoundError

---------

Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit 9f3c86a)
@felixfontein
Copy link
Collaborator

@jikamens thanks a lot for your contribution!
@russoz thanks for reviewing!

felixfontein pushed a commit that referenced this pull request May 8, 2023
…nterpreter that has gi.repository.GLib (#6504)

dconf - Try to find a Python interpreter that has gi.repository.GLib (#6491)

* dconf - Try to find a Python interpreter that has gi.repository.GLib

If we're invoked in a Python interpreter that doesn't have access to
`gi.repository.GLib`, try to find one that does and respawn the task
in that interpreter.

* ChangeLog fragment for #6491

* Update changelogs/fragments/6491-dconf-respawn.yml

Co-authored-by: Felix Fontein <[email protected]>

* Simplify import code

* Get rid of ModuleNotFoundError

---------

Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit 9f3c86a)

Co-authored-by: Jonathan Kamens <[email protected]>
@jikamens jikamens deleted the respawn branch July 31, 2023 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants