Skip to content

Instantly share code, notes, and snippets.

@avoidik
Last active July 11, 2022 16:37
Show Gist options
  • Save avoidik/2ae9257240065a2b6733cc4f0c0e993f to your computer and use it in GitHub Desktop.
Save avoidik/2ae9257240065a2b6733cc4f0c0e993f to your computer and use it in GitHub Desktop.
Azure-Cli under cygwin
@echo off
setup-x86_64.exe -g -B -D -L -d -o -N -s http://cygwin.mirror.constant.com/ -l c:/tools/cygwin/distro -R c:/tools/cygwin -M

This is the unofficial installation guide, please refer to the official guide at https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest

  • download cygwin installation manager at https://cygwin.com/install.html
  • prepare base cygwin environment with curl and wget packages: setup-x86_64.exe -q -g -B -D -L -d -o -N -s http://cygwin.mirror.constant.com/ -l C:/cygwin/distro -R C:/cygwin -C Base -P curl,wget (FAQ CLI), omit last two parameters -C Base -P curl,wget to quietly update all cygwin packages, and optionally add -M to reveal package manager
  • exec installed cygwin shell
  • clean PATH environment variable: export PATH="/usr/local/bin:/usr/bin" (alternatively you may create a shortcut C:\cygwin\bin\mintty.exe -t "Cygwin Shell" -i "/Cygwin-Terminal.ico" /bin/env "CYGWIN_NOWINPATH=1" /bin/bash -l)
  • install apt-cyg: curl -sSL https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg -o /bin/apt-cyg
  • make apt-cyg executable: chmod +x /bin/apt-cyg
  • refresh apt-cyg cache: apt-cyg update
  • install required packages: apt-cyg install python3 python3-devel gcc-g++ gcc-core libffi-devel openssl-devel make libsodium-devel libssl-devel
  • create link to python3: ln -s /usr/bin/python3 /usr/bin/python
  • install pip: curl -sSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python get-pip.py
  • run install: SODIUM_INSTALL=system pip install azure-cli (may take some time to compile, if failed try to set specific version like azure-cli==2.0.61)
  • run external browser: export BROWSER="cygstart"
  • login: az login
  • confirm login in a web-browser
  • check with: az account show and az account list --o table

register cygwin in Windows context menu

apt-cyg install chere
chere -i -t mintty -e "Open Cygwin Here" -s bash -c -f -o '-t \"Cygwin Shell\" -i \"/Cygwin-Terminal.ico\"'
@echo off
setup-x86_64.exe -q -g -B -D -L -d -o -N -s http://cygwin.mirror.constant.com/ -l c:/tools/cygwin/distro -R c:/tools/cygwin -C Base -P curl,wget
@echo off
setup-x86_64.exe -q -g -B -D -L -d -o -N -s http://cygwin.mirror.constant.com/ -l c:/tools/cygwin/distro -R c:/tools/cygwin
@avoidik
Copy link
Author

avoidik commented Jun 24, 2022

I haven't tested this workaround, I am not using cygwin too much these days, but this is what you all can try

export CRYPTOGRAPHY_DONT_BUILD_RUST=1
export SODIUM_INSTALL=system
pip install cryptography==3.4.6 azure-cli

Version 3.4 is the latest release which doesn't require rust to be installed, it is rather a soft dependency there, but starting from version 3.5 it became a hard dependency, and rust must be installed anyway. However, I am not sure how good the latest version of azure-cli is backward-compatible with the older cryptography package, hence the azure-cli downgrade may be needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment