Skip to content

Instantly share code, notes, and snippets.

@scorphus
Last active September 3, 2023 18:10
Show Gist options
  • Save scorphus/f44b5bdc68db6921e36687a8906ac94a to your computer and use it in GitHub Desktop.
Save scorphus/f44b5bdc68db6921e36687a8906ac94a to your computer and use it in GitHub Desktop.
Haystack brew formula in the works

Homebrew Formula for Haystack

Installing the Formula

  1. Copy it to the Formula/h subdirectory of the homebrew/core repository. Use the following command to display the path of such repository on the file system:

    brew --repository homebrew/core
    
  2. Run the following command:

    HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source --verbose --debug haystack
    

    This might take a while.

Testing the Formula

After installing the formula, test it with:

brew test haystack
class Haystack < Formula
include Language::Python::Virtualenv
desc "LLM orchestration framework to build customizable, production-ready LLM applications"
homepage "https://haystack.deepset.ai"
url "https://files.pythonhosted.org/packages/19/51/0016b7650767618b74fc3744148e4280da170603820449c1824dcb328560/farm_haystack-1.19.0.tar.gz"
sha256 "2baf92473fc1660c5911d2891abe1a259eeab2edca718d10450be8411592530a"
license "Apache-2.0"
head "https://github.com/deepset-ai/haystack.git", branch: "main"
depends_on "python"
depends_on "cmake" => :build
depends_on "rust" => :build
depends_on "cython"
depends_on "huggingface-cli"
depends_on "numpy"
depends_on "pillow"
depends_on "python-certifi"
depends_on "python-typing-extensions"
depends_on "pyyaml"
depends_on "scipy"
depends_on "six"
depends_on "pytorch"
resource "appdirs" do
url "https://files.pythonhosted.org/packages/d7/d8/05696357e0311f5b5c316d7b95f46c669dd9c15aaeecbb48c7d0aeb88c40/appdirs-1.4.4.tar.gz"
sha256 "7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"
end
resource "attrs" do
url "https://files.pythonhosted.org/packages/97/90/81f95d5f705be17872843536b1868f351805acf6971251ff07c1b8334dbb/attrs-23.1.0.tar.gz"
sha256 "6279836d581513a26f1bf235f9acd333bc9115683f14f7e8fae46c98fc50e015"
end
resource "backoff" do
url "https://files.pythonhosted.org/packages/47/d7/5bbeb12c44d7c4f2fb5b56abce497eb5ed9f34d85701de869acedd602619/backoff-2.2.1.tar.gz"
sha256 "03f829f5bb1923180821643f8753b0502c3b682293992485b0eef2807afa5cba"
end
resource "boilerpy3" do
url "https://files.pythonhosted.org/packages/2c/34/7b7433f4b07c27d28b126d6d6876b442500df1caa32e5c191fe05d1c2f44/boilerpy3-1.0.6.tar.gz"
sha256 "c864c0041c3197ad8c118109b252c2c564133614e93068bf226eaf6d217304bb"
# Fix invalid version specifier in setup.py
# PR ref: https://github.com/jmriebold/BoilerPy3/pull/TODO # TODO: submit a PR to upstream project
patch do
url "https://gist.github.com/scorphus/b110f3ac1fb897ec7b4aecb01ae250c8/raw/01046375d302368d6832de92f697df0f099e28b1/boilerpy3-1.0.6-patch00-setup.py-Invalid_version_specifier.diff"
sha256 "d5571560a407767571f9d8bc46860e96fb348f3f4a8ded311f0b4de43db7301c"
end
end
resource "canals" do
url "https://files.pythonhosted.org/packages/ca/c2/78dfcce5a9a9597faa8e110879bef5c06ee23ef1220a79d0efea810087ce/canals-0.3.2.tar.gz"
sha256 "4f3843c10f1b61a34f94bafa0140430ab7ae29787dc2ec12cf2faa8e232bddae"
end
resource "cattrs" do
url "https://files.pythonhosted.org/packages/68/d4/27f9fd840e74d51b6d6a024d39ff495b56ffde71d28eb82758b7b85d0617/cattrs-23.1.2.tar.gz"
sha256 "db1c821b8c537382b2c7c66678c3790091ca0275ac486c76f3c8f3920e83c657"
end
resource "click" do
url "https://files.pythonhosted.org/packages/96/d3/f04c7bfcf5c1862a2a5b845c6b2b360488cf47af55dfa79c98f6a6bf98b5/click-8.1.7.tar.gz"
sha256 "ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"
end
resource "charset-normalizer" do
url "https://files.pythonhosted.org/packages/2a/53/cf0a48de1bdcf6ff6e1c9a023f5f523dfe303e4024f216feac64b6eb7f67/charset-normalizer-3.2.0.tar.gz"
sha256 "3bb3d25a8e6c0aedd251753a79ae98a093c7e7b471faa3aa9a93a81431987ace"
end
resource "docopt" do
url "https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz"
sha256 "49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491"
end
resource "Events" do
url "https://github.com/pyeve/events/archive/refs/tags/v0.5.tar.gz"
sha256 "51fed10bad025e4bb81714b6114546b7f42773eda82df10e769d76a7859e9c3a"
end
resource "exceptiongroup" do
url "https://files.pythonhosted.org/packages/c2/e1/5561ad26f99b7779c28356f73f69a8b468ef491d0f6adf20d7ed0ac98ec1/exceptiongroup-1.1.3.tar.gz"
sha256 "097acd85d473d75af5bb98e41b61ff7fe35efe6675e4f9370ec6ec5126d160e9"
end
resource "filelock" do
url "https://files.pythonhosted.org/packages/5a/47/f1f3f5b6da710d5a7178a7f8484d9b86b75ee596fb4fefefb50e8dd2205a/filelock-3.12.3.tar.gz"
sha256 "0ecc1dd2ec4672a10c8550a8182f1bd0c0a5088470ecd5a125e45f49472fac3d"
end
resource "fsspec" do
url "https://files.pythonhosted.org/packages/14/e4/33a5c4635cff37ef6eb66608c675ae678b48baa6e73b331536cf2cbf18a1/fsspec-2023.6.0.tar.gz"
sha256 "d0b2f935446169753e7a5c5c55681c54ea91996cc67be93c39a154fb3a2742af"
end
resource "idna" do
url "https://files.pythonhosted.org/packages/8b/e1/43beb3d38dba6cb420cefa297822eac205a277ab43e5ba5d5c46faf96438/idna-3.4.tar.gz"
sha256 "814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"
end
resource "importlib-resources" do
url "https://files.pythonhosted.org/packages/fd/dc/0c5cfbd4df5d6e83de4e64324b370151ee88de25f3c71aea21115f4f77f8/importlib_resources-6.0.1.tar.gz"
sha256 "4359457e42708462b9626a04657c6208ad799ceb41e5c58c57ffa0e6a098a5d4"
end
resource "inflect" do
url "https://files.pythonhosted.org/packages/9f/90/1d0a889847fdce963ebe9684de24a749e4fad627bf595e9f0d32730f85a8/inflect-7.0.0.tar.gz"
sha256 "63da9325ad29da81ec23e055b41225795ab793b4ecb483be5dc1fa363fd4717e"
end
resource "joblib" do
url "https://files.pythonhosted.org/packages/15/0f/d3b33b9f106dddef461f6df1872b7881321b247f3d255b87f61a7636f7fe/joblib-1.3.2.tar.gz"
sha256 "92f865e621e17784e7955080b6d042489e3b8e294949cc44c6eac304f59772b1"
end
resource "jsonschema" do
url "https://files.pythonhosted.org/packages/99/ba/e51d376c6160d27669c7a9ad0b61d9cbd58fa58be6e6ddc0e7e0b6e6aa40/jsonschema-4.19.0.tar.gz"
sha256 "6e1e7569ac13be8139b2dd2c21a55d350066ee3f80df06c608b398cdc6f30e8f"
end
resource "jsonschema-specifications" do
url "https://files.pythonhosted.org/packages/12/ce/eb5396b34c28cbac19a6a8632f0e03d309135d77285536258b82120198d8/jsonschema_specifications-2023.7.1.tar.gz"
sha256 "c91a50404e88a1f6ba40636778e2ee08f6e24c5613fe4c53ac24578a5a7f72bb"
end
resource "lazy-imports" do
url "https://files.pythonhosted.org/packages/70/74/f9c3c59876a7423d0a152f6f8e95ef27e24d3802deec81ab293c93f9edc3/lazy_imports-0.3.1.tar.gz"
sha256 "636624104bf45b09761323e06292927832aca067c3c199e5de483738789aeb21"
end
resource "monotonic" do
url "https://files.pythonhosted.org/packages/ea/ca/8e91948b782ddfbd194f323e7e7d9ba12e5877addf04fb2bf8fca38e86ac/monotonic-1.6.tar.gz"
sha256 "3a55207bcfed53ddd5c5bae174524062935efed17792e9de2ad0205ce9ad63f7"
end
resource "more-itertools" do
url "https://files.pythonhosted.org/packages/2d/73/3557e45746fcaded71125c0a1c0f87616e8258c78391f0c365bf97bbfc99/more-itertools-10.1.0.tar.gz"
sha256 "626c369fa0eb37bac0291bce8259b332fd59ac792fa5497b59837309cd5b114a"
end
resource "networkx" do
url "https://files.pythonhosted.org/packages/fd/a1/47b974da1a73f063c158a1f4cc33ed0abf7c04f98a19050e80c533c31f0c/networkx-3.1.tar.gz"
sha256 "de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61"
end
resource "num2words" do
url "https://files.pythonhosted.org/packages/74/67/3008e4f0b97d9a5701c8ef3bf95f1941c5b0a620c8f88f32e849117f8dc0/num2words-0.5.12.tar.gz"
sha256 "7e7c0b0f080405aa3a1dd9d32b1ca90b3bf03bab17b8e54db05e1b78301a0988"
end
resource "packaging" do
url "https://files.pythonhosted.org/packages/b9/6c/7c6658d258d7971c5eb0d9b69fa9265879ec9a9158031206d47800ae2213/packaging-23.1.tar.gz"
sha256 "a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f"
end
resource "versioneer" do # pandas
url "https://files.pythonhosted.org/packages/32/d7/854e45d2b03e1a8ee2aa6429dd396d002ce71e5d88b77551b2fb249cb382/versioneer-0.29.tar.gz"
sha256 "5ab283b9857211d61b53318b7c792cf68e798e765ee17c27ade9f6c924235731"
end
resource "tomli" do # pandas
url "https://files.pythonhosted.org/packages/c0/3f/d7af728f075fb08564c5949a9c95e44352e23dee646869fa104a3b2060a3/tomli-2.0.1.tar.gz"
sha256 "de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"
end
resource "pandas" do
url "https://files.pythonhosted.org/packages/b1/a7/824332581e258b5aa4f3763ecb2a797e5f9a54269044ba2e50ac19936b32/pandas-2.0.3.tar.gz"
sha256 "c02f372a88e0d17f36d3093a644c73cfc1788e876a7c4bcb4020a77512e2043c"
end
resource "pkgutil_resolve_name" do
url "https://files.pythonhosted.org/packages/70/f2/f2891a9dc37398696ddd945012b90ef8d0a034f0012e3f83c3f7a70b0f79/pkgutil_resolve_name-1.3.10.tar.gz"
sha256 "357d6c9e6a755653cfd78893817c0853af365dd51ec97f3d358a819373bbd174"
end
resource "platformdirs" do
url "https://files.pythonhosted.org/packages/dc/99/c922839819f5d00d78b3a1057b5ceee3123c69b2216e776ddcb5a4c265ff/platformdirs-3.10.0.tar.gz"
sha256 "b45696dab2d7cc691a3226759c0d3b00c47c8b6e293d96f6436f733303f77f6d"
end
resource "posthog" do
url "https://files.pythonhosted.org/packages/e2/ee/5ef8fc4f91a8027e3388785bfdf3180729d80f83bc19958eb814fb4625b8/posthog-3.0.2.tar.gz"
sha256 "701fba6e446a4de687c6e861b587e7b7741955ad624bf34fe013c06a0fec6fb3"
end
resource "prompthub-py" do
url "https://files.pythonhosted.org/packages/db/95/24c62ce6ae9d8a087576f89dcaffbc05b3c3b2bc6d1367204a5cab570a48/prompthub_py-4.0.0.tar.gz"
sha256 "d2d145213c86712d1951b840e77b8193b9605de77eb5119ce737ba66a058ca29"
end
resource "pydantic" do
url "https://files.pythonhosted.org/packages/3b/9b/a7631bf35e55326fd74654fe6bd896478f47d65e97ca69e60ddb1b3823ee/pydantic-1.10.12.tar.gz"
sha256 "0fe8a415cea8f340e7a9af9c54fc71a649b43e8ca3cc732986116b3cb135d303"
end
resource "python-dateutil" do
url "https://files.pythonhosted.org/packages/4c/c4/13b4776ea2d76c115c1d1b84579f3764ee6d57204f6be27119f13a61d0a9/python-dateutil-2.8.2.tar.gz"
sha256 "0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"
end
resource "pytz" do
url "https://files.pythonhosted.org/packages/5e/32/12032aa8c673ee16707a9b6cdda2b09c0089131f35af55d443b6a9c69c1d/pytz-2023.3.tar.gz"
sha256 "1d8ce29db189191fb55338ee6d0387d82ab59f3d00eac103412d64e0ebd0c588"
end
resource "quantulum3" do
url "https://files.pythonhosted.org/packages/df/21/30b1e76d6ac1716b8360d41e44ffadae0c627056e29626c1a75f2fcb127e/quantulum3-0.9.0.tar.gz"
sha256 "6624adf9462d70b4d633415db3da20bfcc72bc1c40c668fa7ff635b07198a14d"
# Add missing 'requirements_classifier.txt' file required by setup.py
# PR ref: https://github.com/nielstron/quantulum3/pull/TODO # TODO: submit a PR to upstream project
patch do
url "https://gist.github.com/scorphus/b110f3ac1fb897ec7b4aecb01ae250c8/raw/01046375d302368d6832de92f697df0f099e28b1/quantulum3-0.9.0-patch00-requirements_classifier.txt-No_such_file.diff"
sha256 "312c944349a13a4299ef5f68631005cf774c870e015d0b767d74fc30b0550909"
end
end
resource "rank-bm25" do
url "https://files.pythonhosted.org/packages/fc/0a/f9579384aa017d8b4c15613f86954b92a95a93d641cc849182467cf0bb3b/rank_bm25-0.2.2.tar.gz"
sha256 "096ccef76f8188563419aaf384a02f0ea459503fdf77901378d4fd9d87e5e51d"
# Add missing 'version.py' file required by setup.py
# PR ref: https://github.com/dorianbrown/rank_bm25/pull/TODO # TODO: submit a PR to upstream project
patch do
url "https://gist.github.com/scorphus/b110f3ac1fb897ec7b4aecb01ae250c8/raw/01046375d302368d6832de92f697df0f099e28b1/rank_bm25-0.2.2-patch00-version.py-No_module_named_version.diff"
sha256 "7592dae0a48846246d8701d3d3632e9fee4bd9ae3c5efa09ead6dafbbd3e81c8"
end
end
resource "referencing" do
url "https://files.pythonhosted.org/packages/e1/43/d3f6cf3e1ec9003520c5fb31dc363ee488c517f09402abd2a1c90df63bbb/referencing-0.30.2.tar.gz"
sha256 "794ad8003c65938edcdbc027f1933215e0d0ccc0291e3ce20a4d87432b59efc0"
end
resource "regex" do
url "https://files.pythonhosted.org/packages/4f/1d/6998ba539616a4c8f58b07fd7c9b90c6b0f0c0ecbe8db69095a6079537a7/regex-2023.8.8.tar.gz"
sha256 "fcbdc5f2b0f1cd0f6a56cdb46fe41d2cce1e644e3b68832f3eeebc5fb0f7712e"
end
resource "requests" do
url "https://files.pythonhosted.org/packages/9d/be/10918a2eac4ae9f02f6cfe6414b7a155ccd8f7f9d4380d62fd5b955065c3/requests-2.31.0.tar.gz"
sha256 "942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"
end
resource "requests-cache" do
url "https://files.pythonhosted.org/packages/c6/63/76613d73fb4ec23cc2451c1be30974a373c7258274db2e4f79530bda505d/requests_cache-0.9.8.tar.gz"
sha256 "eaed4eb5fd5c392ba5e7cfa000d4ab96b1d32c1a1620f37aa558c43741ac362b"
end
resource "rpds-py" do
url "https://files.pythonhosted.org/packages/77/5a/0c82d0ef1322227e8e997dbbd3d4e235383d51c299dbdfd2fed2625971b0/rpds_py-0.10.0.tar.gz"
sha256 "e36d7369363d2707d5f68950a64c4e025991eb0177db01ccb6aa6facae48b69f"
end
resource "safetensors" do
url "https://files.pythonhosted.org/packages/ea/43/9911dc3ab9c8da3ef0ecf9c81cca132327f73beb22be9b03eaa9f3070d40/safetensors-0.3.3.tar.gz"
sha256 "edb7072d788c4f929d0f5735d3a2fb51e5a27f833587828583b7f5747af1a2b8"
end
resource "scikit-learn" do
url "https://files.pythonhosted.org/packages/72/cd/4761675df1b3dd93072c89697278f3ed3dc004a60c034cd2603c43ff64b5/scikit-learn-1.3.0.tar.gz"
sha256 "8be549886f5eda46436b6e555b0e4873b4f10aa21c07df45c4bc1735afbccd7a"
end
resource "sseclient-py" do
url "https://files.pythonhosted.org/packages/7d/1f/29688479e7e57a4cd847ded630be27b3a96f64b379e7f0136f64020f6308/sseclient-py-1.7.2.tar.gz"
sha256 "ba3197d314766eccb72a1dda80b5fa14a0fbba07d796a287654c07edde88fe0f"
end
resource "tenacity" do
url "https://files.pythonhosted.org/packages/89/3c/253e1627262373784bf9355db9d6f20d2d8831d79f91e9cca48050cddcc2/tenacity-8.2.3.tar.gz"
sha256 "5398ef0d78e63f40007c1fb4c0bff96e1911394d2fa8d194f77619c05ff6cc8a"
end
resource "threadpoolctl" do
url "https://files.pythonhosted.org/packages/47/8a/c05f7831beb32aff70f808766224f11c650f7edfd49b27a8fc6666107006/threadpoolctl-3.2.0.tar.gz"
sha256 "c96a0ba3bdddeaca37dc4cc7344aafad41cdb8c313f74fdfe387a867bba93355"
end
resource "tiktoken" do
url "https://files.pythonhosted.org/packages/9f/88/77a86f915a81449156375b7538c94105a34bebf00838462c9d3fced490e9/tiktoken-0.4.0.tar.gz"
sha256 "59b20a819969735b48161ced9b92f05dc4519c17be4015cfb73b65270a243620"
end
resource "tokenizers" do
url "https://files.pythonhosted.org/packages/29/9c/936ebad6dd963616189d6362f4c2c03a0314cf2a221ba15e48dd714d29cf/tokenizers-0.13.3.tar.gz"
sha256 "2e546dbb68b623008a5442353137fbb0123d311a6d7ba52f2667c8862a75af2e"
end
resource "tqdm" do
url "https://files.pythonhosted.org/packages/62/06/d5604a70d160f6a6ca5fd2ba25597c24abd5c5ca5f437263d177ac242308/tqdm-4.66.1.tar.gz"
sha256 "d88e651f9db8d8551a62556d3cff9e3034274ca5d66e93197cf2490e2dcb69c7"
end
resource "transformers" do
url "https://files.pythonhosted.org/packages/7d/51/6cf951c6faa731c9a54813bfbadb9f2d978a9c50687775f85a23bd23cd65/transformers-4.31.0.tar.gz"
sha256 "4302fba920a1c24d3a429a29efff6a63eac03f3f3cf55b55927fc795d01cb273"
end
resource "tzdata" do
url "https://files.pythonhosted.org/packages/70/e5/81f99b9fced59624562ab62a33df639a11b26c582be78864b339dafa420d/tzdata-2023.3.tar.gz"
sha256 "11ef1e08e54acb0d4f95bdb1be05da659673de4acbd21bf9c69e94cc5e907a3a"
end
resource "url-normalize" do
url "https://files.pythonhosted.org/packages/ec/ea/780a38c99fef750897158c0afb83b979def3b379aaac28b31538d24c4e8f/url-normalize-1.4.3.tar.gz"
sha256 "d23d3a070ac52a67b83a1c59a0e68f8608d1cd538783b401bc9de2c0fac999b2"
end
resource "urllib3" do
url "https://files.pythonhosted.org/packages/31/ab/46bec149bbd71a4467a3063ac22f4486ecd2ceb70ae8c70d5d8e4c2a7946/urllib3-2.0.4.tar.gz"
sha256 "8d22f86aae8ef5e410d4f539fde9ce6b2113a001bb4d189e0aed70642d602b11"
end
resource "zipp" do
url "https://files.pythonhosted.org/packages/e2/45/f3b987ad5bf9e08095c1ebe6352238be36f25dd106fde424a160061dce6d/zipp-3.16.2.tar.gz"
sha256 "ebc15946aa78bd63458992fc81ec3b6f7b1e92d51c35e6de1c3804e73b799147"
end
def install
virtualenv_install_with_resources
# link huggingface-cli virtualenv to make huggingface_hub available
site_packages = Language::Python.site_packages("python3.11")
paths = %w[pytorch huggingface-cli].map do |package_name|
package = Formula[package_name].opt_libexec
package/site_packages
end
(libexec/site_packages/"homebrew-deps.pth").write paths.join("\n")
end
test do
system bin/"haystack --help"
assert_match "Usage: haystack [OPTIONS] COMMAND [ARGS]...", shell_output("#{bin}/haystack --help")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment