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

question: can I use a list defined in context to define shared requirements? #1472

Open
theavey opened this issue Mar 6, 2025 · 2 comments

Comments

@theavey
Copy link

theavey commented Mar 6, 2025

I have a recipe.yaml that defines a bunch of outputs. They all have the same host requirements, but I think currently I have to define them separately for each subpackage output. This is particularly annoying when I want to change them because I have to change it for each.

With the new (experimental) feature of lists defined in context, can I define a list of host requirements there and then use the list for each of the outputs? Alternatively, can I define a "global" set of host requirements that get inherited by each output (95% sure not currently supported, but I kinda like the idea)

current simplified recipe
context:
  version: ${{ env.get("VERSION") }}
  build_num: ${{ env.get("BUILD_NUM") }}

source:
  path: ../
  use_gitignore: true

build:
  number: ${{ build_num }}
  noarch: python

outputs:
  - package:
      name: thing_a
      version: ${{ version }}
    requirements:
      host:
        - pip
        - poetry-core >=2.0.0
        - tomlkit
        - python
        - python-build
        - ruamel.yaml
      run:
        - python>=3.9
        - requests

  - package:
      name: thing_b
      version: ${{ version }}
    requirements:
      host:
        - pip
        - poetry-core >=2.0.0
        - tomlkit
        - python
        - python-build
        - ruamel.yaml
      run:
        - python>=3.9
        - pandas
simplified recipe using list in context
context:
  version: ${{ env.get("VERSION") }}
  build_num: ${{ env.get("BUILD_NUM") }}
  host_requirements:
    - pip
    - poetry-core >=2.0.0
    - tomlkit
    - python
    - python-build
    - ruamel.yaml

source:
  path: ../
  use_gitignore: true

build:
  number: ${{ build_num }}
  noarch: python

outputs:
  - package:
      name: thing_a
      version: ${{ version }}
    requirements:
      host: ${{ host_requirements }}
      run:
        - python>=3.9
        - requests

  - package:
      name: thing_b
      version: ${{ version }}
    requirements:
      host: ${{ host_requirements }}
      run:
        - python>=3.9
        - pandas
simplified recipe using inherited requirements
context:
  version: ${{ env.get("VERSION") }}
  build_num: ${{ env.get("BUILD_NUM") }}

source:
  path: ../
  use_gitignore: true

build:
  number: ${{ build_num }}
  noarch: python

requirements:
  host:
    - pip
    - poetry-core >=2.0.0
    - tomlkit
    - python
    - python-build
    - ruamel.yaml
  run:
    - python>=3.9

outputs:
  - package:
      name: thing_a
      version: ${{ version }}
    requirements:
      # host:  # purely inherited here
      run:
        # maybe inherited as a union, or if overriding at all, need to also specifiy the things listed in the "base"
        # - python>=3.9
        - requests

  - package:
      name: thing_b
      version: ${{ version }}
    requirements:
      # host:  # purely inherited here
      run:
        # maybe inherited as a union, or if overriding at all, need to also specifiy the things listed in the "base"
        # - python>=3.9
        - pandas
@mgorny
Copy link
Contributor

mgorny commented Mar 6, 2025

With the new (experimental) feature of lists defined in context, can I define a list of host requirements there and then use the list for each of the outputs?

I'm afraid that's not possible, and I can't think of a way of making it possible, short of changing how Jinja is used. However, that is likely to break some tooling.

@theavey
Copy link
Author

theavey commented Mar 6, 2025

I'm afraid that's not possible, and I can't think of a way of making it possible, short of changing how Jinja is used. However, that is likely to break some tooling.

Yeah, kinda expected so, but was hopeful :) Thank you for the quick reply, and from the implementer of the feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants