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: compile module was removed in Python 3 #1820

Merged
merged 3 commits into from
Jul 18, 2019

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Jul 12, 2019

Checklist
  • npm install && npm test passes
  • tests are included
  • documentation is changed or added
  • commit message follows commit guidelines
Description of change

Our Travis CI ModuleNotFoundError: No module named 'compiler' errors are caused by the fact that the compiler package was removed in Python 3 in favor of the ast module that exists in both Python 2 and Python 3.

These changes are from refack/GYP3@f989ef9

@nodejs/python

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.

@richardlau
Copy link
Member

Tests still fail with Python 3 with:
https://travis-ci.com/nodejs/node-gyp/jobs/215440829#L3070-L3075

 +gyp: Variable node -e "require('nan')" must expand to a string or list of strings; found a bytes while trying to load binding.gyp
    +gyp ERR! configure error                                                   
    +gyp ERR! stack Error: `gyp` failed with exit code: 1                       
    +gyp ERR! stack     at ChildProcess.onCpExit (/home/travis/build/nodejs/node-gyp/lib/configure.js:344:16)
    +gyp ERR! stack     at ChildProcess.emit (events.js:198:13)                 
    +gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)

The error is coming from

if type(replacement) is list:
for item in replacement:
if not contents[-1] == '/' and type(item) not in (str, int):
raise GypError('Variable ' + contents +
' must expand to a string or list of strings; ' +
'list contains a ' +
item.__class__.__name__)
# Run through the list and handle variable expansions in it. Since
# the list is guaranteed not to contain dicts, this won't do anything
# with conditions sections.
ProcessVariablesAndConditionsInList(replacement, phase, variables,
build_file)
elif type(replacement) not in (str, int):
raise GypError('Variable ' + contents +
' must expand to a string or list of strings; ' +
'found a ' + replacement.__class__.__name__)

@cclauss
Copy link
Contributor Author

cclauss commented Jul 12, 2019

https://travis-ci.com/nodejs/node-gyp/builds/118963575 is a bit opaque to me this time.

@richardlau
Copy link
Member

https://travis-ci.com/nodejs/node-gyp/builds/118963575 is a bit opaque to me this time.

For reference:
https://travis-ci.com/nodejs/node-gyp/jobs/215572608#L1954-L1979

test/test-find-python.js ............................ 24/26
  find python
  not ok should be equal
    --- wanted    
    +++ found     
    +Python 3.7.1 
    compare: ===
    at:
      line: 20
      column: 9
      file: test/test-find-python.js
    stack: |
      test/test-find-python.js:20:9
    source: |
      t.strictEqual(stdout, '')
  
  find python
  not ok expect truthy value
    at:
      line: 21
      column: 9
      file: test/test-find-python.js
    stack: |
      test/test-find-python.js:21:9
    source: |
      t.ok(/Python 2/.test(stderr))

also failed in #1815 (https://travis-ci.com/nodejs/node-gyp/jobs/214789663#L4479-L4504) so isn't because of this PR and is unlikely to be because of anything in gyp. cc @joaocgreis

As discussed in nodejs#1811

PR-URL: nodejs#1818
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: João Reis <reis@janeasystems.com>
Copy link
Member

@rvagg rvagg left a comment

Choose a reason for hiding this comment

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

this is more of a rubber stamp lgtm than anything

i would like to see those tests cleaned up first though, @joaocgreis they look like they might be coming from your changes?

bnoordhuis and others added 2 commits July 16, 2019 19:18
This reverts commit 2761afb.

Building with `-fvisibility=hidden` breaks some of Node's add-on tests
and therefore likely also affects third-party add-ons. This change was
landed in a patch release so I'm opting to revert it until the next
major release.

PR-URL: nodejs#1828
Refs: nodejs/node#28647 (comment)
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
PR-URL: nodejs#1820
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <r@va.gg>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
@cclauss cclauss force-pushed the compile-module-removed-in-Python3 branch 2 times, most recently from d685451 to ef81bdb Compare July 16, 2019 23:07
@joaocgreis
Copy link
Member

This PR can land, the Python failure is unrelated.

test-find-python starts by looking for python as node-gyp would and confirming it is Python 2. But Python 3 is 3 and prints the version to stdout instead of stderr. I'll try to open a PR to fix this if no one beats to to it.

There are still failures in the Windows job that are not related to this.

@cclauss
Copy link
Contributor Author

cclauss commented Jul 17, 2019

You are correct. https://bugs.python.org/issue18338

  • python2 --version writes to stderr
  • python3 --version writes to stdout

@cclauss cclauss force-pushed the compile-module-removed-in-Python3 branch from 7cdca93 to ef81bdb Compare July 17, 2019 11:36
@rvagg
Copy link
Member

rvagg commented Jul 18, 2019

@cclauss you're good to land and you can do it manually as long as you avoid a merge commit. First I'd recommend changing the commit message because it describes why not what. But your metadata is 👍.

Because you're not quite up to date with master, this is what I'd do to get this landed:

git checkout master
git pull origin master # replace "origin" with whatever you've called this repo
git checkout compile-module-removed-in-Python3
git rebase master # now up to date with master
git checkout master
git merge compile-module-removed-in-Python3 # should land just one commit onto master, cleanly
git push origin master # replace "origin" appropriately

I don't think we can use git node land on this repo, at least it didn't seem to work with non-nodejs/node repos last time I checked. I've been doing manual metadata and landing on this repo but perhaps someone else in here has a more automatic suggestion?

@rvagg
Copy link
Member

rvagg commented Jul 18, 2019

Oh, that git pull origin master might cause problems actually because I rewrote master and you may have an out of sync version of master so a pull might create some chaos. I think git pull --rebase origin master might sort that out.

I sometimes go a more explicit route when in this kind of situation just to be absolutely clear what I'm trying to achieve:

git fetch origin
git checkout origin master
git branch -D master
git checkout -b master

but I think git pull --rebase origin master will achieve the same thing in this scenario.

@cclauss cclauss merged commit ef81bdb into nodejs:master Jul 18, 2019
rvagg pushed a commit that referenced this pull request Jul 18, 2019
Make Python 3 compatiblity changes so the code works in both Python 2
and Python 3.  Especially, make changes required because the compiler
module was removed in Python 3 in favor of the ast module that exists
in both Python 2 and Python 3.

PR-URL: #1820
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <r@va.gg>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
@rvagg
Copy link
Member

rvagg commented Jul 18, 2019

Your metadata didn't make it to master so something went wrong along the way unfortunately. I've force pushed a new version of the commit with.

PR-URL: https://github.com/nodejs/node-gyp/pull/1820
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <r@va.gg>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>

and renamed it to build: more Python 3 compat, replace compile with ast, bacf53d

@richardlau
Copy link
Member

Your metadata didn't make it to master so something went wrong along the way unfortunately. I've force pushed a new version of the commit with.

PR-URL: https://github.com/nodejs/node-gyp/pull/1820
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <r@va.gg>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>

and renamed it to build: more Python 3 compat, replace compile with ast, bacf53d

I'm not in front of a computer at the moment, but it looks like this landed as a merge commit (both ef81bdb and bacf53d have two parents)?

rvagg pushed a commit that referenced this pull request Jul 22, 2019
Make Python 3 compatiblity changes so the code works in both Python 2
and Python 3.  Especially, make changes required because the compiler
module was removed in Python 3 in favor of the ast module that exists
in both Python 2 and Python 3.

PR-URL: #1820
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <r@va.gg>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
@rvagg
Copy link
Member

rvagg commented Jul 22, 2019

OK, I've fixed it up, reversed to the commit before and cherry-picked ef81bdb onto it then force pushed master. Thanks for picking that up @richardlau!

@cclauss cclauss deleted the compile-module-removed-in-Python3 branch July 22, 2019 03:21
@rvagg rvagg mentioned this pull request Sep 26, 2019
rvagg pushed a commit that referenced this pull request Sep 26, 2019
Make Python 3 compatiblity changes so the code works in both Python 2
and Python 3.  Especially, make changes required because the compiler
module was removed in Python 3 in favor of the ast module that exists
in both Python 2 and Python 3.

PR-URL: #1820
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <r@va.gg>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
@rvagg rvagg mentioned this pull request Sep 26, 2019
targos added a commit to targos/node that referenced this pull request Oct 9, 2019
targos added a commit to nodejs/node that referenced this pull request Oct 13, 2019
Refs: nodejs/node-gyp#1820
Refs: nodejs/node-gyp#1843

PR-URL: #29897
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
targos added a commit to nodejs/node that referenced this pull request Nov 8, 2019
Refs: nodejs/node-gyp#1820
Refs: nodejs/node-gyp#1843

PR-URL: #29897
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
targos added a commit to nodejs/node that referenced this pull request Nov 10, 2019
Refs: nodejs/node-gyp#1820
Refs: nodejs/node-gyp#1843

PR-URL: #29897
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
BaochengSu pushed a commit to BaochengSu/node that referenced this pull request Oct 20, 2020
Refs: nodejs/node-gyp#1820
Refs: nodejs/node-gyp#1843

PR-URL: nodejs#29897
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
(cherry picked from commit 66b9532)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants