Skip to content

Conversation

@rynbrd
Copy link

@rynbrd rynbrd commented Nov 2, 2017

This allows python-exec to behave correct when called via /usr/bin/env - python.

This was discovered at tensorflow/tensorflow#10529.

This is easily reproducible by running it:

$ /usr/bin/env - python
python: unable to find executable in PATH.

The behavior of env is to call execvp which falls back to the output of confstr(_CS_PATH) when no PATH is set. This allows env - to work in most cases.

However, python-exec2c expects PATH to be set and does not fall back to confstr(_CS_PATH) when it isn't. This change enables this behavior by default when no FALLBACK_PATH is provided at build time.

I've tested this on my own Gentoo. The results are positive:

$ /usr/bin/env - python
Python 2.7.12 (default, Aug  2 2017, 11:41:16) 
[GCC 4.9.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

if (!sys_path)
sys_path = FALLBACK_PATH;
if (!sys_path) {
if (strlen(FALLBACK_PATH) == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Why would FALLBACK_PATH ever be empty? This looks like a broken install.

Copy link
Author

Choose a reason for hiding this comment

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

Couldn't tell you. Here's the ebuild for 2.4.4 that builds this without --with-fallback-path: https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-lang/python-exec/python-exec-2.4.4.ebuild

The 2.4.5 ebuild does set --with-fallback-path: https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-lang/python-exec/python-exec-2.4.5.ebuild

Copy link
Author

Choose a reason for hiding this comment

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

FYI my tests are without --with-fallback-path set during configure.

Copy link
Member

Choose a reason for hiding this comment

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

That's because the fallback code has been added in 2.4.5. We need to stabilize this version.

@mgorny
Copy link
Member

mgorny commented Nov 3, 2017

In any case, the current behavior is intentional and the bug you're trying to fix is already fixed in the current git.

@mgorny mgorny closed this Nov 3, 2017
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