See Ash Code logo See Ash Code

Declaring Python 3.13 support

Ashlynn Antrobus
• • 5 min read

My latest commit to ebook2text has an ambitious title: “Add Python 3.13”.

Here is the change:

     "Programming Language :: Python :: 3.12",
+    "Programming Language :: Python :: 3.13",

That’s it. A single line. If only all compatibility work were that easy.

The ebook2text library converts EPUB, DOCX, PDF, and text files into a semi-structured text for use in AI training/finetuning and other deep learning scenarios. There are a few options to choose when using it, a handful of dependencies, and plenty of places where something could go wrong. None of that changed here.

So what did I actually add support for?

What a classifier tells you

The line I added is a classifier. Classifiers are used to describe a package. Things like what language it uses, what license it uses, who it is intended for, what sort of work it does, and which Python versions its author says it supports.

It is useful information. If I’m considering somebody else’s library, I want to know whether they intend to support the Python version I’m using. That information helps me decide whether the package is worth checking out.

But the classifier doesn’t run my code. It doesn’t check my imports, convert a book, or ask each dependency whether it works on Python 3.13. I can add that string to the file without doing any of those things.

A magnifying glass enlarges a checked box on a checklist.

Illustration by Ryan Kissinger, courtesy of NIAID BioArt; public domain in the United States.

The Python Packaging User Guide explains that Python-version classifiers are used for searching and browsing on PyPI. Actual installation restrictions are handled by a separate field.

Which I already had.

The other Python version declaration

Also in my pyproject.toml:

requires-python = ">= 3.8"

This declares a Python version requirement for the package. In this case, it is saying that only versions of 3.8 or higher will be allowed to install this package. You can also add a maximum, or ceiling requirement if you know that your package definitely will not run on later versions of Python. It becomes the Requires-Python field in the distribution’s metadata, as specified by PEP 621. Installers can use that requirement when selecting a compatible release. The meaning of the field is defined in the core metadata specification.

Python 3.13 already satisfies >= 3.8. Adding its classifier didn’t expand that range. Removing the classifier wouldn’t exclude it from the range either.

If I changed the requirement to >= 3.13, I would be raising the minimum version and blocking older Python versions. That would be a very different change from adding support for another version alongside them.

The requirement also doesn’t establish that the code works. It records what the package declares compatible. I still have to make sure that declaration matches the code, and a complete installation also has to satisfy the dependencies’ requirements.

For ebook2text, this means packages such as Pillow, pdfminer.six, python-docx, and the OpenAI library. The code I’ve written can remain untouched but a dependency update changes which environments can install or run it. A compatibility claim has to account for the package someone actually installs, with its dependencies.

So the classifier, the version requirement, and a working conversion each tell me something different. I need to check all three.

What my workflow actually does

I do have a GitHub Actions workflow for publishing the package. But having a workflow is only useful evidence if I look at what it runs.

The current publishing workflow selects this interpreter:

- name: Set up Python
  uses: actions/setup-python@v3
  with:
    python-version: '3.8'

It then installs the build tool, builds my package, and uploads it when a release is published. The build step is:

- name: Build package
  run: python -m build

There’s no test command and no matrix for running the job on other versions of Python in my classifiers between building and publishing.

Oops.

A successful run of that job confirms that the package built with Python 3.8. But it doesn’t show that a user could install my package on Python 3.13 and convert a PDF. The workflow didn’t ask Python 3.13 to do anything.

Even building a distribution doesn’t prove the conversion paths work. Just because the files are packaged doesn’t mean that chapters are split correctly or text from two pages will merge right.

The publishing workflow needs a test job

What I need is a way to reliably confirm that my package is compatible with the versions I’m claiming I support. The version-selection part of my test job could start with:

strategy:
  matrix:
    python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

That’s a proposed matrix, not something I’ve added to the workflow yet. The setup step would need to use matrix.python-version, and each job would still need to have installation and test steps. Just listing the versions in another YAML block won’t get me very far by itself.

I’ll need those checks to include installing the built package in a clean environment, with its runtime dependencies. This would help catch problems that could be hidden when testing code directly from the repository, such as a file I forgot to include in the package.

Then I need to test the library. I can create some small EPUB, DOCX, PDF, and text fixtures to test output against something I already know. An import check is useful, but it won’t tell me whether the converter lost a paragraph or put a chapter break in the wrong place.

The scope of the tests needs to be clear. Testing one PDF tests one PDF. More varied fixtures would give me better coverage of the different conversion paths. An external OCR request would bring its own service and credential requirements, so that’s a separate issue from a local text-conversion check.

Once this is automated, I know my metadata has something backing it. Future changes to the code or dependencies will be tested in the same environments. I won’t have to rely on remembering which versions I last tested.

For now, I added Python 3.13 to the classifiers, and the publishing workflow is still building on Python 3.8. The next change will be adding those tests into that workflow.

AA

Written by Ashlynn Antrobus

Software developer, author, and builder. Sharing technical lessons learned from building tools like Ebook2Text, IndexedDict, and rag-mcp, and navigating life as a programmer with dyslexia.