Closed AlJohri closed 4 years ago
Latest formula
class Userpath < Formula
include Language::Python::Virtualenv
desc "Cross-platform tool for adding locations to the user PATH"
url "https://files.pythonhosted.org/packages/32/92/4abff0a80d028a306e00bf82f8b21ff18d9ad8199b6d179da3521edf83af/userpath-1.2.0.tar.gz"
sha256 "10fa2a90c61546f188989680a9b7510888b976f5d18503ad4482c8f919e783cb"
depends_on "python3"
resource "click" do
url "https://files.pythonhosted.org/packages/f8/5c/f60e9d8a1e77005f664b76ff8aeaee5bc05d0a91798afd7f53fc998dbc47/Click-7.0.tar.gz"
sha256 "5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"
end
resource "distro" do
url "https://files.pythonhosted.org/packages/ca/e3/78443d739d7efeea86cbbe0216511d29b2f5ca8dbf51a6f2898432738987/distro-1.4.0.tar.gz"
sha256 "362dde65d846d23baee4b5c058c8586f219b5a54be1cf5fc6ff55c4578392f57"
end
def install
xy = Language::Python.major_minor_version "python3"
ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python#{xy}/site-packages"
resources.each do |r|
r.stage do
system "python3", *Language::Python.setup_install_args(libexec/"vendor")
end
end
ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python#{xy}/site-packages"
system "python3", *Language::Python.setup_install_args(libexec)
bin.install Dir["#{libexec}/bin/*"]
bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"])
end
test do
system 'mkdir -p temphome'
system 'userpath append --force --shell bash --home "temphome" /randompath >/dev/null 2>&1 || true'
system 'grep -q "/randompath" temphome/.bash_profile'
end
end
@ofek can you help me write a test? I'm having trouble getting --home
to work.
mkdir -p temphome
touch temphome/.bash_profile
userpath append --shell bash --home "temphome" ~/.local/bin
# assert path in temphome/.bash_profile
rm -rf temphome
EDIT: updated with final formula including test
@AlJohri Sorry, what's not working?
Please try running the short snippet above or let me know if that invocation looks incorrect.
Oh do you mean the error checking? We could do 2 things:
Up to you, let me know 🙂
got it, I didn't realize it was just failing the validation. I can work around that then for now.
mkdir -p temphome
userpath append --force --shell bash --home "temphome" /randompath >/dev/null 2>&1 || true
grep -q "/randompath" temphome/.bash_profile
updating the comment above with the final formula
Any updates on this? (Thanks for leading the charge on it!)
@proinsias I was waiting for https://github.com/ofek/userpath/issues/3 but I suppose its not technically a blocker. The current behavior is differing from my expectations so I wasn't planning on using it until #3 is fixed
happy to submit it earlier if you need it
"Need" is a strong word :) I am certainly looking forward to Homebrew/homebrew-core#40300 getting merged, which I believe is dependent on this PR.
@proinsias is there a particular feature you need from 0.14.0.0
? you should already be able to brew install pipx
, right?
pipx completions
. This is from 0.13.2.0 though, so an upgrade to 0.14.0.0 isn't necessary, but I didn't want to propose an upgrade to 0.13.2.0 if you were close to finishing this.
Closing this issue for now as pipx no longer needs userpath
as a top level tool.
Here is a work in progress homebrew formula. Just the testing section needs to be filled out:
pipx formula for reference: https://github.com/Homebrew/homebrew-core/blob/master/Formula/pipx.rb