Running `pip install` during install

(Lee Gaines) #1

Hi Everyone,

I’m working on developing a formula for some python scripts. It’s not a library, just some scripts that I want to live in a user’s PATH.

The scripts have one dependency; a python package called “kubernetes”.

I want to be able to do something like this inside my Formula:

def install
  if !system("python -c 'import kubernetes'")
    system "pip install kubernetes"
  end
  prefix.install Dir["scripts"]
  bin.install "my-executable-that-calls-the-scripts"
  ...
end

But for some reason brew doesn’t like that…


==> python -c 'import kubernetes'
==> pip install kubernetes
Last 15 lines from /Users/foo/Library/Logs/Homebrew/repo/02.pip:
2019-04-13 13:10:59 -0700

pip install kubernetes

If reporting this issue please do so to (not Homebrew/brew or Homebrew/core):
my/repo

/usr/local/Homebrew/Library/Homebrew/utils/github.rb:253:in `raise_api_error': Validation Failed: [{"message"=>"The listed users and repositories cannot be searched either because the resources do not exist or you do not have permission to view them.", "resource"=>"Search", "field"=>"q", "code"=>"invalid"}] (GitHub::ValidationFailedError)
        from /usr/local/Homebrew/Library/Homebrew/utils/github.rb:207:in `open_api'
        from /usr/local/Homebrew/Library/Homebrew/utils/github.rb:352:in `search'
        from /usr/local/Homebrew/Library/Homebrew/utils/github.rb:260:in `search_issues'
        from /usr/local/Homebrew/Library/Homebrew/utils/github.rb:273:in `issues_for_formula'
        from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:372:in `fetch_issues'
        from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:368:in `issues'
        from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:422:in `dump'
        from /usr/local/Homebrew/Library/Homebrew/brew.rb:136:in `rescue in <main>'
        from /usr/local/Homebrew/Library/Homebrew/brew.rb:36:in `<main>'

Any ideas/guidance would be greatly appreciated!

0 Likes

(Sean Molenaar) #2

It’s better to use something like this: https://github.com/Homebrew/homebrew-core/blob/master/Formula/dnstwist.rb

0 Likes