Use of Python's DistUtilsExtra causes pip install failure

When running snapcraft, python3 -m pip install is failing with

distutils.errors.DistutilsOptionError: error in setup.cfg: command 'build' has no such option 'i18n' [or 'icons' or 'pod2man']

I’m pretty sure it’s failing because pip is picking up the setup.cfg when installing the dependencies in the requirements.txt, whereas in reality setup.cfg is useful only for installing the main source package.

Now maybe my project’s is stuck in the past and it shouldn’t really be using DistUtilsExtra, because I can’t find a single instance of a snap on github that uses it. Or maybe my is missing some kind of clever workaround for the setup.cfg problem.

But assuming snapcraft should not fail when DistUtilsExtra is being used in the way my project uses it, does this indicate a need for snapcraft to be improved? Or does my project’s snapcraft.yaml need some work done on it, perhaps by separating the installation of the python package dependencies from the installation of the project package itself so that the setup.cfg is used only for the latter?

Please note this is my first attempt at building a snap package, so I wouldn’t be surprised if the snapcraft.yaml is not ideal.

This is beacuse the python plugin is really a pip plugin in the background. We don’t do python3 ... but instead pip install ., so your use case could be supported in a distutils plugin which does not exist yet though.

We should provide a better error message here.

My application works with pip – it’s just one has to workaround the setup.cfg being wrongly applied to the dependencies. Using pip to install the application means pip installing all the PyPi dependencies in one step (ignoring the project’s setup.cfg) and then installing the project itself while instructing pip to ignore dependencies.

Even though my project is not up on PyPi (due to the complexity of its required dependencies), ideally I’d like to follow best practice in the python packaging community, and naturally that means sticking with pip.

Does sticking with pip mean I should dump the use of DistUtilsExtra, and figure out another way to install icons, the i18n stuff, and man page? I’m not actually sure how to do that, but I guess some or other project does a good job if it, somewhere. My impression is that the python packaging community (i.e. the pip developers) don’t actively support DistUtilsExtra.

@elopio you had a proposal for this, right?

Is this related to bug 1712634?

Well, we talked about the setup.cfg here:

Nothing proposed yet.

We should just fix it then :wink:

Sorry, I haven’t been able to work on it. Learning git and contributing to another project on top of maintaining my own project and writing a dissertation is too much for me too handle. Sorry for the lack of communication.

No worries, we’ll take care of it.

Just bumped into this while making a snap of Magnus. I ended up using the nil plugin and using install calls via override-build since only a few files actually need installing in this case.