Home > Software engineering >  Brew Formula install with multiple files
Brew Formula install with multiple files

Time:02-19

I've created a python tool and want to install it via brew. Creating the formula worked fine at first when i simply had one python file named myTool. Then i seperated the code into more files as it became larger and more complex.

How do i set up the install to bundle those files, because right now the imports are failing because the other files are not found.

My current install

  def install
    bin.install 'myTool'
  end

The error shown when running the brew installed tool

from myModule import someFunc, someOtherFunc ModuleNotFoundError: No module named 'myModule'

CodePudding user response:

The current setup only installs the angler file without any of the other python modules. This results in the ModuleNotFoundError error. Here is my suggestion:

def install
  # Determines the python version being used
  # e.g. If python3.10, xy = 3.10
  xy = Language::Python.major_minor_version "python3"
  # Where to install the python files
  packages = libexec/"lib/python#{xy}/site-packages/angler"

  # For each file present, install them in the right location
  %w[angler anglerEnums.py anglerGen.py anglerHelperFunctions.py].each do |file|
    packages.install file
  end

  # Create a symlink to the angler python file
  bin.install_symlink packages/"angler"
end
  • Related