aio-libs / frozenlist

`FrozenList` is a `list`-like structure that implements `collections.abc.MutableSequence` and can be made immutable.

Home Page:https://frozenlist.aio-libs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Binary distributions such as wheels include Cython and C sources

musicinmybrain opened this issue · comments

Long story short

Binary distributions such as wheels include Cython and C sources (_frozenlist.pyx and _frozenlist.c).

Expected behaviour

These should not be included in the binary distributions since they do not provide any value, and the C source is quite large.

Actual behaviour

Both _frozenlist.pyx and _frozenlist.c are included in binary distributions.

Steps to reproduce

$ python3 -m venv _e
$ . _e/bin/activate
(_e) $ pip install frozenlist
(_e) $ ls -l _e/lib64/python*/site-packages/frozenlist/
total 816
-rw-rw-r--. 1 ben ben 311481 Dec  6 18:56 _frozenlist.c
-rwxrwxr-x. 1 ben ben 499872 Dec  6 18:56 _frozenlist.cpython-310-aarch64-linux-gnu.so
-rw-rw-r--. 1 ben ben   2983 Dec  6 18:56 _frozenlist.pyx
-rw-rw-r--. 1 ben ben   2391 Dec  6 18:56 __init__.py
-rw-rw-r--. 1 ben ben   1486 Dec  6 18:56 __init__.pyi
drwxrwxr-x. 1 ben ben     48 Dec  6 18:56 __pycache__
-rw-rw-r--. 1 ben ben      6 Dec  6 18:56 py.typed

Your environment

This is totally independent of platform.

Suggested fix

Either add to setup(…) in setup.py:

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

or, since this is currently the only package data, set

    include_package_data=False,

Neither will affect the source distribution.

include_package_data=False is not an option, py.typed marker should be included.

Does exclude_package_data work for binary distribution only? Source tarball should include both Cython and generated C sources.
Also, pyx file should be present even in binary distribution. it makes debugging easier, traceback points on lines in pyx which can be very useful.

include_package_data=False is not an option, py.typed marker should be included.

You’re right. I missed that.

Does exclude_package_data work for binary distribution only? Source tarball should include both Cython and generated C sources. Also, pyx file should be present even in binary distribution. it makes debugging easier, traceback points on lines in pyx which can be very useful.

Then

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

should do the trick.

In my testing (with frozenlist/_frozenlist.c present), this resulted in the C source being present when I did python3 setup.py sdist but not when I did python3 setup.py bdist or python3 setup.py bdist_wheel, while _frozenlist.pyx remained present in all three cases.

Cool!
Would you craft a pull request?