Python plugins fails to build a snap when some parts depends on unpublished modules

Bug #1841861 reported by Adrien Ferrand
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snapcraft
Fix Released
High
Sergio Schvezov

Bug Description

Hello,

I described the full case here: https://forum.snapcraft.io/t/building-a-snap-with-a-multi-python-project/12284

To sum up, let's suppose that you have two python projects, project1 and project2, lying in the same GIT repository. You are building a snap that consists in two parts, one for each project.

However, project2 depends on project1 in its current state, with new features added in project2 that are not yet release. Typically project2 will declare a dependency project1>=0.1.dev0.

Out of the snaps, this situation is OK for pip, since it will install project1 in the local site package, then will successfully install project2 since a compatible version of project1 is already available. However, snapcraft will fail in the same situation, complaining that it cannot find the required version of project1 in PyPI.

I checked the code of python plugin. In theory nothing prevents snapcraft to do the same thing than pip, since the sitecustomize module is properly set up to find packages from the other parts already compiled.

However, the root cause here is this line of code: https://github.com/snapcore/snapcraft/blob/6c3e3ab9acbf672760141f6456c3c47a92899fb3/snapcraft/plugins/python.py#L338

This line ask to invoke `pip download` for the set of requirements declared by a given part. And it will fail because it cannot find the required version for project1.

Funny thing is that in fact, the snap would be built perfectly without this, since the invocation of `pip install` after will successfully find the packages from the already installed snaps.

I made a showcase project (python projects + snapcraf.yml) that focuses on this error, if someone wants a clear target to fix this: https://github.com/adferrand/snapcraft-python-showcase

I am available for any question on that matter.

Regards,
Adrien Ferrand

Revision history for this message
Sergio Schvezov (sergiusens) wrote :
Changed in snapcraft:
importance: Undecided → High
status: New → In Progress
assignee: nobody → Sergio Schvezov (sergiusens)
Changed in snapcraft:
status: In Progress → Fix Committed
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Part of 3.10

Changed in snapcraft:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.