From fa61a385ce1c3bcd6e2eb8571ef0c68370b587a0 Mon Sep 17 00:00:00 2001 From: Martin Strobel Date: Wed, 6 Mar 2019 14:25:12 -0800 Subject: [PATCH 1/3] Enable Homebrew Build & test for this PR. --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8bc22f24c3f..12ba9b41f27 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -196,7 +196,7 @@ jobs: displayName: Build Homebrew Formula dependsOn: BuildPythonWheel - condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual')) + condition: and(succeeded()) pool: vmImage: 'ubuntu-16.04' steps: From 283a7046be26b63b125dac7c3f09c56f19f5880d Mon Sep 17 00:00:00 2001 From: Martin Strobel Date: Wed, 6 Mar 2019 14:30:18 -0800 Subject: [PATCH 2/3] Super naive attempt, just to get the ball rolling --- .../homebrew/docker/formula_template.txt | 86 ++++++++++--------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/scripts/release/homebrew/docker/formula_template.txt b/scripts/release/homebrew/docker/formula_template.txt index c48c8fdacdc..90b3f69e463 100644 --- a/scripts/release/homebrew/docker/formula_template.txt +++ b/scripts/release/homebrew/docker/formula_template.txt @@ -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 }}" @@ -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 From bc2da7e5ad9cfdeea7ee9b9a558b1103ff10902c Mon Sep 17 00:00:00 2001 From: Martin Strobel Date: Wed, 6 Mar 2019 16:23:12 -0800 Subject: [PATCH 3/3] Fix broken ADO Homebrew build criteria --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 12ba9b41f27..fed2d4c1b2b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -196,7 +196,7 @@ jobs: displayName: Build Homebrew Formula dependsOn: BuildPythonWheel - condition: and(succeeded()) + condition: succeeded() pool: vmImage: 'ubuntu-16.04' steps: