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: allow build with system python 3 #16058

Closed
wants to merge 1 commit into from

Conversation

forivall
Copy link
Contributor

@forivall forivall commented Oct 7, 2017

When the system python is python 3, configure now creates a directory
with a symlink called 'python' to python2, uses it when it calls
run_gyp, and puts it in config.mk so that it propagates to everything
that make launches

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 7, 2017
@forivall
Copy link
Contributor Author

forivall commented Oct 7, 2017

Waiting for CI to determine if changes are needed for windows.

@gibfahn
Copy link
Member

gibfahn commented Oct 7, 2017

CI: https://ci.nodejs.org/job/node-test-commit/12832/

EDIT: CI was green.

@gibfahn
Copy link
Member

gibfahn commented Oct 7, 2017

cc/ @nodejs/build @nodejs/python

@Trott Trott added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Oct 7, 2017
configure Outdated
raise e
os.symlink(sys.executable, python_link)

os.environ['PATH'] = bin_override + ':' + os.environ['PATH']
Copy link
Member

Choose a reason for hiding this comment

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

This is a no-op as far as I can tell, it doesn't affect the parent shell.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gyp does a "python -c" call, and this is required for it to work. Will add comment

configure Outdated
bin_override = None

def setup_bin_overrides():
global bin_override
Copy link
Member

Choose a reason for hiding this comment

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

What is the reason you use a global instead of returning a value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It mirrored what other stages were doing, with setting values in "o". Returning makes more sense, will change

configure Outdated
bin_override = os.path.abspath('out/tools/bin')
try:
os.makedirs(bin_override)
except os.error as e:
Copy link
Member

Choose a reason for hiding this comment

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

For consistency with the rest of the file, can you use OSError in this function?

configure Outdated
@@ -1428,6 +1458,10 @@ if options.prefix:

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

setup_bin_overrides()
if bin_override:
config = 'export PATH:=' + bin_override + ':${PATH}\n' + config
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, why ${PATH} and not $(PATH)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's what was on the stack overflow answer. 😝 Will change if I can

When the system python is python 3, configure now creates a directory
with a symlink called 'python' to python2, uses it when it calls
run_gyp, and puts it in config.mk so that it propagates to everything
that make launches
@forivall
Copy link
Contributor Author

forivall commented Oct 7, 2017

Updated for reviews. Diff @ forivall@528a99d

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

@gibfahn
Copy link
Member

gibfahn commented Oct 8, 2017

Landed in 2b5b423.

Thanks for fixing this @forivall , and congrats on becoming a Contributor 🎉 .

@gibfahn gibfahn closed this Oct 8, 2017
gibfahn pushed a commit that referenced this pull request Oct 8, 2017
When the system python is python 3, configure now creates a directory
with a symlink called 'python' to python2, uses it when it calls
run_gyp, and puts it in config.mk so that it propagates to everything
that make launches

PR-URL: #16058
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request Oct 11, 2017
When the system python is python 3, configure now creates a directory
with a symlink called 'python' to python2, uses it when it calls
run_gyp, and puts it in config.mk so that it propagates to everything
that make launches

PR-URL: #16058
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@MylesBorins MylesBorins mentioned this pull request Oct 11, 2017
addaleax pushed a commit to addaleax/ayo that referenced this pull request Oct 12, 2017
When the system python is python 3, configure now creates a directory
with a symlink called 'python' to python2, uses it when it calls
run_gyp, and puts it in config.mk so that it propagates to everything
that make launches

PR-URL: nodejs/node#16058
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@hefangshi
Copy link
Contributor

This change made Node.js build need install distutils packages which is a dependency change, python3 won't break old build environment but distutils dependency will, maybe we can implement a less dependent method to find default python binary?

@bnoordhuis
Copy link
Member

@hefangshi distutils is part of python's stdlib. Are you thinking of setuptools?

@gibfahn
Copy link
Member

gibfahn commented Oct 12, 2017

Looks like distutils is included by default from Python 2.6 onwards, but maybe not in some distributions (looking at https://stackoverflow.com/questions/3810521/how-to-install-python-distutils).

@hefangshi what platform and version of Python are you on?

Also this commit doesn't add the distutils dependency, it was there before (from the diff 2b5b423):

image

@gibfahn
Copy link
Member

gibfahn commented Oct 16, 2017

+1 on landing on a future v6.x release, and it should land with #16241 (assuming that lands).

@forivall
Copy link
Contributor Author

forivall commented Oct 16, 2017

Yeah, i had assumed the distutils would be fine since it would be loaded if it was python 3 or <= 2.5. there's probably an alternative version of 'which' that doesn't depend on distutils, since that's the only thing it's used for.

@MylesBorins
Copy link
Contributor

waiting for #16241 before landing this on v6.x. Please LMK if we don't need to wait

MylesBorins pushed a commit that referenced this pull request Nov 14, 2017
When the system python is python 3, configure now creates a directory
with a symlink called 'python' to python2, uses it when it calls
run_gyp, and puts it in config.mk so that it propagates to everything
that make launches

PR-URL: #16058
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@MylesBorins MylesBorins mentioned this pull request Nov 21, 2017
MylesBorins pushed a commit that referenced this pull request Nov 21, 2017
When the system python is python 3, configure now creates a directory
with a symlink called 'python' to python2, uses it when it calls
run_gyp, and puts it in config.mk so that it propagates to everything
that make launches

PR-URL: #16058
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request Nov 28, 2017
When the system python is python 3, configure now creates a directory
with a symlink called 'python' to python2, uses it when it calls
run_gyp, and puts it in config.mk so that it propagates to everything
that make launches

PR-URL: #16058
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins added a commit that referenced this pull request Nov 28, 2017
Notable Changes:

* build:
  - fix npm install with --shared (Ben Noordhuis)
    #16438
* build:
  - building with python 3 is now supported (Emily Marigold Klassen)
    #16058
* src:
  - v8 options can be specified with either '\_' or '-' in NODE_OPTIONS
    (Sam Roberts) #14093

PR-URL: #17180
MylesBorins added a commit that referenced this pull request Dec 5, 2017
Notable Changes:

* build:
  - fix npm install with --shared (Ben Noordhuis)
    #16438
* build:
  - building with python 3 is now supported (Emily Marigold Klassen)
    #16058
* src:
  - v8 options can be specified with either '\_' or '-' in NODE_OPTIONS
    (Sam Roberts) #14093

PR-URL: #17180
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. code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants