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

Makefile: make python externals available without venv #223

Closed
wants to merge 1 commit into from

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Sep 25, 2024

To run the pyton externals currently a venv is needed. However things work fine without except for this.

This commit tweaks the way the externals are made available so that no venv is needed by just creating small wrapper binaries.

Followup for #204 Closes: #201 (at least for me)

To run the pyton externals currently a venv is needed. However
things work fine without except for this.

This commit tweaks the way the externals are made available so
that no venv is needed by just creating small wrapper binaries.

Followup for osbuild#204
Closes: osbuild#201 (at least for me)
cp $(shell (which "osbuild-make-depsolve-dnf4-curl-source")) ./external/
echo '#!/usr/bin/python3 -motk_external_osbuild.command.gen_depsolve_dnf4' > ./external/osbuild-gen-depsolve-dnf4
echo '#!/usr/bin/python3 -motk_external_osbuild.command.make_depsolve_dnf4_rpm_stage' > ./external/osbuild-make-depsolve-dnf4-rpm-stage
echo '#!/usr/bin/python3 -motk_external_osbuild.command.make_depsolve_dnf4_curl_source'> ./external/osbuild-make-depsolve-dnf4-curl-source
Copy link
Member

Choose a reason for hiding this comment

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

This still requires otk_external_osbuild to be installed somewhere on an importable Python path which won't be by default in the repository root right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It requires PYTHONPATH=./src or similar when outside the venv and it inside it works except it does not :(

mvogt@top:~/devel/osbuild/otk$ python3 -m venv venv
mvogt@top:~/devel/osbuild/otk$  . venv/bin/activate
(venv) mvogt@top:~/devel/osbuild/otk$ pip install -e ".[dev]"
...
$ echo {}|python3 -motk_external_osbuild.command.gen_depsolve_dnf4
...
KeyError: 'tree'
$ make test
...
E           otk.error.ExternalFailedError: call: PosixPath('external/osbuild-gen-depsolve-dnf4') 'otk.external.osbuild-gen-depsolve-dnf4' failed: '', "/usr/bin/python3: Error while finding module specification for 'otk_external_osbuild.command.gen_depsolve_dnf4' (ModuleNotFoundError: No module named 'otk_external_osbuild')\n"

apparently because VIRTUAL_ENV is stripped from the env.

I will close this again as clearly something that does not work inside a venv is silly but I'm also a bit annoyed at python for requiring this byzantian setup for binaries (which I suspect is needed for windows and we pay for this complexity). I would really love to just have a ./src/otk/externals/osbuild-gen-depsolve-dnf4 with:

#!/usr/bin/env python3
from otk_external_osbuild.command.gen_depsolve_dnf4 import main
if __name__ == "__main__":
    main()

afaict this would just work in venv or with a set pythonpath. oh well.

@mvo5 mvo5 closed this Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Figure out a better way to test externals
2 participants