Closed ScottTodd closed 1 week ago
We also embed a version.py
file in the package using this code: https://github.com/iree-org/iree/blob/d4975713a0aa3ba872807fc16585fb4b5a04e41d/compiler/setup.py#L307-L318
Within the .whl file, that ends up looking like /iree/compiler/version.py
with contents:
# Auto-generated version info.
PACKAGE_SUFFIX = ""
VERSION = "3.0.0rc20241114"
REVISIONS = {"IREE": "eef2c3a1544a7e0d772dc9a480ecbcb00acd0604"}
That may or may not be related to what pip reports for the package version. I'll edit the archive to test.
Editing the version embedded in iree_base_compiler.egg_info/PKG-INFO
changes the version reported by pip freeze
.
I found the code in change_wheel_version
that edits .dist-info/METADATA
: https://github.com/hauntsaninja/change_wheel_version/blob/e28436ebdb6fe5a81cd29922f7276d00675d1bd3/change_wheel_version.py#L128-L144 . Could add similar code for .egg-info/PKG-INFO
, or see if we can remove that .egg-info
folder in the wheel. I see things online suggesting that egg files/directories may be deprecated? https://setuptools.pypa.io/en/latest/deprecated/python_eggs.html Is there some version upgrade or packaging change that we could make that would remove those files entirely?
This may be related to the setuptools
version, so I checked the logs:
https://github.com/iree-org/iree/actions/runs/11831213438/job/32966041058#step:12:272
Using pip 24.2 from /opt/_internal/cpython-3.9.20/lib/python3.9/site-packages/pip (python 3.9)
Collecting setuptools>=42
Obtaining dependency information for setuptools>=42 from https://files.pythonhosted.org/packages/fe/df/88ccbee85aefbca071db004fdc8f8d2507d55d5a9dc27ebb93c92edb1bd8/setuptools-75.5.0-py3-none-any.whl.metadata
Downloading setuptools-75.5.0-py3-none-any.whl.metadata (6.8 kB)
https://github.com/iree-org/iree/actions/runs/11831213438/job/32966041058#step:12:13465
Found compiler packages: ['iree.compiler', 'iree.compiler.api', 'iree.compiler.dialects', 'iree.compiler.tools', 'iree.compiler._mlir_libs', 'iree.compiler.extras', 'iree.compiler.dialects.gpu', 'iree.compiler.dialects.transform', 'iree.compiler.dialects.linalg', 'iree.compiler.dialects.gpu.passes', 'iree.compiler.dialects.transform.interpreter', 'iree.compiler.dialects.transform.extras', 'iree.compiler.dialects.linalg.opdsl', 'iree.compiler.dialects.linalg.passes', 'iree.compiler.dialects.linalg.opdsl.ops', 'iree.compiler.dialects.linalg.opdsl.lang', 'iree.compiler.tools.scripts', 'iree.compiler.tools.import_onnx', 'iree.compiler.tools.ir_tool', 'iree.compiler.tools.scripts.iree_compile', 'iree.compiler.tools.scripts.iree_opt', 'iree.compiler._mlir_libs.iree_platform_libs', 'iree.compiler._mlir_libs._mlir', 'iree.compiler._mlir_libs.iree_platform_libs.rocm', 'iree.compiler._mlir_libs._mlir.dialects', 'iree.compiler._mlir_libs._mlir.dialects.transform']
running egg_info
creating build/i/python_packages/iree_compiler/iree_base_compiler.egg-info
writing build/i/python_packages/iree_compiler/iree_base_compiler.egg-info/PKG-INFO
writing dependency_links to build/i/python_packages/iree_compiler/iree_base_compiler.egg-info/dependency_links.txt
writing entry points to build/i/python_packages/iree_compiler/iree_base_compiler.egg-info/entry_points.txt
writing requirements to build/i/python_packages/iree_compiler/iree_base_compiler.egg-info/requires.txt
writing top-level names to build/i/python_packages/iree_compiler/iree_base_compiler.egg-info/top_level.txt
writing manifest file 'build/i/python_packages/iree_compiler/iree_base_compiler.egg-info/SOURCES.txt'
reading manifest file 'build/i/python_packages/iree_compiler/iree_base_compiler.egg-info/SOURCES.txt'
writing manifest file 'build/i/python_packages/iree_compiler/iree_base_compiler.egg-info/SOURCES.txt'
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Running command Preparing metadata (pyproject.toml)
Running setup.py from source tree: SOURCE_DIR = /home/runner/work/iree/iree/c/compiler/.. BINARY_DIR = /home/runner/work/iree/iree/c/compiler/build/b
Generating version.py:
Inserting a pip install --upgrade pip
here does not help: https://github.com/iree-org/iree/blob/d4975713a0aa3ba872807fc16585fb4b5a04e41d/build_tools/python_deploy/build_linux_packages.sh#L191 I saw posts online suggesting updating both setuptools
and pip itself for issues relating to egg_info
, e.g. https://askubuntu.com/questions/975523/pip-install-gives-command-python-setup-py-egg-info-failed-with-error-code-1
I'm still trying to figure out why the iree_base_compiler.egg-info
folder exists at all, when iree_base_compiler-3.0.0.dist-info
already exists. Maybe we can just delete the .egg-info
from the .whl entirely...? It would be better to never produce it in the first place, or fix the metadata in there.
Still not sure why these files are being produced, but I'll try scripting a way to edit the version in .egg-info/PKG-INFO
file I guess 🤷
Found some clues on https://stackoverflow.com/questions/3779915/why-does-python-setup-py-sdist-create-unwanted-project-egg-info-in-project-r
This directory is created intentionally as part of the build process for a source distribution.
You may safely delete the directory after your build has completed.
An alternative solution to jathanism's method could be the usage of the egg_info hook. I use it to clean up before each build:
Another clue: the CMake build that setup.py
kicks off creates a few iree_base_compiler.egg-info
folders, which then appear to get copied in to the .whl file:
Our other packages don't use CMake "install" from what I can tell, they just "build"?
Well that was a "fun" three hours of learning more about Python packaging. Fix PR is landing: https://github.com/iree-org/iree/pull/19156.
What happened?
The https://github.com/iree-org/iree/blob/main/build_tools/python_deploy/promote_whl_from_rc_to_final.py script used by https://github.com/iree-org/iree/blob/main/build_tools/python_deploy/pypi_deploy.sh is changing some of the package version metadata, but not enough for pip. The 2.9.0 release of https://pypi.org/project/iree-base-compiler/ is reported as version
iree-base-compiler==2.9.0rc20241108
Steps to reproduce your issue
See the issue using stable pypi releases:
Reproduce locally:
Download a wheel file from https://github.com/iree-org/iree/releases/tag/iree-3.0.0rc20241114
Run the promotion script on a single release:
Check the version on the converted file:
What component(s) does this issue relate to?
Python
Version information
Tip of tree: https://github.com/iree-org/iree/commit/d4975713a0aa3ba872807fc16585fb4b5a04e41d
Additional context
Looking into the .whl file (they are zip archives), I see:
/iree_base_compiler-3.0.0.dist-info/METADATA
reportsVersion: 3.0.0
as expected/iree_base_compiler.egg-info/PKG-INFO
reportsVersion: 3.0.0rc20241114
The runtime wheel and our downstream wheels like https://pypi.org/project/shortfin/ don't have that
.egg-info
folder orPKG-INFO
fileSo next step is figuring out what
.egg-info
is, why we are producing it, and if https://github.com/hauntsaninja/change_wheel_version or our own scripting should handle it. I can also directly edit the package files to see if that is the cause.