Setuptool can't find custom command

Hi everyone,

during plugin development I came across a problem with running python commands; to be more specific, setuptools in a snapcraft cleanbuild environment. In my plugin (which is based on snapcraft’s python plugin) I’m using pip to install a package that extends setuptool commands by a build_apps command. Now if I try to call the setup script using this command, snapcraft exits with an error telling the command is not available.

Alternatively I’ve also tried to import the setup module of the installed pip package in the setup script directly to make sure the command is set up. Though, this leads to an import error stating the module is not available even though the module can be imported for example by calling python3 -c ‘from direct.showutil.dist import setup’ but as soon as I’m trying to call it within the actual setup.py file, it fails. The actual calls in the plugin script are:
self.run([self._get_python_command(), "-c", "'from direct.showutil.dist import setup'"], env=env, cwd=cwd)
and
self.run([self._get_python_command(), self._get_cmd_string(setup_file), "build_apps"], env=env, cwd=cwd)
They are called right after another with the same environment for env and directory for cwd.

Is there a difference in how snapcraft handles the calls to python3 -c ‘command…’ and python3 setup.py build_apps?
And what could cause that the setuptools command is not correctly acknowledged by the installed setuptools at all?

The plugin script can be found over at:

I just noticed, that the python3 -c ‘command…’ call doesn’t seem to work at all as I tried to add print statements and some other stuff like file writing which had no effect.

Aside of that, I can definitely see that the desired packages got installed, but it seems the python interpreter can’t find it. Is there someone here who has knowledge about snapcrafts python plugin? Maybe there is something with the environment handling which I’ve overlooked.