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

[bug] pdm fails to build whl when use_uv is True #3231

Closed
1 task done
monchin opened this issue Oct 29, 2024 · 5 comments · Fixed by #3237
Closed
1 task done

[bug] pdm fails to build whl when use_uv is True #3231

monchin opened this issue Oct 29, 2024 · 5 comments · Fixed by #3237
Labels
🐛 bug Something isn't working

Comments

@monchin
Copy link
Contributor

monchin commented Oct 29, 2024

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

set pdm config use_uv false, then make a pdm project, and run pdm build, it fails with log

pdm.termui: Preparing environment(Isolated mode) for PEP 517 build...
pdm.termui: Error occurs
Traceback (most recent call last):
  File "C:\Users\c.men\AppData\Roaming\pdm\venv\lib\site-packages\pdm\termui.py", line 260, in logging
    yield logger
  File "C:\Users\c.men\AppData\Roaming\pdm\venv\lib\site-packages\pdm\cli\commands\build.py", line 62, in do_build
    sdist_file = SdistBuilder(project.root, project.environment).build(dest)
  File "C:\Users\c.men\AppData\Roaming\pdm\venv\lib\site-packages\pdm\builders\base.py", line 84, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\c.men\AppData\Roaming\pdm\venv\lib\site-packages\pdm\builders\sdist.py", line 14, in build
    self.install(self._requires, shared=True)
  File "C:\Users\c.men\AppData\Roaming\pdm\venv\lib\site-packages\pdm\builders\base.py", line 322, in install
    install_requirements(missing, env)
  File "C:\Users\c.men\AppData\Roaming\pdm\venv\lib\site-packages\pdm\installers\core.py", line 45, in install_requirements
    syncer.synchronize()
  File "C:\Users\c.men\AppData\Roaming\pdm\venv\lib\site-packages\pdm\installers\uv.py", line 39, in synchronize
    builder.build_uv_lock(include_self=self.install_self)
  File "C:\Users\c.men\AppData\Roaming\pdm\venv\lib\site-packages\pdm\formats\uv.py", line 100, in build_uv_lock
    group = req.groups[0]
IndexError: list index out of range

Actual behavior

It fails

Expected behavior

It successes just as use_uv is False

Environment Information

I'm using pdm==2.19.3. I checked the source code, and found that when building whl, the Synchronizer's requirements would be just pdm-backend, with groups=[], so req.groups[0] would be out of range. In my opinion, the simplest way is to run uv build when use_uv is True, it seems uv build can recognize the contents in [tool.pdm.build] such as excludes, is-purelib, etc. But uv build doesn't support --no-sdist, so if pdm build --no-sdist, tar.gz should be removed after uv build is called.

@monchin monchin added the 🐛 bug Something isn't working label Oct 29, 2024
@monchin
Copy link
Contributor Author

monchin commented Oct 29, 2024

I have implemented the solution to directly use uv build when use_uv is true here. If it is ok, I'm glad to make a PR.

@frostming
Copy link
Collaborator

Can you reproduce it on the main branch?

@monchin
Copy link
Contributor Author

monchin commented Oct 29, 2024

Can you reproduce it on the main branch?

Yes, I can reproduce it on 4401ff5

@frostming
Copy link
Collaborator

@monchin Thanks, can you contribute the PR

@monchin
Copy link
Contributor Author

monchin commented Oct 31, 2024

@monchin Thanks, can you contribute the PR

My pleasure. I have made the PR.

And I also found that pdm build -h shows that there is a --quiet arg, but it seems useless in build. uv build is quite verbose but it would output nothing if -q is added, so maybe we can add quiet parameter in do_build

frostming pushed a commit that referenced this issue Oct 31, 2024
* fix: build fails when use_uv is true(#3231)

* fix: delete uv build .gitignore so that publish could work

* fix: make uv build compatible to --no-clean

* feat: uv build enables --quiet

* fix: resolve #3237 conversation

* fix: build test failed

---------

Co-authored-by: c.men <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants