<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Squademy</title>
    <description>The latest articles on Forem by Squademy (@squademy).</description>
    <link>https://forem.com/squademy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F626543%2F52016a18-76c5-4f5a-8829-2cdf263e3499.png</url>
      <title>Forem: Squademy</title>
      <link>https://forem.com/squademy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/squademy"/>
    <language>en</language>
    <item>
      <title>Install and manage multiple Python versions on macOS 11 (Apple Silicon) with pyenv</title>
      <dc:creator>Squademy</dc:creator>
      <pubDate>Sun, 13 Jun 2021 06:36:34 +0000</pubDate>
      <link>https://forem.com/squademy/install-and-manage-multiple-python-versions-on-macos-11-apple-silicon-with-pyenv-2n3a</link>
      <guid>https://forem.com/squademy/install-and-manage-multiple-python-versions-on-macos-11-apple-silicon-with-pyenv-2n3a</guid>
      <description>&lt;h2&gt;
  
  
  A fresh Mac and its default Python
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;macOS 11&lt;/strong&gt; comes with a default version of python2, which is now obsolete in favor of python3. Python2 reached end of life in January 2020.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ type -a python
python is /usr/bin/python

$ which python
/usr/bin/python

$ python --version
Python 2.7.16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are certainly do not want to touch macOS's default python2 and will leave it as it is. Let's install &lt;code&gt;pyenv&lt;/code&gt; to manage multiple versions of Python.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install &lt;code&gt;pyenv&lt;/code&gt; on macOS 11 (Apple Silicon)
&lt;/h2&gt;

&lt;p&gt;There are two ways to install &lt;code&gt;pyenv&lt;/code&gt; on macOS:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Via &lt;a href="https://brew.sh/"&gt;Homebrew&lt;/a&gt;: this is the quickest way. Unfortunately I could not make &lt;code&gt;pyenv&lt;/code&gt; works as expected on a fresh macOS 11 (Apple Silicon).&lt;/li&gt;
&lt;li&gt;Git checkout: &lt;code&gt;pyenv&lt;/code&gt; team has documented the install process in details &lt;a href="https://github.com/pyenv/pyenv#basic-github-checkout"&gt;here&lt;/a&gt;. However, when I followed that step by step and applied on my new macOS 11 (M1), it did not work. After serveral hours tweaking, here's how I managed to get the &lt;code&gt;pyenv&lt;/code&gt; to work with Git check out installation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;1.Clone the &lt;code&gt;pyenv&lt;/code&gt; repo into your home folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv
$ cd ~/.pyenv &amp;amp;&amp;amp; src/configure &amp;amp;&amp;amp; make -C src
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Edit your &lt;code&gt;.zshrc&lt;/code&gt; and add the following lines at the bottom of the file (macOS 11 comes with zsh as the default shell)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.Quit your terminal and reopen it. Now &lt;code&gt;pyenv&lt;/code&gt; should be &lt;a href="https://github.com/pyenv/pyenv#how-it-works"&gt;activated&lt;/a&gt; and you can start to install some Python.&lt;/p&gt;

&lt;h2&gt;
  
  
  My macOS 11 (Big Sur, Apple Silicon) system info before install Python
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ arch
arm64

$ which brew
/opt/homebrew/bin/brew

$ brew --version
Homebrew 3.1.11
Homebrew/homebrew-core (git revision 7c34424687; last commit 2021-06-10)
Homebrew/homebrew-cask (git revision ab9a64f927; last commit 2021-06-10)

$ pyenv --version
pyenv 2.0.1-3-g1706436f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Install the Python build dependencies for macOS 11
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;pyenv&lt;/code&gt; suggests that before install any version of Python, we need a &lt;a href="https://github.com/pyenv/pyenv/wiki#suggested-build-environment"&gt;Python build environment for Mac&lt;/a&gt;. Make sure you have Xcode Command Line Tools (&lt;code&gt;xcode-select --install&lt;/code&gt;) and Homebrew on your system. Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ brew install openssl readline sqlite3 xz zlib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;For a complete guide on how to install Homebrew on a fresh macOS 11 Big Sur (Apple Silicon), check out &lt;a href="https://squademy.medium.com/install-homebrew-on-macos-11-apple-silicon-630f37a74490"&gt;this guide&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Python 3.9 on macOS 11 M1 (Apple Silicon) with &lt;code&gt;pyenv&lt;/code&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pyenv install 3.9.4
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.4.tar.xz...
-&amp;gt; https://www.python.org/ftp/python/3.9.4/Python-3.9.4.tar.xz
Installing Python-3.9.4...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.9.4 to /Users/squademy/.pyenv/versions/3.9.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;pyenv&lt;/code&gt; install Python 3.9.4 seamlessly on Mac M1 and everything works out of the box.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Note
&lt;/h2&gt;

&lt;p&gt;This guide originally published and frequently updated &lt;a href="https://squademy.medium.com/install-python-on-macos-11-m1-apple-silicon-using-pyenv-12e0729427a9"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>applesilion</category>
      <category>pyenv</category>
      <category>python</category>
      <category>m1</category>
    </item>
    <item>
      <title>Install and configure Git on a fresh new macOS 11 Big Sur in 2021 — A complete guide</title>
      <dc:creator>Squademy</dc:creator>
      <pubDate>Sat, 08 May 2021 14:27:18 +0000</pubDate>
      <link>https://forem.com/squademy/install-and-configure-git-on-a-fresh-new-macos-11-big-sur-in-2021-a-complete-guide-6ld</link>
      <guid>https://forem.com/squademy/install-and-configure-git-on-a-fresh-new-macos-11-big-sur-in-2021-a-complete-guide-6ld</guid>
      <description>&lt;h1&gt;
  
  
  Install Git on a fresh macOS 11 Big Sur
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1. Install XCode 12 (optional)
&lt;/h2&gt;

&lt;p&gt;Xcode is an IDE for macOS containing a suite of software development tools for developing software for macOS, iOS, watchOS and tvOS. Even if you're not a full time professional Apple developer, we still recommend to install it on your brand new laptop/iMac. Xcode has some long term benefits that you'll need in the future.&lt;br&gt;
Xcode 12 is around 11 GB and downloading it though Apple Store might need some times, depends on how fast your Internet connection is.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Install Xcode Command Line Tools (required)
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;$ xcode-select --install&lt;/code&gt;&lt;br&gt;
Xcode CTL will bring Git to you systems, along with other tools to build and compile software packages such as: GCC, Make..&lt;br&gt;
When it's done, to test that it installed properly you can run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git --version
git version 2.30.1 (Apple Git-130)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And $ which git should output &lt;code&gt;/usr/bin/git&lt;/code&gt;&lt;br&gt;
Another way to install Git is to install Homebrew and then install Git though brew commands. Homebrew calls itself The missing package manager for macOS and is an essential tool for any developer. We highly recommend it.&lt;br&gt;
To install HomeBrew:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;For a complete guide on install Homebrew on Mac M1 ARM, please read&lt;/strong&gt; &lt;a href="https://squademy.medium.com/install-homebrew-on-macos-11-apple-silicon-630f37a74490"&gt;this article&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now install Git via Homebrew with &lt;code&gt;$ brew install git&lt;/code&gt;&lt;br&gt;
When done, to test that it installed properly you can run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And which git should output &lt;code&gt;/usr/local/bin/git&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Notice that the Git version installed from brew is likely more update-to-date than the Git version in Xcode CTL. Homebrew always put it things on &lt;code&gt;/usr/local/bin/&lt;/code&gt; path which owned by a local user, in stead of the &lt;code&gt;/usr/bin/&lt;/code&gt; in Xcode CTL which owned by the macOS system.&lt;/p&gt;

&lt;h1&gt;
  
  
  Git setup at global level
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1. Set global user.name and user.email
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git config --global user.name "Your Name" 
$ git config --global user.email "your_email@your_company.com"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The global Git configuration file is stored at &lt;code&gt;$HOME/.gitconfig&lt;/code&gt; on all platforms, i.e: &lt;code&gt;~/.gitconfig&lt;/code&gt;. You shouldn't need to manually tweak this file, unless you particularly want to. Use this command to open up Vim editor with that file loaded, if you're keen:&lt;br&gt;
&lt;code&gt;$ git config --global --edit&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Enable Git password caching
&lt;/h2&gt;

&lt;p&gt;Let's macOS save the Git credentials on its keychain, so that you won't have to type Git passwords many times:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git config --global credential.helper osxkeychain
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Only allow git pull in fast-forward mode
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git config --global pull.ff only
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's a good practice and if you're wondering why, here is the reason: &lt;a href="https://blog.sffc.xyz/post/185195398930/why-you-should-use-git-pull-ff-only-git-is-a"&gt;https://blog.sffc.xyz/post/185195398930/why-you-should-use-git-pull-ff-only-git-is-a&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. macOS globally ignored files
&lt;/h2&gt;

&lt;p&gt;On a Mac, it is important to remember to add &lt;code&gt;.DS_Store&lt;/code&gt; (a hidden macOS system file that's put in folders) to your &lt;code&gt;~/.gitignore&lt;/code&gt; files. If you want to never include &lt;code&gt;.DS_Store&lt;/code&gt; files in your Git repositories, you can configure your Git to globally exclude those files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# specify a global exclusion list:
$ git config --global core.excludesfile ~/.gitignore

# adding .DS_Store to that list:
$ echo .DS_Store &amp;gt;&amp;gt; ~/.gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you would like to use some ready-to-use file, consider Github's default &lt;code&gt;.gitignore&lt;/code&gt; for macOS environment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl https://raw.githubusercontent.com/github/gitignore/master/Global/macOS.gitignore -o ~/.gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Force Git to use https:// instead of git://, or vice versa
&lt;/h2&gt;

&lt;p&gt;Some package manager, such as NPM has package.json file fixed with SSH protocol and you might behind a corporate firewall that does not allow SSH..&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"dependencies": {
    "package_name": "git+ssh://git@git.scm.domain.com:Domain/package_name.git",
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The only option is to force Git to change its protocol to HTTPS for you to be able to install the package - notice the semicolon in &lt;code&gt;git@github.com:&lt;/code&gt; must be included&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git config --global url."https://github.com/".insteadOf git@github.com:
$ git config --global url."https://".insteadOf git://
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to switch it back:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git config --global url."git@github.com:".insteadOf https://github.com/
$ git config --global url."git://".insteadOf https://
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Global Git config file - final result
&lt;/h2&gt;

&lt;p&gt;Final &lt;code&gt;~/.gitconfig&lt;/code&gt; will be something similar to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[user]
        name = Your Name
        email = your-email@your-company.com
[pull]
        ff = only
[core]
        excludesfile = /Users/user1/.gitignore
[credential]
        helper = osxkeychain
[url "https://github.com/"]
        insteadOf = git@github.com
[url "https://"]
        insteadOf = git://
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# edit and list global Git config:
git config --global --edit
git config --global --list
# edit and list local Git config
git config --local --edit
git config --local --list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Latest updates on this article &lt;a href="https://squademy.medium.com/install-and-configure-git-on-a-fresh-new-macos-11-big-sur-in-2021-a-complete-guide-ed64961292e4"&gt;available here&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Related guide: &lt;a href="https://squademy.medium.com/install-python-on-macos-11-m1-apple-silicon-using-pyenv-12e0729427a9"&gt;Install multiple Python versions on MacOS 11 M1 Big Sur using pyenv&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>macos</category>
      <category>bigsur</category>
      <category>git</category>
      <category>github</category>
    </item>
  </channel>
</rss>
