question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.pyc files are included in wheels

See original GitHub issue

@lamby filed https://bugs.debian.org/1005825 in Debian:

Whilst working on the Reproducible Builds effort we noticed that hatchling could not be built reproducibly. This is because it included the checksums of (unshipped) .pyc files in the RECORD file. A patch is attached that strips them out; this change is analogous to a similar conditional later in the wheel.py file.

He supplied a patch to strip .pyc files from RECORD.

But I’d suggest that we go a step further and exclude the .pyc files from the generated wheels, entirely. While Debian didn’t ship the .pyc files, due to packaging tooling, they are in generated wheels.

This would be what most other packaging tools do, and in line with PEP 427, which states:

  1. Wheel, being an installation format that is intended to work across multiple versions of Python, does not generally include .pyc files.

I would have filed a PR to do this, but I’m not entirely sure what your preferred mechanism to implement the exclusion would be. It could be defaulting to exclude __pycache__ directories, or .pyc files, using the existing exclusion mechanisms, or a hardcoded exclusion for .pyc files in recurse_project_files().

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
lambycommented, Feb 15, 2022

(Yep, not wedded to the idea of only stripping the .pyc references from RECORD; I was merely following the principle of providing the minimal possible patch.)

0reactions
stefanorcommented, Feb 16, 2022

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

include only *.pyc files in python wheel - Stack Overflow
How can I include only *.pyc files in a python wheel? When creating eggs, it used to be possible to run python setup.py...
Read more >
pyc-wheel - PyPI
Compile all py files in a wheel to pyc files. Overview. pyc_wheel is a strict fork of Grant Patten's pycwheel package with a...
Read more >
Wheel vs Egg - Python Packaging User Guide
Wheel and Egg are both packaging formats that aim to support the use case of needing an install artifact that ... Wheel archives...
Read more >
What Are Python Wheels and Why Should You Care?
Python .whl files, or wheels, are a little-discussed part of Python, but they've been a boon to the installation process for Python packages....
Read more >
karpierz/pyc_wheel: Compile all py files in a wheel to pyc files.
pyc_wheel is a strict fork of Grant Patten's pycwheel package with a fixes allowing to work with Python3 or higher and with a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found