<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Python on sysarcher/@ich_code</title><link>https://sysarcher.github.io/categories/python/</link><description>Recent content in Python on sysarcher/@ich_code</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 17 Mar 2020 21:22:37 +0200</lastBuildDate><atom:link href="https://sysarcher.github.io/categories/python/index.xml" rel="self" type="application/rss+xml"/><item><title>On WebAssembly</title><link>https://sysarcher.github.io/posts/web-assembly/</link><pubDate>Tue, 17 Mar 2020 21:22:37 +0200</pubDate><guid>https://sysarcher.github.io/posts/web-assembly/</guid><description>&lt;p&gt;This blog is not going to define what WebAssembly is, how it interacts with JS or other languages; there are too many blogs and posts available on the internet already.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re not familiar with WebAssembly, I would suggest you start here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://hacks.mozilla.org/2017/02/a-cartoon-intro-to-webassembly/"&gt;A cartoon intro to WebAssembly&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts"&gt;WebAssembly Concepts&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This blog post is about wondering what WebAssembly can look like for some usecases.&lt;/p&gt;
&lt;h2 id="run-everywhere"&gt;Run Everywhere&lt;/h2&gt;
&lt;p&gt;WebAssembly can run everywhere - atleast that&amp;rsquo;s the goal. It&amp;rsquo;s performant - as performant as C/C++ and it&amp;rsquo;s secure.&lt;/p&gt;</description><content:encoded><![CDATA[<p>This blog is not going to define what WebAssembly is, how it interacts with JS or other languages; there are too many blogs and posts available on the internet already.</p>
<p>If you&rsquo;re not familiar with WebAssembly, I would suggest you start here:</p>
<ul>
<li><a href="https://hacks.mozilla.org/2017/02/a-cartoon-intro-to-webassembly/">A cartoon intro to WebAssembly</a></li>
<li><a href="https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts">WebAssembly Concepts</a></li>
</ul>
<p>This blog post is about wondering what WebAssembly can look like for some usecases.</p>
<h2 id="run-everywhere">Run Everywhere</h2>
<p>WebAssembly can run everywhere - atleast that&rsquo;s the goal. It&rsquo;s performant - as performant as C/C++ and it&rsquo;s secure.</p>
<blockquote>
<p>WebAssembly is a type of code that can be run in modern web browsers and provides new features and major gains in performance.</p>
</blockquote>
<p><em><a href="https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts">https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts</a></em></p>
<h3 id="open-questions">Open Questions</h3>
<p>Although designed for the web, WebAssembly is able to run portably across architectures. This can be a nice way to distribute applications. Some day perhaps WebAssembly runtimes will be a part of <em>all</em> OSes.</p>
<p>What needs to be determined IMO is:</p>
<ul>
<li>
<p>Realtime capabilities</p>
<p>Can WebAssembly modules written in C/C++ provide any RT capabilities? If so, then it&rsquo;ll be interesting to evaluate whether a WebAssembly runtime is all that a PLC should be. Apps running the PLC would be delivered like software. Less stickiness for everybody.</p>
</li>
<li>
<p>Recompile all the things</p>
<p>Can WebAssembly runtimes replace native programs? How about message queues, brokers implemented in WebAssembly? I know it&rsquo;s not possible to compile all complicated software to WebAssembly today - but is that the future too?</p>
</li>
<li>
<p>UI</p>
<p>Will Slack and it&rsquo;s likes re-implement significant portions of their code to WebAssembly? Should work, right?</p>
</li>
<li>
<p>Edge</p>
<p>Fastly has already done lots of work with their CDN running WebAssembly-isolated workloads. Can we bring this down to the Edge where we&rsquo;re running containers today?</p>
</li>
</ul>
<h2 id="conclusion">Conclusion</h2>
<p>There&rsquo;re so many things I&rsquo;m looking an answer for. This year is going to be awesome!</p>
]]></content:encoded></item><item><title>My Python Environment</title><link>https://sysarcher.github.io/posts/python-env/</link><pubDate>Wed, 12 Feb 2020 21:22:37 +0200</pubDate><guid>https://sysarcher.github.io/posts/python-env/</guid><description>&lt;p&gt;The most common way people go about setting up a Python environment is to do something like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ sudo apt install python3 python3-pip &lt;span style="color:#75715e"&gt;# installs pip3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ sudo pip3 install --upgrade pip &lt;span style="color:#75715e"&gt;# upgrade pip to latest version&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Congrats, now you&amp;rsquo;re stuck with whatever version ships with the distro. I think we can do better!&lt;/p&gt;
&lt;h1 id="pyenv"&gt;&lt;code&gt;pyenv&lt;/code&gt;&lt;/h1&gt;
&lt;p&gt;My recommendation now, is to use &lt;code&gt;pyenv&lt;/code&gt; with which you can manage multiple versions, virtualenvs through a nice CLI&lt;/p&gt;</description><content:encoded><![CDATA[<p>The most common way people go about setting up a Python environment is to do something like this:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ sudo apt install python3 python3-pip    <span style="color:#75715e"># installs pip3</span>
</span></span><span style="display:flex;"><span>$ sudo pip3 install --upgrade pip         <span style="color:#75715e"># upgrade pip to latest version</span>
</span></span></code></pre></div><p>Congrats, now you&rsquo;re stuck with whatever version ships with the distro. I think we can do better!</p>
<h1 id="pyenv"><code>pyenv</code></h1>
<p>My recommendation now, is to use <code>pyenv</code> with which you can manage multiple versions, virtualenvs through a nice CLI</p>
<h3 id="uninstall-pippip3">Uninstall <code>pip</code>/<code>pip3</code></h3>
<p>Before proceeding, I&rsquo;d suggest uninstalling <code>pip</code> using <code>pip uninstall pip</code> and <code>sudo apt remove python3-pip</code></p>
<h2 id="installation">Installation</h2>
<p><a href="https://github.com/pyenv/pyenv-installer">Using the <code>pyenv</code> installer project</a></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ sudo apt install libssl-dev <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>                   libsqlite-dev \
</span></span><span style="display:flex;"><span>                   libreadline-dev \
</span></span><span style="display:flex;"><span>                   libbz2-dev  \
</span></span><span style="display:flex;"><span>                   libsqlite3-dev  # I&#39;ve observed failures without these libs
</span></span><span style="display:flex;"><span>$ curl https://pyenv.run | bash
</span></span><span style="display:flex;"><span>...
</span></span><span style="display:flex;"><span>WARNING: seems you still have not added &#39;pyenv&#39; to the load path.
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span># Load pyenv automatically by adding
</span></span><span style="display:flex;"><span># the following to ~/.bashrc:
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>export PATH=&#34;/home/taimoor/.pyenv/bin:$PATH&#34;
</span></span><span style="display:flex;"><span>eval &#34;$(pyenv init -)&#34;
</span></span><span style="display:flex;"><span>eval &#34;$(pyenv virtualenv-init -)&#34;
</span></span></code></pre></div><p>This should set up <code>pyenv</code> for you. Read the instructions printed at the end and follow them! Add the three things to your <code>~/.bashrc</code> or <code>~/.zshrc</code> or whatever.</p>
<h2 id="usage-summarized">Usage (summarized)</h2>
<p>Example: Install Python 3.8.1:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ pyenv install 3.8.1
</span></span></code></pre></div><p>P.S: logout and log back in</p>
<p>P.S2: Tab completion works!</p>
<h3 id="virtualenv">Virtualenv</h3>
<p>Create a virtualenv</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ pyenv virtualenv 3.8.1 venv3.8    <span style="color:#75715e"># create a virtualenv called venv3.8 based on python 3.8.1</span>
</span></span><span style="display:flex;"><span>$ pyenv activate venv3.8    <span style="color:#75715e"># activate venv3.8</span>
</span></span><span style="display:flex;"><span>$ python --version
</span></span><span style="display:flex;"><span>Python 3.8.1
</span></span><span style="display:flex;"><span>$ which python
</span></span><span style="display:flex;"><span>/home/taimoor/.pyenv/shims/python
</span></span></code></pre></div><p>That&rsquo;s it! Now you can manage your anaconda and python environments, versions sooo much better.</p>
]]></content:encoded></item></channel></rss>