Posted in 2022

Install dependencies from GitHub with pyproject.toml or requirements.txt

This is a short post to demonstrate how to install packages directly from GitHub with pyprojects.toml or requirements.txt, including custom branches and commits. It will focus on pyprojects.toml because this is newer and there’s less information about it, but the general pattern holds for requirements.txt as well.

In pyproject.toml, you can specify dependencies for a project via the dependencies field. For example, to specify Sphinx as a dependency:

Read more ...


Report from the JupyterLite workshop: WebAssembly is pretty cool

I recently attended the JupyterLite community workshop in Paris, here are some quick thoughts from the three-day event[1].

For those without any background, JupyterLite is a distribution of Jupyter’s user interfaces and a Python kernel that runs entirely in the browser. Its goal is to provide a low-overhead and accessible way to use a Jupyter interface via the browser. See the jupyterlite documentation for more information.

Read more ...


Load and plot a remote font with Matplotlib

As part of my sphinx-social-previews prototype, I wanted to be able to use the Roboto Font from Google in image previews. However, Roboto is often not loaded on your local filesystem, so it took some digging to figure out how to make it possible to load via Matplotlib’s text plotting functionality.

Here’s the solution that finally worked for me, inspired from this Tweet with a similar implementation from the dmol book.

../../_images/868fcd11b95a614186ca3a676d028d4548af86c0749233733e16ac5cf97f2fed.png

Read more ...


How to update Sphinx options during the build

As part of the pydata-sphinx-theme we have a few settings that auto-enable extensions and configure them on behalf of the user. It has always been mysterious to me how to do this properly during the Sphinx build. It’s easy to configure things with conf.py ahead of time, but what if you want to manually set a value during the build?

I finally figured it out, so documenting the process here.

Read more ...


Automatically update pre-commit hook versions

I figured out a way to automatically update all of the git pre-commit hook versions at once!

pre-commit is a useful command line tool for running simple commands before every git commit. I use it to enforce things like flake8 and black in many of my projects.

Read more ...


subprocess.run can execute shell commands directly

I often run shell commands in Python via the subprocess.run command. One thing that has always bugged me is that this required you to split commands into a list before it’d work properly. For example, you’d have to do:

Today I discovered that you don’t have to do this! There’s a shell= keyword that can be used to tell subprocess to simply run the command directly in the shell.

Read more ...


Fix phantom GitHub workflows in your ci-cd with protected branch rules

Have you ever had a GitHub pull request show “phantom” workflows that never pass? This looks like one or more workflows that are in a constant waiting state, with a yellow status indicator, and that never complete.

It looks something like this:

https://user-images.githubusercontent.com/1839645/204134864-da2541f0-ff4f-4d9f-8c80-aa8c4437d8a0.png

Read more ...


Custom roles and domains in Sphinx with one line

I was working on the roles and structure section of the 2i2c Team Compass and found a nifty feature in Sphinx that I hadn’t known before.

You can currently add labels to any section with the following MyST Markdown structure:

Read more ...


Automatically updating my publications page with ORCID and doi.org

For a while I’ve had a hand-crafted .bibtex file stored locally for my publications/ page. However, manually updating local text file is a pain to remember, especially since there are many services out there that automatically track new publications.

A helpful suggestion on Twitter allowed me to include the full citation information, including lists of authors, using the doi.org API!

Read more ...


Automatically redirect folders in Sphinx websites

  • 19 November 2022
  • til

I spent a bit of time today updating my website after some changes in the MyST-NB and Sphinx Design ecosystems. Along the way, I decided to redirect /posts/ to /blog/, since it seems /blog/ is a much more common folder to use for blog posts.

This posed a problem, because the sphinx-rediraffe extension does not allow you to redirect folders with wildcards. AKA, you cannot do:

Read more ...


Ask Twitter: Why don’t academic researchers use cloud services?

this is an experiment at making my Twitter conversations a bit more useful and archivable over time. It’s going to be a bit messy and unpolished, but hopefully that makes it more likely I’ll actually do it :-)

Over the past decade, cloud infrastructure has become increasingly popular in industry. An ecosystem of modular tools and cloud services (often called the Modern Data Stack) has filled many data needs for companies.

Read more ...