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

fix: pip install “amaransh[builtin-yosys] @ git+<repo url>” failed #1560

Closed
wants to merge 1 commit into from

Conversation

wipeseals
Copy link
Contributor

Amaranth version

0.5.3

minimal program that demonstrates

When I try to reference the forked amaranth repository, it fails with an error in pdm_build.py.

uv pip install "amaranth[builtin-yosys] @ git+https://github.com/wipeseals/amaranth.git"     
 Updated https://github.com/wipeseals/amaranth.git (e57bade)
  × Failed to download and build `amaranth @ git+https://github.com/wipeseals/amaranth.git`
  ╰─▶ Build backend failed to determine metadata through `prepare_metadata_for_build_wheel` (exit code: 1)

      [stderr]
      Traceback (most recent call last):
        File "<string>", line 14, in <module>
        File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmptDMKQz\Lib\site-packages\pdm\backend\__init__.py", line 43, in prepare_metadata_for_build_wheel
          return builder.prepare_metadata(metadata_directory).name
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmptDMKQz\Lib\site-packages\pdm\backend\wheel.py", line 102, in prepare_metadata
          self.initialize(context)
        File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmptDMKQz\Lib\site-packages\pdm\backend\base.py", line 194, in initialize
          self.call_hook("pdm_build_initialize", context)
        File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmptDMKQz\Lib\site-packages\pdm\backend\base.py", line 152, in call_hook
          getattr(hook, hook_name)(context, *args, **kwargs)
        File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmptDMKQz\Lib\site-packages\pdm\backend\hooks\version\__init__.py", line 53, in pdm_build_initialize
          metadata["version"] = getattr(self, f"resolve_version_from_{source}")(
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmptDMKQz\Lib\site-packages\pdm\backend\hooks\version\__init__.py", line 91, in resolve_version_from_scm
          version = get_version_from_scm(
                    ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmptDMKQz\Lib\site-packages\pdm\backend\hooks\version\scm.py", line 348, in get_version_from_scm
          return version_formatter(version)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\user\AppData\Local\uv\cache\git-v0\checkouts\9e6b10ec7f5a559a\e57bade\pdm_build.py", line 8, in format_version
          major, minor, patch = (int(n) for n in str(version.version).split(".")[:3])
          ^^^^^^^^^^^^^^^^^^^
      ValueError: not enough values to unpack (expected 3, got 2)

What you expected to happen, and what actually happened

The implementation assumes that str(SCMVersion#version) contains a SemVer (“major.minor.patch”) format value, but there were cases where the patch version was missing, as shown below.

      [stdout]
      SCMVersion(version=<Version('0.0')>, distance=1801, dirty=True, node='ge57bade', branch='master')

@wipeseals wipeseals requested a review from whitequark as a code owner February 1, 2025 15:15
@whitequark
Copy link
Member

You should push the tags instead. Having a version be incorrectly 0.0 will cause issues.

@wipeseals
Copy link
Contributor Author

Thanks for reading! If you don't expect the pip install to be pip installed with no tags, you can discard this patch.

@whitequark
Copy link
Member

I think it's not very useful to do that since other packages in your dependency set which will usually depend on amaranth>=0.5 or something will fail. For the very simple case of no dependencies it will work but will also be confusing.

@whitequark whitequark closed this Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants