Library Usage

This page is for developers who want to use Fontknife from the Python code of a project.

Overview: Pin Your Packages!

TL;DR: Keep your code working by telling ``pip`` to use specific package versions.

What’s Pinning?

By default, pip install will install the latest version of a package released. This can break your code if the latest release of a package changes features your code relies on.

You can pin your project’s package versions so pip only uses the exact version you tell it. This is called pinning a package.

Why Pin Packages?

Before version 1.0, projects often change unexpectedly. Fontknife is no exception! Once it reaches 1.0, it will follow semantic versioning. Until then:

  • Large changes may release without warning

  • When that happens, projects without pinned package versions may break!

How do I Pin?

If you’re using a tool like Rye or Poetry, consult their documentation. Otherwise, the following steps may help:

1. Find where you specify dependencies

The simplest and oldest way is a requirements.txt file with one package per line.

However, many projects now use a pyproject.toml file instead. If you aren’t using a tool which generates it for you, then you can edit it directly:

  1. Open pyproject.toml

  2. Search for a [project]] heading

  3. Look for a dependencies variable under it which looks like this

    [project]
    dependencies = [
      'example_package_name == 1.0',
      'another_example_name == 1.1'
    ]
    

2. Choose Your Version

Safe & Stable

The current latest version is specified by this string:

'fontknife == 0.2.0'

You can choose from other versions on PyPI by checking the Release history tab.

Advanced: Straight from GitHub

Warning

These versions will be buggy!

Even if builds pass tests, this is a pre-release WIP unless it’s a release commit. Things will break!

Very adventurous users can install directly from the latest commit at the time of build by using the following:

3. Add it to your dependencies

Where your dependencies are kept

Where to put it

Example

requirements.txt

At the end of requirements.txt

'fontknife == 0.2.0'

pyproject.toml

Under [project] section in the dependencies list

[project]
dependencies =[
    'example_package_name == 1.0',
    'another_example_name == 1.1'
    'fontknife == 0.2.0'
]

Now pip install -Ie . or use your preferred project management tool to install dependencies!