pipbuildpython-3.6python-wheel

How to use pyproject.toml with python-3.6?


I created my simple Python-module. The pyproject.toml reads:

[project]
authors = [
        {name = "Me Me", email = "Me@example.com"}
]
name = "Mysms"
description = "Fetch specified secrets-file(s) from My's SMS-portal"
version = "0.1"
requires-python = ">= 3.6"
dependencies = [
        "requests",
        "requests_kerberos",
        "pyspnego"
]
readme = "README.md"
keywords = ["SMS", "secrets"]
classifiers = [
        "Development Status :: 4 - Beta",
        "Topic :: Software Development :: Secrets"
]

[project.scripts]
Mysms = "Mysms:main"

[project.optional-dependencies]
decodejwt = ["pyjwt"]

[tool.setuptools]
py-modules = ["Mysms"]

There is a single Python-file. On my FreeBSD desktop, using python-3.11 (and build-module version 1.2.1), I build the wheel with python3.11 -m build --wheel ., which creates dist/Mysms-0.1-py3-none-any.whl -- so far so good.

However, when I try to do the same on our RHEL7 servers -- where Python-3 is 3.6, and build-module is 0.9.0 -- I get dist/UNKNOWN-0.0.0-py3-none-any.whl, with no actual code inside, and only the meta-data files:

-rw-r--r--  2.0 unx      132 b- defN 25-Jun-25 18:51 UNKNOWN-0.0.0.dist-info/METADATA
-rw-r--r--  2.0 unx       92 b- defN 25-Jun-25 18:51 UNKNOWN-0.0.0.dist-info/WHEEL
-rw-r--r--  2.0 unx        1 b- defN 25-Jun-25 18:51 UNKNOWN-0.0.0.dist-info/top_level.txt
?rw-rw-r--  2.0 unx      296 b- defN 25-Jun-25 18:51 UNKNOWN-0.0.0.dist-info/RECORD
4 files, 521 bytes uncompressed, 379 bytes compressed:  27.3%

It seems like the older build-module is simply ignoring my pyproject.toml -- picking neither the name, nor the version from it. Nor the actual Python-code.

How do I make my module buildable by any Python-3.6+?


Solution

  • Creating an answer from comments above.

    The lowest Python version with which I managed to use pyproject.toml is 3.7. With Python 3.6 and build 0.9 the problem was exactly as yours, and I didn't find any fix. For Python 3.6 use setup.cfg or setup.py.

    For a package that consists of a single file Mysms.py use setup(py_modules=['Mysms']) in setup.py. Or in setup.cfg:

    [options]
    py_modules = Mysms
    

    Requires setuptools 34.4.0+. See the docs.