83 lines
3.1 KiB
Ruby
83 lines
3.1 KiB
Ruby
class Pyenv < Formula
|
|
desc "Python version management"
|
|
homepage "https://github.com/pyenv/pyenv"
|
|
url "https://github.com/pyenv/pyenv/archive/refs/tags/v2.3.2.tar.gz"
|
|
sha256 "150ac8f7161c00e8e613bf5e273306f674b60037e3dace9c6bb7611dceb17144"
|
|
license "MIT"
|
|
version_scheme 1
|
|
head "https://github.com/pyenv/pyenv.git", branch: "master"
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^v?(\d+(?:\.\d+)+(-\d+)?)$/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_monterey: "aa4269518d431edce18d4472cf72c571ac175b9b4120bd64b6f1b89ca94a4357"
|
|
sha256 cellar: :any, arm64_big_sur: "b70fdbb161f18ce25ffc046baf23b91fba4b0a6a802147f750086e32a5472f0f"
|
|
sha256 cellar: :any, monterey: "b37a5d64282152f2af9c63d2dbcd25f4ba2a3fa85decdbc2863dbd453a312658"
|
|
sha256 cellar: :any, big_sur: "025b8cd919d17474f365a0cf42155adf8f3305cd15c0a046c0961d124624cf12"
|
|
sha256 cellar: :any, catalina: "48cbcf88041b0e9eba5c260b28596281b73cadbaf62f5380ad1cb1c407ec47f2"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "0b363024d05bd19a0cdce620fe2a5b8e602986272790bf5626ee9dc71f201b6a"
|
|
end
|
|
|
|
depends_on "autoconf"
|
|
depends_on "openssl@1.1"
|
|
depends_on "pkg-config"
|
|
depends_on "readline"
|
|
|
|
uses_from_macos "bzip2"
|
|
uses_from_macos "libffi"
|
|
uses_from_macos "ncurses"
|
|
uses_from_macos "xz"
|
|
uses_from_macos "zlib"
|
|
|
|
on_linux do
|
|
depends_on "python@3.9" => :test
|
|
end
|
|
|
|
def install
|
|
inreplace "libexec/pyenv", "/usr/local", HOMEBREW_PREFIX
|
|
inreplace "libexec/pyenv-rehash", "$(command -v pyenv)", opt_bin/"pyenv"
|
|
inreplace "pyenv.d/rehash/source.bash", "$(command -v pyenv)", opt_bin/"pyenv"
|
|
|
|
system "src/configure"
|
|
system "make", "-C", "src"
|
|
|
|
prefix.install Dir["*"]
|
|
%w[pyenv-install pyenv-uninstall python-build].each do |cmd|
|
|
bin.install_symlink "#{prefix}/plugins/python-build/bin/#{cmd}"
|
|
end
|
|
|
|
share.install prefix/"man"
|
|
|
|
# Do not manually install shell completions. See:
|
|
# - https://github.com/pyenv/pyenv/issues/1056#issuecomment-356818337
|
|
# - https://github.com/Homebrew/homebrew-core/pull/22727
|
|
end
|
|
|
|
test do
|
|
# Create a fake python version and executable.
|
|
pyenv_root = Pathname(shell_output("pyenv root").strip)
|
|
python_bin = pyenv_root/"versions/1.2.3/bin"
|
|
foo_script = python_bin/"foo"
|
|
foo_script.write "echo hello"
|
|
chmod "+x", foo_script
|
|
|
|
# Test versions.
|
|
versions = shell_output("eval \"$(#{bin}/pyenv init --path)\" " \
|
|
"&& eval \"$(#{bin}/pyenv init -)\" " \
|
|
"&& pyenv versions").split("\n")
|
|
assert_equal 2, versions.length
|
|
assert_match(/\* system/, versions[0])
|
|
assert_equal(" 1.2.3", versions[1])
|
|
|
|
# Test rehash.
|
|
system "pyenv", "rehash"
|
|
refute_match "Cellar", (pyenv_root/"shims/foo").read
|
|
assert_equal "hello", shell_output("eval \"$(#{bin}/pyenv init --path)\" " \
|
|
"&& eval \"$(#{bin}/pyenv init -)\" " \
|
|
"&& PYENV_VERSION='1.2.3' foo").chomp
|
|
end
|
|
end
|