I'm am a super nub, in context, here, so please be nice! The project I want to write a formula for is used in the context of cognitive psychology research; it won't, probably, see a very broad distribution simply because the user base is very narrow; to date I've just been running around installing this by hand on everyone's computers. But it's finally getting sufficient use that this is no longer viable.
The only 'Ruby' I know is from writing SCSS/Sass, so I'm mostly just copy-and-pasting my way to something like success.
In a nut shell, I am trying to distribute a project I've been working on for a while via Homebrew. It includes:
I understand:
I do not understand:
Worth noting is that my lab uses the system Python. I'm not opposed to this running in a brew-installed version of Python (indeed I'd prefer it), but, the install can't cause the system Python to stop being the default version used at the command line, mostly because the intended userbase (i.e. Coders with a very low proficiency) will panic and flee if their memorized routines for executing their programs fail and I can't guarantee they haven't installed things in the the system site-packages directory (sorry).
If any of this was unclear, by all means throw questions at me I'll be happy to clarify.
Here's a link to the Git repository for reference to the directory structure of the project.
My script to date isn't very big, here's as far as I've gotten:
class Klibs < Formula
desc ""
homepage ""
url "https://github.com/jmwmulle/klibs/archive/0.9.1.4.tar.gz"
version "0.9.1.4"
# sha256 is wrong; just been editing the local cache while I learn how to do this properly :S
# (in case anyone tries to brew create the repository and notices)
sha256 "d854b85fc6fae58a9f6d046c206a73ac8c5948e89740cd55c02450e1ba9af0e0"
depends_on :python if MacOS.version <= :snow_leopard
depends_on "sdl2" => :required
# bunch of other brewable dependencies
resource "PySDL2" do
url "https://pypi.python.org/packages/source/P/PySDL2/PySDL2-0.9.3.zip"
sha1 "030f2351d1da387f878e14c8a86e08571d7baf5b"
end
# ...bunch of other python modules
resource "AggDraw" do # note that this one's not hosted by PyPi
url "https://github.com/preo/aggdraw.git"
sha1 "92e5e75aaaf5c535735d974764472e7e4d8e5cb0"
end
def install
resource("PySDL2").stage { system "python", *Language::Python.setup_install_args(libexec/"vendor") }
# and, again, more python modules
cd "klibs" do
ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python2.7/site-packages"
cd "lib/pylink" do
cd "frameworks/eyelink" do
frameworks.install("eyelink_core_graphics.framework")
frameworks.install("eyelink_core.framework")
end
# this next part I *know* must be wrong, I'm just not sure how to achieve
# this the homebrew way and thought I'd at least demonstrate what
# I need to do; this is a pre-compiled, third-party python module
# that is not distributed by any other means
system "cp", "-r", "pylink", "#{libexec}/lib/python2.7/site-packages"
system "ln", "-s", "#{libexec}/lib/python2.7/site-packages/pylink"
end
system "python", "setup.py", "install", "--prefix=#{prefix}"
end
bin.install("bin/klibs")
lib.install("lib/klibs")
end
test do
system "false"
end
end
Homebrew's pre-built binary packages (known as bottles) of many formulae can only be used if you install in the default installation prefix, otherwise they have to be built from source. Building from source takes a long time, is prone to failure, and is not supported.
Packages are installed according to their formulae, which live in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula .
A formula provides instructions and metadata for Homebrew to install a piece of software. Every Homebrew formula is a Formula. All subclasses of Formula (and all Ruby classes) have to be named UpperCase and not-use-dashes . A formula specified in this-formula.
Well, homebrew
is not the best medium for packaging and distributing code (OSX only).
You probably want to look at: http://python-packaging-user-guide.readthedocs.org/en/latest/distributing/. Depending on how you write your code; you may be able to put your requirements directly in your setup.py
rather than put them in a homebrew recipe.
As for packages that you are using that are not on PyPI; ask yourself the following questions:
If you are managing a farm of machines:
chef
, puppet
, salt
, ansible
, ...If you only care about the distribution:
setuptools
+ virtualenv
+ pip
makes a good combo.pip
is able to install requirements from PyPI, github, file servers, ...If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With