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

termux_step_get_dependencies_python.sh: adding path to python-crossenv modules #21590

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Maxython
Copy link
Member

so termux python can work with them

@@ -30,6 +30,9 @@ termux_step_get_dependencies_python() {

# adding and setting values ​​to work properly with python modules
export PYTHONPATH=$TERMUX_PYTHON_HOME/site-packages
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
export PYTHONPATH+=":$TERMUX_PYTHON_CROSSENV_PREFIX/build/lib/python${TERMUX_PYTHON_VERSION}/site-packages"
Copy link
Member

Choose a reason for hiding this comment

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

This will mess up the target python. Can you give a case why this PR is needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

This will mess up the target python.

Could you explain this in more detail?

Can you give a case why this PR is needed?

I'm trying to rebuild some glibc packages with new python-glibc (3.12.6), and I encountered a problem with gobject-introspection-glibc package. The problem is that gobject-introspection-glibc package works with python-glibc directly, and it started requiring setuptools module in new python-glibc. The module can be installed via termux_step_get_dependencies_python function, but python-glibc doesn't see it, because it is installed for python-crossenv. So I think it would be good if python-glibc could find modules from python-crossenv. Here is the PR (it already tested with this change) - termux-pacman/glibc-packages#287

Copy link
Member

Choose a reason for hiding this comment

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

Could you explain this in more detail?

crossenv uses virtualenv to simulate a python interceptor for the target python. If PYTHONPATH is set, then the simulated python will search it first, and some packages installed in the cross-virtualenv will never get searched -- packages in the build-virtualenv will be used instead, and this may lead to some issues.

If crossenv is used, the python command should be redirected to $TERMUX_PYTHON_CROSSENV_PREFIX/cross/bin/python. It seems that $PREFIX/bin/python is used in the build script of gobject-introspection-glibc (https://github.com/termux-pacman/glibc-packages/blob/ac3a9354b29a20dcff8f33740e564dcffa582612/gpkg/gobject-introspection/build.sh#L22)

If it is really necessay for python-glibc, you can guard it with "$TERMUX_ON_DEVICE_BUILD" = "false" && "${TERMUX_PACKAGE_LIBRARY}" = "glibc".

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, thanks for the explanation. I took this into account and made some changes in the python-glibc package. There I added a special variable TERMUX_PYTHON_MAINPATH, which works like the PYTHONPATH variable. But when using this new variable, the PYTHONPATH variable will be ignored.

…v modules so termux python can work with them
@Maxython Maxython force-pushed the termux_step_get_dependencies_python.sh branch from d1707a7 to 465ba08 Compare September 28, 2024 14:14
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.

2 participants