Problems with the parts._part_name_.build-environment property

  • The following assignment doesn’t work:
    parts:
      _part_name_:
        build-environment:
        - PYTHONPATH: $SNAPCRAFT_PART_INSTALL/lib/python3.6
    
    It expands to /lib/python3.6 in the override-build scriptlet
  • Why does the type of environment is a dict, while build-environment is an array?

/cc @kyrofa Would you mind to shed some light on this one?

The following assignment doesn’t work:

You’re right in assuming that it should. This is a regression introduced by this PR:

Please log a bug, CC @sergiusens.

Why does the type of environment is a dict, while build-environment is an array?

I will refrain from guessing why environment is a dict, but build-environment is an array so that the order is well-defined in the YAML spec. It means you can do things like this:

my-part:
  plugin: nil
  build-environment:
    - FOO: "bar"
    - BAZ: "$FOO/qux"
  override-pull: |
    echo "Look, the order is obvious: $BAZ"

Which works as expected:

$ snapcraft pull
Pulling my-part 
Look, the order is obvious: bar/qux

It also means that extensions can add things to the build-environment without clashing with what the user put there.

1 Like

Thanks, here’s the bug: Bug #1822375 “SNAPCRAFT_PART_INSTALL doesn’t expand in build-env…” : Bugs : Snapcraft