Invoke (Pyinvoke) is great

I recently started using Invoke to automate common tasks for my projects, such as building and deploying documentation pages. Naturally, I started using Invoke to maintain this blog, so here's a quick guide on how to use Invoke.

What's invoke?

Invoke is a Python library for managing shell-oriented tasks. It was inspired by Ruby's Rake, which is a tool designed to write Makefiles using Ruby. The main advantages Rake provided over simple Makefiles is that they are easier to write, and extremely versatile, as you have the whole Ruby programming language to describe tasks.

Invoke is similar to Rake, in that it attempts to provide an alternative to Makefiles for automating tasks. Similarly to Rake, Invoke provides full Python to describe and automate tasks.

How to use invoke

You first need to install invoke, you can install it globally using pip:

pip install invoke

However, and I have written before, I like to use poetry to manage virtual environments an dependencies, so I just add invoke as a "dev" dependency to my projects:

poetry add --group dev invoke

Now that you have invoke available, you need to create a tasks.py file on your project's root directory. The tasks.py …

more ...

Getting started with Ruff and Poetry

I manage most of my Python projects with Poetry, I really like how it handles dependencies, configures projects and manages virtual environments using simple commands.

Normally I include linting tools as part of my Poetry projects, specifically flake8 and pylint. They served me well, but recently I saw a lot of hype around ruff in online tech circles, so I decided to give it a try.

And I'm glad I did, ruff and poetry are a match made in heaven. I'm really enjoying working with ruff, and how I can have really good static code analysis, and really fast.

In this article, I give a quick guide on how to setup ruff the way I use it on my Python projects, and how to integrate the ruff-lsp to Neovim.

Add ruff to you poetry dependencies

Assuming you already have a poetry project in place, you can add ruff as a development dependency:

poetry add --group dev ruff

This will create the following entry in your pyproject.toml file:

[tool.poetry.group.dev.dependencies]
ruff = "^0.4.2"

Configure ruff

The ruff documentation is pretty good, and the tool is pretty versatible, so you can set ruff to however you like …

more ...

Building a blog with Pelican and Netlify

It's been more than a year since I last posted on this website. I've been busy and I didn't have something to write about, until now. As I wrote before, I've been running the classic Jekyll/GitHub Pages combo, but I wanted to try something different, something that gave me more control over my website, so I found Pelican.

Similar to Jekyll, Pelican is a static site generator: its output are plain HTML/CSS files that you can upload anywhere, you don't need a backend nor a database. This is great because finding cheap (free) hosting is easy, and Netlify's Started Plan is perfect for this type of websites.

Just like Jekyll, Pelican also supports a wide variety of plugins and themes. The main difference is that Pelican is written in Python, and being a huge Python fan myself, I decided to give it a go. This is the write-up of how I got it working.

1. Setup the project using Poetry

I really like Poetry for managing my dependencies and virtual environments.

You can create a new Poetry project by running:

poetry new new-blog

You can find more information on how to use Poetry by reading the docs.

Now …

more ...