Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure CLI 2.0 on Homebrew (with latest release 2.0.17) #17344

Closed
wants to merge 2 commits into from

Conversation

derekbekoe
Copy link
Contributor

@derekbekoe derekbekoe commented Aug 28, 2017


Copy link
Contributor

@tamird tamird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to create a version alias for the new formula as well:

Error: 1 problem in 1 formula
azure-cli:

  • Formula has other versions so create a versioned alias:
    cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Aliases
    ln -s ../Formula/azure-cli.rb azure-cli@2.0

@derekbekoe
Copy link
Contributor Author

@tamird thanks for the initial comments. I fixed that and some formatting of the formula also.

@ilovezfs
Copy link
Contributor

This is a duplicate of #13198 and it appears to have the exact same issue that it's not building the dependencies from source.

@derekbekoe
Copy link
Contributor Author

derekbekoe commented Aug 29, 2017

Hi @ilovezfs the main blocker with that PR was that there were dependency conflicts.
This has been fixed in the latest version of upstream.

Also, some dependencies do not have source packages (Python sdist) available.

@derekbekoe
Copy link
Contributor Author

The product source code is built from source with https://azurecliprod.blob.core.windows.net/releases/azure-cli_packaged_2.0.15.tar.gz

@ilovezfs
Copy link
Contributor

I mean the dependencies, not the product source code.

Copy link
Contributor

@ilovezfs ilovezfs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All dependencies need to be built from source not just the azure wheels themselves.

@ilovezfs
Copy link
Contributor

Hi @ilovezfs the main blocker with that PR was that there were dependency conflicts.
This has been fixed in the latest version of upstream.

Also, some dependencies do not have source packages (Python sdist) available.

Regardless of whether the conflicts have or have not been resolved, I'm afraid we'll have to pass on this upgrade until everything can build from source.

@vszakats
Copy link
Contributor

If you agree, it'd be nice to use this language-agnostic URL in homepage and in the caveat text:
https://docs.microsoft.com/cli/azure/overview

@derekbekoe
Copy link
Contributor Author

@vszakats thanks now using the language-agnostic URL.

@vszakats
Copy link
Contributor

Thank you @derekbekoe!

@derekbekoe
Copy link
Contributor Author

@ilovezfs I am taking a look at building everything (including dependencies) from source.
I will update soon.

@derekbekoe
Copy link
Contributor Author

@ilovezfs I now build from source by specifying --no-binary. 😄

Now we build from source, it takes longer to build.
Can bottles be created targeting the common macOS versions (sierra, el_capitan, yosemite).

Bottles states 'Bottles are created using the Brew Test Bot.'

Is this a process I need to initiate?

@helenlivsc
Copy link

After the fix is ready, does installing Azure Cli through homebrew require Xcode on MacOs in advance?

@derekbekoe
Copy link
Contributor Author

Once Azure CLI is available through Homebrew, brew install azure-cli is all that will be needed.

@derekbekoe
Copy link
Contributor Author

@ilovezfs Can we get another look at the PR?

@derekbekoe
Copy link
Contributor Author

Friendly ping on this. :)

@cglong
Copy link
Contributor

cglong commented Sep 3, 2017

@derekbekoe FWIW bottles (and the associated bottle stanza) are automatically generated as part of BrewTestBot and will be available once the PR has been merged 😄

@ilovezfs
Copy link
Contributor

ilovezfs commented Sep 3, 2017

Please recast this not to use virtualenv and to use setup_install_args instead.

@derekbekoe
Copy link
Contributor Author

Please recast this not to use virtualenv and to use setup_install_args instead.

@ilovezfs Can you provide an example or expand on this further?

Currently we use include Language::Python::Virtualenv then create the venv with virtualenv_create(libexec) and install with libexec/"bin/pip", "install", "--no-binary", ":all:".

This appears similar to these formulae.

@ilovezfs
Copy link
Contributor

ilovezfs commented Sep 5, 2017

cython, ipython, jupyter, meson, protobuf, snakemake, etc.

@derekbekoe
Copy link
Contributor Author

I will take a look at those examples though the current formula looks similar to these other formulae.

@ilovezfs
Copy link
Contributor

ilovezfs commented Sep 5, 2017

Yes, I did those. They're for small, frequently updated cases where I tired of maintaining the resource blocks. It's a hack.

@derekbekoe derekbekoe changed the title Azure CLI 2.0 on Homebrew (with latest release 2.0.15) Azure CLI 2.0 on Homebrew (with latest release 2.0.17) Sep 11, 2017
depends_on "openssl"
depends_on "python3"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be :python3 not "python3"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

system libexec/"bin/pip", "install", "--no-binary", ":all:", "--force-reinstall", "-U", "azure-nspkg", "azure-mgmt-nspkg", "-f", buildpath/"dist"
# 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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

touch site_packages/"azure/__init__.py"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The files already exist and contain these contents:

import pkg_resources
pkg_resources.declare_namespace(__name__)

I want to empty the contents of those files.
touch would create the file if it didn't exist but doesn't empty its contents.

@cglong
Copy link
Contributor

cglong commented Sep 14, 2017

The patch won't be merged upstream as the patch addresses an issue in Homebrew (not Azure CLI) - Azure/azure-cli#4428 (comment). In other words, the patch is specific to homebrew.

FYI, Homebrew has a policy against using patches "when patching something that will never be accepted upstream". The general recommendation is to instead use inreplace in this case, although obviously it's up to ILZ if there will be an exception in this case.

@ilovezfs
Copy link
Contributor

Where do az extension add extensions end up getting installed?

Regarding the patch, I think we'll need to do without it if it's never going to be merged upstream.

@derekbekoe
Copy link
Contributor Author

Extensions get installed into the user directory or ~/.azure/cliextensions to be specific.

The patch resolves Homebrew/brew#837 which is not an issue with upstream.

If the patch is removed, the user experience is less than ideal. Without the patch, az extension add commands fail with stacktraces like below. To clarify, this only happens due to Homebrew/brew#837 and doesn't happen with our other installers.

Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 742, in install
    **kwargs
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 831, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1032, in move_wheel_files
    isolated=self.isolated,
  File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 247, in move_wheel_files
    prefix=prefix,
  File "/usr/local/lib/python2.7/site-packages/pip/locations.py", line 153, in distutils_scheme
    i.finalize_options()
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 264, in finalize_options
    "must supply either home or prefix/exec-prefix -- not both"
DistutilsOptionError: must supply either home or prefix/exec-prefix -- not both

The only workaround in this case is for a user to temporarily create the ~/.pydistutils.cfg file, run az extension add, then remove the file afterwards.

The patch does this for them.

@ilovezfs
Copy link
Contributor

Then Homebrew/brew#837 would need to be fixed because a permanent patch isn't really OK.

@derekbekoe
Copy link
Contributor Author

It should be okay to leave the patch in until Homebrew/brew#837 is resolved.

@ilovezfs
Copy link
Contributor

Given Homebrew/brew#837 is closed, my assumption at this point has to be it will never be fixed, which means the patch is permanent, and therefore not acceptable.

@derekbekoe
Copy link
Contributor Author

If Homebrew/brew#837 isn't going to be fixed and a patch for that is required for this formula, it makes sense to make an exception for this patch.

@ilovezfs
Copy link
Contributor

Whether or not it makes sense from the perspective of functionality and user experience, I'm not willing to accept a patch that won't be upstreamed.

@derekbekoe
Copy link
Contributor Author

We'd like this formula in homebrew as it's a highly requested installer.

So if a patch to fix the user experience is not an option, what other option will you accept that can get this PR merged?

I can add a caveat message that explains how to manually temporarily create the ~/.pydistutils.cfg file then remove it afterwards. Would you accept that?

@ilovezfs
Copy link
Contributor

Would it not be possible to detect the installation is Homebrew, and handle it conditionally?

@derekbekoe
Copy link
Contributor Author

I have reopened Azure/azure-cli#4428.
We can look at having conditional logic in the Azure CLI code for the next release of the product.

Would like to get this PR merged. For the next release, I can include conditional logic for homebrew in Azure CLI.

Sound good?

@ilovezfs
Copy link
Contributor

Yup, thank you. The patch url is

url "https://raw.githubusercontent.com/Homebrew/formula-patches/e600681/azure-cli/bug-4428.patch"

@derekbekoe
Copy link
Contributor Author

Changed patch URL.

export PYTHONPATH="#{ENV["PYTHONPATH"]}"
python#{xy} -m azure.cli \"$@\"
EOS
(bin/"az").write az_exec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    (bin/"az").write <<-EOS.undent
      #!/usr/bin/env bash
      export PYTHONPATH="#{ENV["PYTHONPATH"]}"
      python#{xy} -m azure.cli \"$@\"
    EOS

That said, it would be nice if this could use the write_env_script DSL instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay changed this...

assert_equal azure_cloud["resourceManagerEndpointUrl"], "https://management.azure.com/"
version_output = shell_output("#{bin}/az --version")
assert_match "azure-cli", version_output
system bin/"az", "account", "list"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we assert the output matches something here? I'd like to just get rid of the version test above, and have this do something a bit more involved to make sure things are working properly. See the tests in faas-cli, jose, jupyter, and stubby for some good examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a different test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derekbekoe
Copy link
Contributor Author

@ilovezfs Anything else?

@ilovezfs
Copy link
Contributor

Please squash it down to one commit for azure-cli 2.0.17 and one commit for azure-cli@1 1.0.10.15 (new formula)

@derekbekoe
Copy link
Contributor Author

@ilovezfs done.

@ilovezfs ilovezfs closed this in fbad3a8 Sep 15, 2017
@ilovezfs
Copy link
Contributor

Thanks for your first contribution to Homebrew, @derekbekoe! (And for putting up with me.)

@derekbekoe
Copy link
Contributor Author

Thanks for your cooperation @ilovezfs.

@antoineco
Copy link
Contributor

Most anticipated, thanks for merging, and thanks @derekbekoe for making it happen :)

@lamdor
Copy link
Contributor

lamdor commented Sep 18, 2017

I ran into an issue with this formula after installing with it not finding the python image: #18240

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants