It is not possible to build a python snap that has setup.py requirements

Bug #1712634 reported by Leo Arias
24
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Snapcraft
Triaged
High
Unassigned

Bug Description

There are some python projects that have dependencies on their setup.py This is probably a bad practice but we can see it in offlineimap [1] and rasterio [2], so we should probably have to support it in a nice way.

If the snapcraft.yaml is not on the same repository as the setup.py, we have a way to make it work like popey did in [3].

However, if we want the snapcraft.yaml in the same repo, the separate part for the setup dependencies will not work. The python plugin will see the setup.py and try to install it, even in the separate part.

This is because the default source is `.`. Maybe, we should support a `source: nil`, that is useful only to install stuff in stage, that's required for other parts, but doesn't assume that it has a source directory.

I made a dirty workaround, using `source: snap`, which will find only the snapcraft.yaml in the dir so it will not try to install the setup.py.

[1] https://forum.snapcraft.io/t/importerror-no-module-named-six/1002/2
[2] https://github.com/mapbox/rasterio/blob/b64bdd8b9a140faac574457e38261bf2a03f8a0b/setup.py#L84
[3] https://forum.snapcraft.io/t/importerror-no-module-named-six/1002/3

Revision history for this message
Leo Arias (elopio) wrote :
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Yeah i got confused about that too.
Somehow it should be possible to process requirements.txt without loading setup.py.

I've added try: except ImportError: statements to my setup.py and I have both requirements.txt and build-package: stanzas to install the same thing.

Very redundant.

Cris Dywan (kalikiana)
Changed in snapcraft:
status: New → Confirmed
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

The default `source: .` is the real problem here and we should fix that (with a potential break on some projects).

Changed in snapcraft:
status: Confirmed → Triaged
importance: Undecided → High
Revision history for this message
Leo Arias (elopio) wrote :

This also affects raiden:
https://github.com/elopio/raiden/blob/082acd1cb76a3a71dffead08685b8ee1516b7721/snap/snapcraft.yaml#L40

The workaround there is a little different, because we need to install requirements before running setup.py. Then, I added a dependent part, with the hack to delete the setup.py on prepare.

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.