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

build: Fix python path resolution in configure #16460

Merged
merged 1 commit into from
Oct 26, 2017

Conversation

digitalinfinity
Copy link
Contributor

The check to validate whether the current python process is the same as
the one resolved from the current path fails if the paths differ by case
which can happen on an operating system with case insensitive file
system behavior like Windows. Canonicalize it by converting both to
lower case if running on Windows.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

build

@nodejs-github-bot nodejs-github-bot added the build Issues and PRs related to build files or the CI. label Oct 24, 2017
@refack
Copy link
Contributor

refack commented Oct 24, 2017

@digitalinfinity what's the use case? Are you using a shebang simulating mechanism? IMHO on windows we should use sys.executable and err if it's not v2.x.

@refack
Copy link
Contributor

refack commented Oct 24, 2017

Or you can call https://github.com/nodejs/node/blob/master/tools/msvs/find_python.cmd (Windows FTW!)

BTW in the new "Opinionated dev shell" I'm writing we won't need that ;)

@digitalinfinity
Copy link
Contributor Author

digitalinfinity commented Oct 24, 2017

There is a discrepancy between the paths derived through which vs paths derived through sys.executable and it looks like os.path.realpath doesn't canonicalize it. I ran into it while running vcbuild on my machine because I have python.exe in C:\Python27 but my PATH environment variable contains C:\python27. I could work around it by updating my PATH but I figure it would be better for configure to be resilient to this difference.

As an aside, I'm a python neophyte so if there is a better way in python to do this, happy to update the PR

Edit: formatting

@refack
Copy link
Contributor

refack commented Oct 24, 2017

So vcbuild already works hard to figure out where a suitible python resides, so there's no need for the which trick (POSIX uses that because the shebang - #!/bin/sh might not resolve to the right python).

I'll push a suggestion.

@refack
Copy link
Contributor

refack commented Oct 24, 2017

/cc @nodejs/platform-windows

@digitalinfinity
Copy link
Contributor Author

I like your suggestion better- I'd just add a check in bin_override to error out if it's Windows then, if we never expect it to be called?

configure Outdated
@@ -1460,7 +1460,8 @@ if options.prefix:

config = '\n'.join(map('='.join, config.iteritems())) + '\n'

bin_override = get_bin_override()
# On Windows there's no reason to search for a differnt python binary
Copy link
Member

Choose a reason for hiding this comment

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

differnt -> different (@refack)

Copy link
Member

Choose a reason for hiding this comment

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

Aside: the function is not well-named. It suggests it just looks up something but it does all kinds of things as a side effect. Maybe make_bin_override()?

@digitalinfinity
Copy link
Contributor Author

Thanks @refack - the new changes look good to me!

@refack
Copy link
Contributor

refack commented Oct 25, 2017

I won't ✔️ my own code, so we need a 3rd party 😃

@refack
Copy link
Contributor

refack commented Oct 25, 2017

def get_bin_override():
def make_bin_override():
if sys.platform == 'win32':
raise Exception('make_bin_override should not be called on win32.')
Copy link
Member

Choose a reason for hiding this comment

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

Does WSL's sys.platform identify as win32?

Copy link
Contributor

Choose a reason for hiding this comment

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

It says linux2

PR-URL: nodejs#16460
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
@refack refack merged commit 90640f7 into nodejs:master Oct 26, 2017
@digitalinfinity digitalinfinity deleted the pypath_fix branch October 28, 2017 01:34
gibfahn pushed a commit that referenced this pull request Oct 30, 2017
PR-URL: #16460
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
gibfahn pushed a commit that referenced this pull request Oct 30, 2017
PR-URL: #16460
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
gibfahn pushed a commit that referenced this pull request Oct 31, 2017
PR-URL: #16460
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
@gibfahn gibfahn mentioned this pull request Oct 31, 2017
Qard pushed a commit to ayojs/ayo that referenced this pull request Nov 2, 2017
PR-URL: nodejs/node#16460
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Qard pushed a commit to ayojs/ayo that referenced this pull request Nov 2, 2017
PR-URL: nodejs/node#16460
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
MylesBorins pushed a commit that referenced this pull request Nov 16, 2017
PR-URL: #16460
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Nov 21, 2017
MylesBorins pushed a commit that referenced this pull request Nov 21, 2017
PR-URL: #16460
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
MylesBorins pushed a commit that referenced this pull request Nov 28, 2017
PR-URL: #16460
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
addaleax pushed a commit to ayojs/ayo that referenced this pull request Dec 7, 2017
PR-URL: nodejs/node#16460
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants