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
scons: Fix a wrapping issue which overrides your PATH #61213
Conversation
This fixes the following situation: If your PATH contains a python.withPackages interpreter and as part of your SConstruct build you want to launch a python script in a subprocess, which should run with '#!/usr/bin/env python', then it would be problematic to have scons wrapped with an additional PATH pointing to a different python interpreter. None of your withPackages-packages would be importable.
@primeos: Could you maybe have a look? |
@knedlsepp This is an interesting problem, thanks for the PR :) To document things a bit on this PR I'll add an example of the current wrapper: #! /nix/store/5p8qcz6i13ymgf80kimhx2g9pb5r5nia-bash-4.4-p23/bin/bash -e
export PATH='/nix/store/29xfvq39h5z7af90id0zaa4a09vgpsm7-python-2.7.16/bin:/nix/store/cc85cq9lvy89kcb0806gv3yhq0iawb45-scons-3.0.5/bin:/nix/store/2jh8bf3k21hkc7agik6idy5mjr2yljrx-python2.7-setuptools-41.0.1/bin'${PATH:+':'}$PATH
export PYTHONNOUSERSITE='true'
exec -a "$0" "/nix/store/cc85cq9lvy89kcb0806gv3yhq0iawb45-scons-3.0.5/bin/.scons-wrapped" "${extraFlagsArray[@]}" "$@" Which ensures that the following binaries are available in /nix/store/29xfvq39h5z7af90id0zaa4a09vgpsm7-python-2.7.16/bin:
2to3 idle pdb pdb2.7 pydoc python python2 python2.7 python2.7-config python2-config python-config smtpd.py smtpd.pyc smtpd.pyo
/nix/store/2jh8bf3k21hkc7agik6idy5mjr2yljrx-python2.7-setuptools-41.0.1/bin:
easy_install easy_install-2.7
/nix/store/cc85cq9lvy89kcb0806gv3yhq0iawb45-scons-3.0.5/bin:
scons scons-3.0.5 scons-3.0.5.bat scons.bat scons-configure-cache scons-configure-cache-3.0.5 sconsign sconsign-3.0.5 scons-time scons-time-3.0.5 TODO: Before we merge this PR we have to verify if any of these binaries are required in Theoretically adding additional modules should work via cc @FRidh (and @risicle who introduced dontWrapPythonPrograms): Do you have any insights/opinions on this? I'm unfortunately not that familiar with our Python infrastructure :o |
I encountered a situation where this was not applicable for multiple reasons:
Both issues can be patched away for a nix-build of that particular package with the appropriate postPatch phase. However interactively using scons to build stuff requires applying these patches manually. |
Thank you for your contributions.
|
I marked this as stale due to inactivity. → More info |
This fixes the following situation:
If your PATH contains a python.withPackages interpreter and as part of
your SConstruct build you want to launch a python script in a
subprocess, which should run with '#!/usr/bin/env python', then it would
be problematic to have scons wrapped with an additional PATH pointing to
a different python interpreter. None of your withPackages-packages would
be importable.
In a sidenote: this will also remove the PYTHONNOUSERSITE argument. I'm not yet sure if this behavior is good or bad. So to whoever will be reviewing this, I'm especially interested in this part of the PR.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)