Bug 1385471

Summary: Auto-activate the SCL from generated script wrappers
Product: Red Hat Software Collections Reporter: Nick Coghlan <ncoghlan>
Component: python-pipAssignee: Tomas Orsava <torsava>
Status: CLOSED EOL QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rh-python35CC: hhorak, torsava
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-14 13:06:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1369788, 1371936, 1372700, 1390495    
Bug Blocks:    

Description Nick Coghlan 2016-10-17 06:45:09 UTC
Description of problem:

When installing Python projects, pip generates wrapper scripts for declared entry points: https://packaging.python.org/distributing/#console-scripts

This process assumes that running the script with the shebang line set to `sys.executable` will be sufficient to start Python with the correct sys.path settings, which is a correct assumption for Python virtual environments and full Linux containers, but not correct for Software Collections (since dynamically linked external C libraries won't be found correctly).


How reproducible:

Always

Steps to Reproduce:
1. Install a project with entry points defined that relies on external C extensions linked against the SCL Python binary
2. Run that project via a wrapper script generated by pip, setuptools, or pipsi
3.

Actual results:

You have to explicitly activate the SCL before the wrapper scripts will work

Expected results:

The wrapper scripts work automatically without requiring separate activation of the SCL (i.e. the use of the SCL Python becomes a transparent implementation detail of the installed script)

Additional info:

Ideally, this could be done *without* needing to patch the wrapper generation process by instead setting RPATH appropriately in the SCL Python executable, as then it would also fix subprocess execution of sys.executable with environment inheritance disabled (SCLs currently rely on the active environment being passed through to subprocesses), as well as every other piece of Python code that assumes that "sys.executable" provides all the info you need in order to re-run the "same" Python environment.

Such an approach would also ensure that running "pip install --upgrade pip wheel setuptools" inside a virtual environment doesn't break anything (this is a common technique to ensure a project is using the latest version of these tools with full support for modern Python packaging techniques)

Alternatively, the fix could be implemented by patching the SCL provided python-pip and python-setuptools to be "SCL aware", but that has the downside of being quite fragile, and inconsistent with the established techniques for running Python programs in a particular environment.

Comment 6 Joe Orton 2019-03-14 11:02:42 UTC
Red Hat does not currently plan to provide any further changes to this collection in a Red Hat Software Collections update release.

This software collection is nearing the retirement date (May 2019) after which customers are encouraged to upgrade to a later release.

Please contact Red Hat Support if you have further questions, or refer to the support lifecycle page for more information. https://access.redhat.com/support/policy/updates/rhscl/

Comment 7 Joe Orton 2019-06-14 13:06:50 UTC
In accordance with the Red Hat Software Collections Product Life Cycle, the support period for this collection has ended.

New bug fix, enhancement, and security errata updates, as well as technical support services will no longer be made available for this collection.

Customers are encouraged to upgrade to a later release.

Please contact Red Hat Support if you have further questions, or refer to the support lifecycle page for more information. https://access.redhat.com/support/policy/updates/rhscl/