Skip to content

node formula should depend on Python only during build phase #87879

@raphlcx

Description

@raphlcx

brew gist-logs <formula> link OR brew config AND brew doctor output

$ brew config

HOMEBREW_VERSION: 3.2.17-133-g890190c
ORIGIN: https://github.com/Homebrew/brew
HEAD: 890190c0f30b36512835c846be004b0253b062ad
Last commit: 31 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 26a841653a5d824cec69d1ae60b0b3de3c2f18e3
Core tap last commit: 37 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_CLEANUP_MAX_AGE_DAYS: 0
HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
HOMEBREW_EDITOR: vim
HOMEBREW_MAKE_JOBS: 4
HOMEBREW_NO_AUTO_UPDATE: set
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: quad-core 64-bit broadwell
Clang: 13.0.0 build 1300
Git: 2.33.1 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.6-x86_64
CLT: 13.0.0.0.1.1630607135
Xcode: 13.0

$ brew doctor

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: The filesystem on /System/Volumes/Data appears to be case-sensitive.
The default macOS filesystem is case-insensitive. Please report any apparent problems.

Warning: Putting non-prefixed coreutils in your path can cause GMP builds to fail.

  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.

What were you trying to do (and why)?

Good day Homebrew,

I'm looking through the formulae that I have installed on my machine, identifying which one of them depends on Python during runtime.

And I noticed the node formula has a runtime dependency on Python, but from my reading up to this point, this dependency is only required when building node, not during runtime:

  • On Node.js official documentation, it mentions the use of Python >=3 for building and testing. [ref]
  • On Arch Linux Node.js package, Python is also mentioned as a dependency only during the build phase (stylised as (make)). [ref]

I have followed the conversation in #86894, but there seems to be no mention of adding Python only as a build-time dependency.

I have tried turning Python from runtime to build-time dependency for the formula:

diff --git a/Formula/node.rb b/Formula/node.rb
index ed304dc55d1..ce0e602a478 100644
--- a/Formula/node.rb
+++ b/Formula/node.rb
@@ -27,7 +27,7 @@ class Node < Formula
   depends_on "libnghttp2"
   depends_on "libuv"
   depends_on "[email protected]"
-  depends_on "[email protected]"
+  depends_on "[email protected]" => :build
 
   uses_from_macos "zlib"
 

Then I was able to build from source and run the tests successfully for the formula:

(I had an active tmux split pane, so the output got clipped)

$ brew install --build-from-source node
==> Downloading https://ghcr.io/v2/homebrew/core/python/3.9/manifests/3.9.7_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/python/3.9/blobs/sha256:c08c5f01bca862fd69d511261
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:c08c5f01bca86
######################################################################## 100.0%
==> Downloading https://github.com/nodejs/node/commit/8699aa501c4d4e1567ebe8901e5ec80cadaa9323.pat
######################################################################## 100.0%
==> Downloading https://registry.npmjs.org/npm/-/npm-8.1.0.tgz
######################################################################## 100.0%
==> Downloading https://nodejs.org/dist/v17.0.1/node-v17.0.1.tar.xz
######################################################################## 100.0%
==> Installing dependencies for node: [email protected]
==> Installing node dependency: [email protected]
==> Pouring [email protected]_1.big_sur.bottle.tar.gz
==> /usr/local/Cellar/[email protected]/3.9.7_1/bin/python3 -m ensurepip
==> /usr/local/Cellar/[email protected]/3.9.7_1/bin/python3 -m pip install -v --no-deps --no-index --upgr
🍺  /usr/local/Cellar/[email protected]/3.9.7_1: 3,080 files, 54.7MB
==> Installing node
==> Patching
==> Applying 8699aa501c4d4e1567ebe8901e5ec80cadaa9323.patch
patching file src/cares_wrap.h
==> ./configure --prefix=/usr/local/Cellar/node/17.0.1 --without-npm --with-intl=system-icu --shar
==> make install
==> node /private/tmp/node-20211024-83467-l7wt2o/node-v17.0.1/npm_bootstrap/bin/npm-cli.js install
🍺  /usr/local/Cellar/node/17.0.1: 2,008 files, 45.1MB, built in 79 minutes 10 seconds
Removing: /Users/cx/Library/Caches/Homebrew/node--npm--8.1.0.tgz... (2.1MB)
Removing: /Users/cx/Library/Caches/Homebrew/node--patch--678643c79258372d5054d3da16bc0c5db17130f151f0e72b6e4f20817987aac9.patch... (1.2KB)
Removing: /Users/cx/Library/Caches/Homebrew/node--17.0.1.tar.xz... (33.1MB)
$ brew test node
==> Testing node
==> /usr/local/Cellar/node/17.0.1/bin/node /private/tmp/node-test-20211024-51438-qkkshk/test.js
==> /usr/local/Cellar/node/17.0.1/bin/node -e 'console.log(new Intl.NumberFormat("en-EN").format(1234.56))'
==> /usr/local/Cellar/node/17.0.1/bin/node -e 'console.log(new Intl.NumberFormat("de-DE").format(1234.56))'
==> /usr/local/bin/npm -ddd --cache=/Users/cx/Library/Caches/Homebrew/npm_cache --build-from-source install npm@latest
==> /usr/local/bin/npm -ddd --cache=/Users/cx/Library/Caches/Homebrew/npm_cache --build-from-source install ref-napi
==> /usr/local/bin/npx --yes cowsay hello
npm notice
npm notice New patch version of npm available! 8.1.0 -> 8.1.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.1.1
npm notice Run npm install -g [email protected] to update!
npm notice

I think this could help to proof that Python is indeed only required as a build-time dependency of node, and not during runtime, although I might be missing a few points or notes in a coversation somewhere that could disprove my rationale.

Hope to hear soon.

What happened (include all command output)?

$ brew deps node | grep python
[email protected]

node formula shows Python as one of its dependencies.

What did you expect to happen?

$ brew deps node | grep python

This command should not display anything.

Step-by-step reproduction instructions (by running brew commands)

brew deps node | grep python

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedPR was locked due to age

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions