How to set environment variables for parts?


Trying to get some basic snap bits in place for apache-airflow it looks like I need to set an environment variable at pip install time.

Here are my initial airflow snap bits, and here is the error I’m getting that seems to be forcing me to set an environment variable prior to pip install.

Fetching and installing setuptools...
Collecting setuptools
  Downloading (573kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 573kB 13.4MB/s 
  Saved ./parts/apache-airflow/python-packages/setuptools-40.6.3-py2.py3-none-any.whl
Successfully downloaded setuptools
Looking in links: /root/build_airflow/parts/apache-airflow/python-packages
Collecting setuptools
Installing collected packages: setuptools
Successfully installed setuptools-40.6.3
Collecting apache-airflow[all]
  Downloading (4.3MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4.3MB 5.8MB/s 
  Saved ./parts/apache-airflow/python-packages/apache-airflow-1.10.1.tar.gz
    Complete output from command python egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-download-f0qrnlpp/apache-airflow/", line 394, in <module>
      File "/tmp/pip-download-f0qrnlpp/apache-airflow/", line 259, in do_setup
      File "/tmp/pip-download-f0qrnlpp/apache-airflow/", line 49, in verify_gpl_dependency
        raise RuntimeError("By default one of Airflow's dependencies installs a GPL "
    RuntimeError: By default one of Airflow's dependencies installs a GPL dependency (unidecode). To avoid this dependency set SLUGIFY_USES_TEXT_UNIDECODE=yes in your environment when you install or upgrade Airflow. To force installing the GPL version set AIRFLOW_GPL_UNIDECODE

Any insight on how this might be accomplished using the python plugin would be very helpful.



You can use the build-environment property, however it’s a Snapcraft 3 feature and will require you using the new snapcraft syntax(i.e. with the base keyword, without the remote parts)

Refer for more info.

For legacy Snapcraft syntax you have to override the build step and build the part manually, or write a local plugin to replace/complement the python plugin.


I’ve got a few 2x4s beating me in the face here.

Kicking the tires with 3.x, using my airflow bits as a catalyst, I’ve added,L24 and

Now when I attempt to build my snap I get the following:

$ snapcraft cleanbuild
The cleanbuild command is no longer supported when using the base keyword.
✘-2 ~/allcode/github/omnivector/snap-airflow [master|✚ 2…2] 
10:06 $ snapcraft
You need multipass installed to build snaps which use the base keyword.
Would you like to install it now? [y/N]: y
snapd is not logged in, snap install commands will use sudo
[sudo] password for bdx: 
multipass (beta) 2018.12.1 from Canonicalβœ“ installed
Channel latest/beta for multipass is closed; temporarily forwarding to beta.
Waiting for multipass...
Launching a VM.
launch failed: CPU does not support KVM extensions.                             
An error occurred when trying to launch the instance with 'multipass': returned exit code 2.
Ensure that 'multipass' is setup correctly and try again.

To me, this indicates that I will not be able to build snaps that use bases on my little virtualbox vm anymore, looks like I will require bare metal hosts, or lxd running on bare metal hosts such that snapcraft will be able to spawn a vm. Does this sound correct?



You can still run the build in a compatible base version of LXD container by running Snapcraft in the container with the SNAPCRAFT_BUILD_ENVIRONMENT=host environment variable exported.