From 05e0309001db74e343832a7afc4b4c8d23896c73 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Mon, 4 Jul 2016 03:28:58 -0400 Subject: Fix Homebrew Python voodoo so that PySerial loads correctly. --- build-homebrew-formula.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/build-homebrew-formula.py b/build-homebrew-formula.py index 26a587c..e82c1a5 100755 --- a/build-homebrew-formula.py +++ b/build-homebrew-formula.py @@ -40,22 +40,34 @@ class CryptechAlpha < Formula end def install - # Homebrew voodoo for installing Python dependencies without depending on pip. - # In theory, this handles any number of (Python) resource specifications. + # Installation is a bit complex due to the way Homebrew handles + # Python library dependencies and due to our stuff being a mix of + # Python and C. + + # Set PYTHONPATH to point to our private library location. ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages" + + # Add all resources (and assume they are all Python, be careful...). resources.each do |r| r.stage do system "python", *Language::Python.setup_install_args(libexec/"vendor") end end + # Build everything. ohai "Building PKCS #11 code (including crypto and bignum libraries) from source, this is slow, sorry..." ENV.deparallelize system "make", "-C", "sw/pkcs11" + + # Install the Python script(s) then replace them with stubs which + # set PYTHONPATH before calling the real script(s). + sbin.install "sw/stm32/projects/hsm/cryptech_upload" + sbin.env_script_all_files(libexec/"sbin", :PYTHONPATH => ENV["PYTHONPATH"]) + + # Install other (non-Python) stuff, then we are done. share.install "cryptech-alpha-firmware.tar.gz" lib.install "sw/pkcs11/libpkcs11.dylib" sbin.install "sw/pkcs11/p11util" - sbin.install "sw/stm32/projects/hsm/cryptech_upload" end end -- cgit v1.2.3