Skip to content

Binary distributions such as wheels include C sources #659

Closed
@musicinmybrain

Description

@musicinmybrain

Long story short

Binary distributions such as wheels include C sources (_multidict.c and _multilib/*.h) that aren’t obviously useful in this type of distribution.

See also aio-libs/frozenlist#250.

Expected behaviour

These should ideally be present in the sdist but not in the bdist.

Their total size is only about 100kB, but that’s 100kB that could easily be saved. In frozenlist, yarl, and aiohttp, the C sources are much larger since they are Cython-generated.

Actual behaviour

These files are included in both binary and source distributions.

Steps to reproduce

$ python3 -m venv _e
$ . _e/bin/activate
(_e) $ pip install multidict
(_e) $ ls -l _e/lib64/python*/site-packages/multidict/total 436
-rw-rw-r--. 1 ben ben   1190 Dec  7 23:42 _abc.py
-rw-rw-r--. 1 ben ben    363 Dec  7 23:42 _compat.py
-rw-rw-r--. 1 ben ben    942 Dec  7 23:42 __init__.py
-rw-rw-r--. 1 ben ben   4931 Dec  7 23:42 __init__.pyi
-rw-rw-r--. 1 ben ben   3791 Dec  7 23:42 _multidict_base.py
-rw-rw-r--. 1 ben ben  40881 Dec  7 23:42 _multidict.c
-rwxrwxr-x. 1 ben ben 358592 Dec  7 23:42 _multidict.cpython-310-aarch64-linux-gnu.so
-rw-rw-r--. 1 ben ben  14731 Dec  7 23:42 _multidict_py.py
drwxrwxr-x. 1 ben ben     84 Dec  7 23:42 _multilib
drwxrwxr-x. 1 ben ben    254 Dec  7 23:42 __pycache__
-rw-rw-r--. 1 ben ben     15 Dec  7 23:42 py.typed

Your environment

This is totally independent of platform.

Suggested fix

Add to setup(…) in setup.py:

    exclude_package_data={"": ["*.c", "*.h"]},

which will exclude these sources from binary distributions without affecting source distributions.

PR to follow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions