12/15/2021»»Wednesday

Awesome Python

12/15/2021
    29 - Comments
Latest version

Released:

Python Tricks: A Buffet of Awesome Python Features - Kindle edition by Bader, Dan. Download it once and read it on your Kindle device, PC, phones or tablets. Use features like bookmarks, note taking and highlighting while reading Python Tricks: A Buffet of Awesome Python Features. Build a Virtual Assistant. In this project, you will build your own virtual assistant using the Python.

The Font Awesome icon set for python

Project description

Usage 

License

The code in this repository is licensed under Apache2.0

The character codes included with this package are part of the FontAwesome project.

Release historyRelease notifications RSS feed

5.10.1.post1

5.7.2.post1

5.3.1.post1

Awesome Python

4.7.0.post5

4.7.0.post4

4.7.0.post3

4.6.3.post2

4.6.3.post1

4.6.3

Download files

Libraries

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for fontawesome, version 5.10.1.post1
Filename, sizeFile typePython versionUpload dateHashes
Filename, size fontawesome-5.10.1.post1-py3-none-any.whl (20.2 kB) File type Wheel Python version py3 Upload dateHashes
Filename, size fontawesome-5.10.1.post1.tar.gz (20.4 kB) File type Source Python version None Upload dateHashes
Close

Hashes for fontawesome-5.10.1.post1-py3-none-any.whl

Hashes for fontawesome-5.10.1.post1-py3-none-any.whl
AlgorithmHash digest
SHA256642d74da5f4726bb2c8f035a2f4a98fdc4294d213a291994ee0b3d845166f9e8
MD5c77ca2df76dd8e4be5e410734c57eda5
BLAKE2-256b9fa84705d3713db9a528ab489cc8e213cafb6425407a437a1a7a6148d6bf98f
Close

Hashes for fontawesome-5.10.1.post1.tar.gz

Hashes for fontawesome-5.10.1.post1.tar.gz
AlgorithmHash digest
SHA2561b5e8f2ed12a74b88aef6f404ff770af425324041bc5620523a802d5406595b8
MD513d48226fb352f6d9affc2c497821a80
BLAKE2-256d45c7bd784c3f6dc8dc148a6a6ad3e7d4bf0e3c5a53f9565cc0385d7f3dcee29

If you are like me, every once in a while you write a useful python utility and want to share it with your colleagues. The best way to do this is to make a package: it easy to install and saves from copy-pasting.

If you are like me, you might be thinking that creating packages is a real headache. Well, that’s not the case anymore. And I am going to prove it with this step-by-step guide. Just three main steps (and a bunch of optional ones) accompanied by few GitHub links. See for yourself:

1. Stub

We will create podsearch - a utility that searches for podcasts in iTunes. Let’s create a directory and a virtual environment:

Define a minimal package structure:

2. Test package

Creating a package in Python used to be a troublesome task. Fortunately, nowadays there is a great little flit utility which simplifies everything. Let’s install it:

And create package description:

Flit has created pyproject.toml - the project metadata file. It already has everything you need to publish the package to the public repository - PyPI.

Sign up for TestPyPi (test repository) and PyPI (the main one). They are completely independent, so you will need two accounts.

Setup access to repositories in the ~/.pypirc:

And publish the package to the test repository:

Done! The package is available on TestPyPi.

3. Public package

Let’s improve the code so that it actually searches for podcasts:

And publish to the main repository - PyPI. Perform this step only after your package has working code that does something useful. Do not publish non-working packages and stubs.

Done! Time to share it with colleagues.

To make the package a pleasure to use, I recommend that you follow a few more steps.

A. Readme and changelog

No one likes to write documentation. But without docs, it is unlikely that people will want to install your package, so let’s add README.md and CHANGELOG.md.

Add readme to the pyproject.toml, so that PyPI shows it on the package page:

Also specify the minimal supported Python version:

Update the version in __init__.py and publish the package via flit publish:

Mmm, nice.

B. Linters and tests

Let’s take care of formatting (black), test coverage (coverage), code quality (flake8, pylint, mccabe), and static analysis (mypy). We will run everything through tox.

Create tox configuration in tox.ini:

And run all the checks:

Lovely! The linters are happy, the tests passed, the coverage is 100%.

C. Cloud build

Every solid open-source project runs cloud tests after each commit, so we will too. A nice side effect is having beautiful badges in the readme ツ

Let’s build the project with GitHub Actions, check test coverage with Codecov and code quality with Code Climate.

You will have to sign up for Codecov and Code Climate (both support GitHub login) and enable package repository in the settings.

After that, add the GitHub Actions build config to .github/workflows/build.yml:

GitHub runs tests via tox - just as we did. tox-gh-actions package and USING_COVERAGE settings ensure that tox uses the same Python version as GitHub Actions themself, as required by strategy.matrix (I learned this clever trick from Hynek Schlawak).

AppsAwesome

The last step sends test coverage to Codecov. Code Climate does not need a separate step - it spots repository changes automatically.

Now commit, push, and enjoy the result in a minute. And let everyone enjoy as well - add badges to README.md:

Aren’t they cute?

D. Task automation

Flask

tox is fine, but not very handy for development. It’s faster to run individual commands like pylint, coverage etc. But they are quite verbose, so we’ll automate the boring stuff.

Let’s create short aliases for frequent actions with Makefile:

Here are our tasks:

To make the code more DRY, replace raw build.yml steps with make calls:

E. Cloud publish

GitHub is quite capable of running flit publish for us. Let’s create a separate workflow:

PYPI_USERNAME and PYPI_PASSWORD are set in repository settings (Settings > Secrets > New repository secret). Use your PyPi username and password, or even better - an API token.

Now GitHub will automatically publish the package as soon as you create a new release. Sweet!

⌘ ⌘ ⌘

Your perfect package is ready! It has everything one could dream of: clean code, clear documentation, tests, and cloud builds. Time to tell your colleagues and friends.

Awesome Python List

These settings will make your package awesome:

Awesome Python Codes

Thanks for reading! Follow @ohmypy on Twitter to keep up with new posts 🚀

Recent Pages