Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ jobs:
displayName: Build Homebrew Formula

dependsOn: BuildPythonWheel
condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual'))
condition: succeeded()
pool:
vmImage: 'ubuntu-16.04'
steps:
Expand Down
86 changes: 46 additions & 40 deletions scripts/release/homebrew/docker/formula_template.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class AzureCli < Formula
include Language::Python::Virtualenv

desc "Microsoft Azure CLI 2.0"
homepage "https://docs.microsoft.com/cli/azure/overview"
url "{{ upstream_url }}"
Expand All @@ -14,56 +16,60 @@ class AzureCli < Formula
{{ resources }}

def install
xy = Language::Python.major_minor_version "python3"
site_packages = libexec/"lib/python#{xy}/site-packages"
ENV.prepend_create_path "PYTHONPATH", site_packages
ENV.prepend "LDFLAGS", "-L#{Formula["openssl"].opt_lib}"
ENV.prepend "CFLAGS", "-I#{Formula["openssl"].opt_include}"
ENV.prepend "CPPFLAGS", "-I#{Formula["openssl"].opt_include}"
# xy = Language::Python.major_minor_version "python3"
# site_packages = libexec/"lib/python#{xy}/site-packages"
# ENV.prepend_create_path "PYTHONPATH", site_packages
# ENV.prepend "LDFLAGS", "-L#{Formula["openssl"].opt_lib}"
# ENV.prepend "CFLAGS", "-I#{Formula["openssl"].opt_include}"
# ENV.prepend "CPPFLAGS", "-I#{Formula["openssl"].opt_include}"

# Get the CLI components we'll install
components = [
buildpath/"src/azure-cli",
buildpath/"src/azure-cli-telemetry",
buildpath/"src/azure-cli-core",
buildpath/"src/azure-cli-nspkg",
buildpath/"src/azure-cli-command_modules-nspkg",
]
components += Pathname.glob(buildpath/"src/command_modules/azure-cli-*/")
# components = [
# buildpath/"src/azure-cli",
# buildpath/"src/azure-cli-telemetry",
# buildpath/"src/azure-cli-core",
# buildpath/"src/azure-cli-nspkg",
# buildpath/"src/azure-cli-command_modules-nspkg",
#]
# components += Pathname.glob(buildpath/"src/command_modules/azure-cli-*/")

# Install dependencies
# note: Even if in 'resources', don't include 'futures' as not needed for Python3
# and causes import errors. See https://github.com/agronholm/pythonfutures/issues/41
deps = resources.map(&:name).to_set - ["futures"]
deps.each do |r|
resource(r).stage do
system "python3", *Language::Python.setup_install_args(libexec)
end
end
# deps = resources.map(&:name).to_set - ["futures"]
#deps.each do |r|
# resource(r).stage do
# system "python3", *Language::Python.setup_install_args(libexec)
# end
#end

# Install CLI
components.each do |item|
cd item do
system "python3", *Language::Python.setup_install_args(libexec)
end
end
# components.each do |item|
# cd item do
# system "python3", *Language::Python.setup_install_args(libexec)
# end
# end

# # This replaces the `import pkg_resources` namespace imports from upstream
# # with empty string as the import is slow and not needed in this environment.
# File.open(site_packages/"azure/__init__.py", "w") {}
# File.open(site_packages/"azure/cli/__init__.py", "w") {}
# File.open(site_packages/"azure/cli/command_modules/__init__.py", "w") {}
# File.open(site_packages/"azure/mgmt/__init__.py", "w") {}

# This replaces the `import pkg_resources` namespace imports from upstream
# with empty string as the import is slow and not needed in this environment.
File.open(site_packages/"azure/__init__.py", "w") {}
File.open(site_packages/"azure/cli/__init__.py", "w") {}
File.open(site_packages/"azure/cli/command_modules/__init__.py", "w") {}
File.open(site_packages/"azure/mgmt/__init__.py", "w") {}
# (bin/"az").write <<~EOS
# #!/usr/bin/env bash
# export PYTHONPATH="#{ENV["PYTHONPATH"]}"
# if command -v python#{xy} >/dev/null 2>&1; then
# python#{xy} -m azure.cli \"$@\"
# else
# python3 -m azure.cli \"$@\"
# fi
#EOS

(bin/"az").write <<~EOS
#!/usr/bin/env bash
export PYTHONPATH="#{ENV["PYTHONPATH"]}"
if command -v python#{xy} >/dev/null 2>&1; then
python#{xy} -m azure.cli \"$@\"
else
python3 -m azure.cli \"$@\"
fi
EOS
venv = virtualenv_create(libexec, "python3")
venv.pip_install resources
venv.pip_install buildpath

bash_completion.install "az.completion" => "az"
end
Expand Down