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

Upgrade node-gyp-build to support python 3.11+ users #1087

Closed
csydvs opened this issue May 1, 2023 · 9 comments
Closed

Upgrade node-gyp-build to support python 3.11+ users #1087

csydvs opened this issue May 1, 2023 · 9 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@csydvs
Copy link

csydvs commented May 1, 2023

Software versions

Please provide at least OS and version of pact-js

  • OS: Mac OSX 12.6.1
  • Consumer Pact library: Pact JS@Latest

Issue Checklist

Please confirm the following:

  • [*] I have upgraded to the latest
  • [*] I have the read the FAQs in the Readme
  • [*] I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures
  • [*] I have set my log level to debug and attached a log file showing the complete request/response cycle

Expected behaviour

Just trying to run npm i -S @pact-foundation/pact@latest on a box with python 3.11.2 installed, would like it to install

Actual behaviour

Error encountered. See this gyp issue for more info on what's going on here.

Relevant log files


> @pact-foundation/pact-core@13.13.8 install /Users/casey/Workspace/service/graphql/node_modules/@pact-foundation/pact-core
> node-gyp rebuild

Traceback (most recent call last):
  File "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 50, in <module>
    sys.exit(gyp.script_main())
             ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 554, in script_main
    return main(sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 547, in main
    return gyp_main(args)
           ^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 520, in gyp_main
    [generator, flat_list, targets, data] = Load(
                                            ^^^^^
  File "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 136, in Load
    result = gyp.input.Load(build_files, default_variables, includes[:],
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2782, in Load
    LoadTargetBuildFile(build_file, data, aux_data,
  File "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 391, in LoadTargetBuildFile
    build_file_data = LoadOneBuildFile(build_file_path, data, aux_data,
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 234, in LoadOneBuildFile
    build_file_contents = open(build_file_path, 'rU').read()
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid mode: 'rU' 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 (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12)
gyp ERR! System Darwin 21.6.0
gyp ERR! command "/usr/local/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd ...
gyp ERR! node -v v14.21.3
gyp ERR! node-gyp -v v5.1.1
gyp ERR! not ok ```
@csydvs csydvs added the bug Indicates an unexpected problem or unintended behavior label May 1, 2023
@YOU54F
Copy link
Member

YOU54F commented May 2, 2023

hmm

node-gyp suggest npm install -g node-gyp on the end user side.

We have some troubleshooting notes here that warrant updating :)

  • edit: forgot to add link 😅

@csydvs
Copy link
Author

csydvs commented May 2, 2023

The global node-gyp install didn't work for me, but another good option for anyone who runs into this is to run npm config set python <different version of python> to downgrade the version of python that node uses to something lower that you have locally.

@eugenk
Copy link

eugenk commented May 9, 2023

node-gyp suggest npm install -g node-gyp on the end user side.

This cannot be the solution, though. A simple npm i on every machine that has Python 3 installed (no matter if 3.10 or 3.11) should just work.

This line fixed it

The same goes for the pipelines. You should not be required to take additional steps to just install the pact package.

Couldn't the node-gyp (current version) be a devDependency of pact-core that is then used for the postinstall step?

Out of curiosity: Why are you (transitively) depending on Python in a node project in the first place? This seems a little odd.

@YOU54F
Copy link
Member

YOU54F commented May 9, 2023

It's not the only javascript project to do so

see electrons guidance

https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules

See this issue for #899 for tracking.

I agree its suboptimal

Happy for someone to propose a PR with the suggested change

@YOU54F
Copy link
Member

YOU54F commented May 9, 2023

The same goes for the pipelines. You should not be required to take additional steps to just install the pact package.

I don't agree, you may have to take additional steps, dependant on the package and how its built, that is just life, however they should be very well documented, so as to cause minimal frustration to end users.

@YOU54F
Copy link
Member

YOU54F commented May 12, 2023

Closing this issue as invalid

node-gyp-build isn't included in the package.json for pact-js and its core pact-js-core

https://github.com/pact-foundation/pact-js/blob/master/package.json
https://github.com/pact-foundation/pact-js-core/blob/master/package.json

@YOU54F YOU54F closed this as completed May 12, 2023
@JVKeller
Copy link

If anyone stumbles here again...

Change the line with the error from rU to r, and run 'nmp rebuild'

@YOU54F
Copy link
Member

YOU54F commented Aug 23, 2023

thanks, they should just install the latest version 12.x or later as that doesn't require this build step at all 👍🏾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants