Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary distributions such as wheels include Cython and C sources #250

Closed
musicinmybrain opened this issue Dec 7, 2021 · 3 comments
Closed

Comments

@musicinmybrain
Copy link
Contributor

musicinmybrain commented Dec 7, 2021

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.

@asvetlov
Copy link
Member

asvetlov commented Dec 7, 2021

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.

@musicinmybrain
Copy link
Contributor Author

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.

@asvetlov
Copy link
Member

asvetlov commented Dec 7, 2021

Cool!
Would you craft a pull request?

musicinmybrain added a commit to musicinmybrain/frozenlist that referenced this issue Dec 7, 2021
This does not affect source distributions, and Cython sources (.pyx) are
still installed.

Fixes aio-libs#250.
musicinmybrain added a commit to musicinmybrain/frozenlist that referenced this issue Dec 7, 2021
This does not affect source distributions, and Cython sources (.pyx) are
still installed.

Fixes aio-libs#250.
clrpackages referenced this issue in clearlinux-pkgs/pypi-frozenlist Jan 20, 2022
…ersion 1.3.0

1.3.0 (2022-01-18)
==================

Bugfixes
--------

- Do not install C sources with binary distributions.
  `#250 <https://github.com/aio-libs/frozenlist/issues/250>`_

Deprecations and Removals
-------------------------

- Dropped Python 3.6 support
  `#274 <https://github.com/aio-libs/frozenlist/issues/274>`_

(NEWS truncated at 15 lines)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants