August 2nd, 2017

Python Bytes: #37 Rule over the shells with Sultan

Programing, Python, by admin.

<p><strong>Brian #1:</strong> <a href=”https://devguide.python.org/”><strong>New URL for Python Developer’s Guide</strong></a></p> <ul>
<li>How to contribute to CPython</li>
</ul> <p>Some really useful links that I hadn’t noticed before. Also great ideas to include in a contributing guide for any large open source project:</p> <ul>
<li>Core developers and contributors alike will find the following guides useful:
<ul>
<li><a href=”https://opensource.guide/how-to-contribute/”>How to Contribute to Open Source</a> (from https://opensource.guide)</li>
<li><a href=”https://opensource.guide/building-community/”>Building Welcoming Communities</a> (from https://opensource.guide)</li>
</ul></li>
<li>Guide for contributing to Python:
<ul>
<li><a href=”https://devguide.python.org/setup/”>Getting Started</a></li>
<li><a href=”https://devguide.python.org/help/”>Where to Get Help</a></li>
<li><a href=”https://devguide.python.org/pullrequest/”>Lifecycle of a Pull Request</a></li>
<li><a href=”https://devguide.python.org/runtests/”>Running &amp; Writing Tests</a></li>
<li>Beginner tasks to become familiar with the development process</li>
<li><a href=”https://devguide.python.org/docquality/”>Helping with Documentation</a></li>
<li><a href=”https://devguide.python.org/coverage/”>Increase Test Coverage</a></li>
<li>Advanced tasks for once you are comfortable</li>
<li><a href=”https://devguide.python.org/silencewarnings/”>Silence Warnings From the Test Suite</a></li>
<li>Fixing issues found by the <a href=”https://devguide.python.org/buildbots/”>buildbots</a></li>
<li><a href=”https://devguide.python.org/fixingissues/”>Fixing “easy” Issues (and Beyond)</a></li>
<li><a href=”https://devguide.python.org/tracker/#tracker”>Using the Issue Tracker</a> and <a href=”https://devguide.python.org/tracker/#helptriage”>Helping Triage Issues</a></li>
<li><a href=”https://devguide.python.org/triaging/”>Triaging an Issue</a></li>
<li><a href=”https://devguide.python.org/experts/”>Experts Index</a></li>
<li><a href=”https://devguide.python.org/communication/”>Following Python’s Development</a></li>
<li><a href=”https://devguide.python.org/coredev/”>How to Become a Core Developer</a></li>
<li><a href=”https://devguide.python.org/committing/”>Committing and Pushing Changes</a></li>
<li><a href=”https://devguide.python.org/devcycle/”>Development Cycle</a></li>
<li><a href=”https://devguide.python.org/buildbots/”>Continuous Integration</a></li>
<li><a href=”https://devguide.python.org/gitbootcamp/”>Git Bootcamp and Cheat Sheet</a></li>
</ul></li>
</ul> <p><strong>Michael #2:</strong> <a href=”https://sultan.readthedocs.io/en/latest/”><strong>Sultan: Command and Rule Over Your Shell</strong></a></p> <ul>
<li>Python package for interfacing with command-line utilities, like yum, apt-get, or ls, in a Pythonic manner</li>
</ul> <p>Simple example</p> <pre><code>from sultan.api import Sultan
s = Sultan()
s.sudo(“yum install -y tree”).run()
</code></pre> <p>Better in a context manager:</p> <pre><code>from sultan.api import Sultan with Sultan.load(sudo=True) as s: s.yum(“install -y tree”).run()
</code></pre> <p>Even works remotely:</p> <pre><code>from sultan.api import Sultan with Sultan.load(sudo=True, hostname=”myserver.com”) as sultan: sultan.yum(“install -y tree”).run()
</code></pre> <p><strong>Brian #3:</strong> <a href=”https://github.com/dreadatour/Flake8Lint”><strong>Flake8Lint</strong></a></p> <ul>
<li>Sublime Text plugin for lint Python files.</li>
<li>Includes these linters and style checkers:
<ul>
<li><a href=”http://pypi.python.org/pypi/flake8″><strong>Flake8</strong></a> (used in “Python Flake8 Lint”) is a wrapper around these tools:</li>
<li><a href=”http://pypi.python.org/pypi/pep8″><strong>pep8</strong></a> is a tool to check your Python code against some of the style conventions in <a href=”http://www.python.org/dev/peps/pep-0008/”>PEP8</a>.</li>
<li><a href=”https://launchpad.net/pyflakes”><strong>PyFlakes</strong></a> checks only for logical errors in programs; it does not perform any check on style.</li>
<li><a href=”http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html”><strong>mccabe</strong></a> is a code complexity checker. It is quite useful to detect over-complex code. According to McCabe, anything that goes beyond 10 is too complex. See <a href=”https://en.wikipedia.org/wiki/Cyclomatic_complexity”>Cyclomatic_complexity</a>.</li>
<li>There are additional tools used to lint Python files:</li>
<li><a href=”https://github.com/PyCQA/pydocstyle”><strong>pydocstyle</strong></a> is a static analysis tool for checking compliance with Python <a href=”http://www.python.org/dev/peps/pep-0257/”>PEP257</a>.</li>
<li><a href=”https://github.com/flintwork/pep8-naming”><strong>pep8-naming</strong></a> is a naming convention checker for Python.</li>
<li><a href=”https://github.com/JBKahn/flake8-debugger”><strong>flake8-debugger</strong></a> is a flake8 debug statement checker.</li>
<li><a href=”https://github.com/public/flake8-import-order”><strong>flake8-import-order</strong></a> is a flake8 plugin that checks import order in the fashion of the Google Python Style Guide (turned off by default).</li>
</ul></li>
</ul> <p><strong>Michael #4:</strong> <a href=”https://github.com/warner/magic-wormhole”><strong>Magic Wormhole</strong></a></p> <ul>
<li>Get things from one computer to another, safely.</li>
<li>A library and a command-line tool named <code>wormhole</code>, which makes it possible to get arbitrary-sized files and directories (or short pieces of text) from one computer to another.</li>
<li>The two endpoints are identified by using identical “wormhole codes”</li>
<li>Video from PyCon 2016: <a href=”https://www.youtube.com/watch?v=oFrTqQw0_3c”>https://www.youtube.com/watch?v=oFrTqQw0_3c</a></li>
<li>The codes are short and human-pronounceable, using a phonetically-distinct wordlist.</li>
<li>As a library too: The wormhole module makes it possible for other applications to use these code-protected channels. </li>
</ul> <p><strong>Brian #5:</strong> <a href=”https://realpython.com/blog/python/python-virtual-environments-a-primer/”><strong>Python Virtual Environments Primer</strong></a></p> <ul>
<li>why do we need virtual environments</li>
<li>what are they</li>
<li>how to use them / how do they work</li>
<li>also
<ul>
<li>virtualenvwrapper</li>
<li>using different versions of python</li>
<li>pyvenv</li>
</ul></li>
</ul> <p><strong>Michael #6:</strong> <a href=”http://www.infoworld.com/article/3208391/python/how-rust-can-replace-c-with-pythons-help.html”><strong>How Rust can replace C, with Python’s help</strong></a></p> <ul>
<li>Why Rust? Rust has
<ul>
<li>a type system feature that helps eliminate memory leaks,</li>
<li>proper interfaces, called ‘traits’,</li>
<li>better type inference,</li>
<li>better support for concurrency,</li>
<li>(almost) first-class functions that can be passed as arguments.</li>
</ul></li>
<li>It isn’t difficult to expose Rust code to Python. A Rust library can expose a C ABI (application binary interface) to Python without too much work. </li>
<li>Some Rust crates (as Rust packages are called) already expose Python bindings to make them useful in Python.</li>
<li>A new spate of projects are making it easier to develop Rust libraries with convenient bindings to Python – and to deploy Python packages that have Rust binaries</li>
<li><a href=”https://github.com/dgrunwald/rust-cpython”><strong>Rust-CPython</strong></a><strong>:</strong> <ul>
<li><strong>What it is:</strong> A set of bindings in Rust for the CPython runtime. This allows a Rust program to connect to CPython, use its ABI, run Python programs through it, and work with representations of Python objects in Rust itself.</li>
<li><strong>Who it’s for:</strong> Rust programmers who want to hook into CPython and control it from the inside out.</li>
</ul></li>
<li><a href=”https://github.com/PyO3/PyO3″><strong>PyO3</strong></a>
<ul>
<li><strong>What it is:</strong> For Rust developers, the PyO3 project provides a basic way to write Rust software with bindings to Python in both directions. A Rust program can interface with Python objects and the Python interpreter, and can expose Rust methods to a Python program in the same way a C module does.</li>
<li><strong>Who it’s for:</strong> Those writing modules that work closely with the Python runtime, and need to interact directly with it.</li>
</ul></li>
<li><a href=”https://github.com/mitsuhiko/snaek/”><strong>Snaek</strong></a>
<ul>
<li><strong>What it is:</strong> Another project in the early stages, Snaek lets developers create Rust libraries that are loaded dynamically into Python as needed, but don’t rely on being linked statically against Python’s runtime.</li>
<li>Doesn’t use CTypes but CFFI</li>
<li><strong>Who it’s for:</strong> Those who want to expose methods written in Rust to a Python script, or for Rust developers who don’t want or need to become familiar with Python.</li>
</ul></li>
<li>And there is a cookiecutter project / template too
<ul>
<li><a href=”https://github.com/mckaymatt/cookiecutter-pypackage-rust-cross-platform-publish”>https://github.com/mckaymatt/cookiecutter-pypackage-rust-cross-platform-publish</a></li>
<li>“A very important goal of the project,” writes its maintainers, “is that it be able to produce a binary distribution (Wheel) which will not require the end user to actually compile the Rust code themselves.”</li>
</ul></li>
</ul>

Back Top

Leave a Reply