<?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>The Ops Community ⚙️: Sebastian Zawadzki</title>
    <description>The latest articles on The Ops Community ⚙️ by Sebastian Zawadzki (@schrenker).</description>
    <link>https://community.ops.io/schrenker</link>
    <image>
      <url>https://community.ops.io/images/auxiJwQMpiWmbUNZL6W0oSmSjnjMGidhUKcbYRK1hRg/rs:fill:90:90/g:sm/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL3Vz/ZXIvcHJvZmlsZV9p/bWFnZS81MDgvMTg1/MTAwMGEtY2ZjMi00/YzFkLTg0YTktZTI3/M2ZkY2M2ZjA0Lmpw/ZWc</url>
      <title>The Ops Community ⚙️: Sebastian Zawadzki</title>
      <link>https://community.ops.io/schrenker</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://community.ops.io/feed/schrenker"/>
    <language>en</language>
    <item>
      <title>Multiple separate versions of Python with pyenv + virtualenv (MacOS)</title>
      <dc:creator>Sebastian Zawadzki</dc:creator>
      <pubDate>Sat, 28 May 2022 18:26:31 +0000</pubDate>
      <link>https://community.ops.io/schrenker/multiple-separate-versions-of-python-with-pyenv-virtualenv-macos-h7e</link>
      <guid>https://community.ops.io/schrenker/multiple-separate-versions-of-python-with-pyenv-virtualenv-macos-h7e</guid>
      <description>&lt;p&gt;Not always you will be in comfort of using a single python version for everything you write. Sometimes you need to juggle the versions around. Also installing dependencies system wide can evolve into unmanageable mess, when you want to freeze the dependencies into requirements.txt file, and end up putting more than needed.&lt;/p&gt;

&lt;p&gt;Fortunately, python is popular enough to spawn multitude of tools to help with managing versions, and creating virtual environments, where you can put only required dependencies of your project. Combination of pyenv and virtualenv allows to do just that. For the purpose of this tutorial, I will be using MacOS and homebrew package manager, but you probably can succeed with changing some steps on Linux and Windows. I also assume that you have homebrew installed, if not, head to &lt;a href="https://brew.sh"&gt;https://brew.sh&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pyenv
&lt;/h2&gt;

&lt;p&gt;First of all, we need to install both pyenv and pyenv-virtualenv:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;brew install pyenv pyenv-virtualenv&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Next, you need to run &lt;code&gt;pyenv init&lt;/code&gt;, which will print out instructions on what needs to be done to configure shell for pyenv use. In my case for fish shell, following appears:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/tsey6Bo6FWvhPxwQhi5_anWWGG9KqUWTS_6z2zjfqOo/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3NpZ2lr/aTZzdHh4czh6MHpk/OHMzLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/tsey6Bo6FWvhPxwQhi5_anWWGG9KqUWTS_6z2zjfqOo/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3NpZ2lr/aTZzdHh4czh6MHpk/OHMzLnBuZw" alt="Image description" width="478" height="269"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;At this point you are almost done. So what can you do now? Well, you need to install python version through pyenv. Let's list available versions first via &lt;code&gt;pyenv install --list&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/JstoxGoCd94S2-oV8omDAVs2zGWVzDIgyJmrbjPbQJI/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2t6NjRu/c2ZtM3gzMjA4dWg4/eXBwLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/JstoxGoCd94S2-oV8omDAVs2zGWVzDIgyJmrbjPbQJI/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2t6NjRu/c2ZtM3gzMjA4dWg4/eXBwLnBuZw" alt="Image description" width="510" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are tons of versions, along with miniconda, anaconda and other flavors. In fact, at the time of writing this post, there are 564 versions available for install. Let's install version 3.9.12 for our example with &lt;code&gt;pyenv install 3.9.12&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/5X4GWubEFjgeV1ij46Q_Z5b6SS4uR85iBDs45LhJO_4/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3FmMTV3/NTRjN20ybmtzNnBx/OXczLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/5X4GWubEFjgeV1ij46Q_Z5b6SS4uR85iBDs45LhJO_4/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3FmMTV3/NTRjN20ybmtzNnBx/OXczLnBuZw" alt="Image description" width="559" height="201"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point you are pretty much done with pyenv. You can view your python versions with command &lt;code&gt;pyenv versions&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Virtualenv
&lt;/h2&gt;

&lt;p&gt;You can spin virtualenvs of pyenv versions you have installed. Simply run &lt;code&gt;pyenv virtualenv $python_version $custom_name&lt;/code&gt;. Your virtualenv will be now available at $custom_name.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/6Aix7cYNVhhyCcNApy8UZZ9QjvMbjsv8KbWfA6G23nE/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3oyNDNt/aWgyMWFiMnp2aDB1/OWF3LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/6Aix7cYNVhhyCcNApy8UZZ9QjvMbjsv8KbWfA6G23nE/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3oyNDNt/aWgyMWFiMnp2aDB1/OWF3LnBuZw" alt="Image description" width="800" height="114"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can now activate said virtualenv with &lt;code&gt;pyenv activate $custom_name&lt;/code&gt; (My terminal theme chose bad color, but before my login name, there is grey name with virtualenv. Sorry :D ):&lt;br&gt;
&lt;a href="https://community.ops.io/images/N6prfh_VEOK9a2VuUW3YzAQHYoGu9eKUYtujqJSYqLQ/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzQwbW0w/cG16dnM5aWhxZjJu/YTduLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/N6prfh_VEOK9a2VuUW3YzAQHYoGu9eKUYtujqJSYqLQ/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzQwbW0w/cG16dnM5aWhxZjJu/YTduLnBuZw" alt="Image description" width="453" height="60"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's install something to virtualenv, like my favourite package, Ansible:&lt;br&gt;
&lt;a href="https://community.ops.io/images/BJ8A38H43VxntjHZOEBv2xhiY7hgV4IBngymTXLznV8/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzg4eXh3/dHUxZDI1bHo4a3Fy/aHpuLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/BJ8A38H43VxntjHZOEBv2xhiY7hgV4IBngymTXLznV8/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzg4eXh3/dHUxZDI1bHo4a3Fy/aHpuLnBuZw" alt="Image description" width="704" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it! You can now either do some work with your virtualenv or disable it with &lt;code&gt;pyenv deactivate&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Doom Emacs bonus
&lt;/h2&gt;

&lt;p&gt;I am even more lazy, so with help of Internet and emacs, correct virtualenv is being activated as I switch to correct project.&lt;/p&gt;

&lt;p&gt;First of all, you will need to create virtualenv with the same name as your project. After that, in your project directory, run `pyenv local $custom_name. This will create .python-version file, which point to your pyenv virtualenv.&lt;br&gt;
&lt;a href="https://community.ops.io/images/MoR7jvSP7xRUBf6gnGlKPyTTW9t2uKOlDX4XGu8R-rM/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzdmZDhu/ZDhkNW5ybzJtOG1x/bWwzLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/MoR7jvSP7xRUBf6gnGlKPyTTW9t2uKOlDX4XGu8R-rM/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzdmZDhu/ZDhkNW5ybzJtOG1x/bWwzLnBuZw" alt="Image description" width="471" height="64"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now everytime I switch to this project, virtualenv will activate automatically for this project:&lt;br&gt;
&lt;a href="https://community.ops.io/images/4O2xDtzo6pGi0y9XCuAeEtSlQqu5Vpqrsarc_-efnmc/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3hwd3ll/Y2poYjI3Z3ZqMWJ3/YnFvLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/4O2xDtzo6pGi0y9XCuAeEtSlQqu5Vpqrsarc_-efnmc/w:800/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3hwd3ll/Y2poYjI3Z3ZqMWJ3/YnFvLnBuZw" alt="Image description" width="732" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can achieve this, by adding following to your emacs configuration:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
(require 'pyenv-mode)&lt;br&gt;
(defun projectile-pyenv-mode-set ()&lt;br&gt;
  (let ((project (projectile-project-name)))&lt;br&gt;
    (if (member project (pyenv-mode-versions))&lt;br&gt;
        (pyenv-mode-set project)&lt;br&gt;
      (pyenv-mode-unset))))&lt;br&gt;
(add-hook 'projectile-after-switch-project-hook 'projectile-pyenv-mode-set)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That is it. I hope it is useful. Pyenv of course allows for much more options, just run pyenv to see whole list of options.&lt;/p&gt;

&lt;p&gt;(This is my first tutorial style post ever :D Improvement is very important for me, so feedback is welcome)&lt;/p&gt;

</description>
      <category>python</category>
      <category>devops</category>
      <category>sre</category>
      <category>tutorials</category>
    </item>
    <item>
      <title>Starting the editor war</title>
      <dc:creator>Sebastian Zawadzki</dc:creator>
      <pubDate>Sat, 28 May 2022 11:22:24 +0000</pubDate>
      <link>https://community.ops.io/schrenker/starting-the-editor-war-1imo</link>
      <guid>https://community.ops.io/schrenker/starting-the-editor-war-1imo</guid>
      <description>&lt;p&gt;Hi, glad to be part of this community. And of course, it wouldn't be complete without starting decades old war anew, so. What is your:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Favorite Editor&lt;/li&gt;
&lt;li&gt;Color Scheme&lt;/li&gt;
&lt;li&gt;What made you choose this one&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I will start, normally on servers I use vi. On my personal computer I use doom emacs with evil mode. Color theme is solarized light/dark with switching depending of time of the day. I love modal editing options that vi provides, but also I love extensibility of emacs. Also magit and org mode.&lt;/p&gt;

&lt;p&gt;Sorry for bringing this up, but this community cannot go further without this topic :D&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>watercooler</category>
    </item>
  </channel>
</rss>
