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: change definition of pkg_type variable in build function to solve KeyError: 'conda' #5560

Merged
merged 4 commits into from
Dec 9, 2024

Conversation

ypradat
Copy link
Contributor

@ypradat ypradat commented Dec 3, 2024

Description

When trying to run conda-build on a simple perl package I wrote, I came across the error

Traceback (most recent call last):
  File "/mnt/nfs01/home/y_pradat/mambaforge/bin/conda-build", line 11, in <module>
    sys.exit(execute())
  File "/mnt/nfs01/home/y_pradat/mambaforge/lib/python3.10/site-packages/conda_build/cli/main_build.py", line 648, in execute
    api.build(
  File "/mnt/nfs01/home/y_pradat/mambaforge/lib/python3.10/site-packages/conda_build/api.py", line 211, in build
    return build_tree(
  File "/mnt/nfs01/home/y_pradat/mambaforge/lib/python3.10/site-packages/conda_build/build.py", line 3653, in build_tree
    packages_from_this = build(
  File "/mnt/nfs01/home/y_pradat/mambaforge/lib/python3.10/site-packages/conda_build/build.py", line 2764, in build
    newly_built_packages = bundlers[pkg_type](
KeyError: 'conda'

although I specified

build:
  pkg_format: ".conda"

in the meta.yaml of the conda recipe of my package. I tried

build:
  pkg_format: "conda"

as well but the same error occurred.

As a matter of fact, I don't quite understand how the current code can work. Looking at https://github.com/conda/conda/blob/main/conda/base/constants.py#L152-L153, we see clearly that acceptable keys for the bundlers dictionary are .conda, .tar.bz2, or wheel, not conda.

I suggest to replace the definition of pkg_type in the build.py function using the following piece of code from render.py
https://github.com/conda/conda-build/blob/main/conda_build/render.py#L73-L79.

Doing this replacement solved the KeyError issue for me.

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@ypradat ypradat requested a review from a team as a code owner December 3, 2024 14:39
@conda-bot
Copy link
Contributor

We require contributors to sign our Contributor License Agreement and we don't have one on file for @ypradat.

In order for us to review and merge your code, please e-sign the Contributor License Agreement PDF. We then need to manually verify your signature, merge the PR (conda/infrastructure#1072), and ping the bot to refresh the PR.

@travishathaway
Copy link
Contributor

@conda-bot check

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Dec 3, 2024
Copy link

codspeed-hq bot commented Dec 3, 2024

CodSpeed Performance Report

Merging #5560 will not alter performance

Comparing ypradat:fix-pkg-type-key-error (9f996b1) with main (3cf75b6)

Summary

✅ 5 untouched benchmarks

@jaimergp
Copy link
Contributor

jaimergp commented Dec 5, 2024

pre-commit.ci autofix

@jaimergp jaimergp closed this Dec 6, 2024
@jaimergp jaimergp reopened this Dec 6, 2024
@jaimergp
Copy link
Contributor

jaimergp commented Dec 6, 2024

@conda/builds-tools, any idea why the CI is not running here?

edit: nvm, it was the new "merge experience" beta

@jaimergp
Copy link
Contributor

jaimergp commented Dec 9, 2024

@conda/builds-tools - this is ready for review.

@jaimergp jaimergp merged commit 56a2a80 into conda:main Dec 9, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants