import-style prevents vendoring
See original GitHub issueI just tried to vendor TUF into pip (in other words embed the tuf sources inside pip sources) and it fails (even with #1160 fixed) because of the import style used in TUF source code itself:
import tuf.download
Using this (instead of relative imports) means tuf needs to be installed to python path for the imports to work.
I’ve looked at the dozen other projects pip vendors and the system seems to cope with two styles:
- Most projects use relative imports like
from . import treebuilders
from .treebuilders.base import Marker
- The other method is
from toml.decoder import InlineTableDict
The second style works because vendoring (the tool) modifies import NAME
to from vendored.path import NAME
and from NAME.module import something
to from vendored.path.NAME.module import something
. I assume this is mostly done so vendored dependencies of vendored projects work (so e.g. vendored tuf can “import securesystemslib”). In any case the TUF style cannot be automatically modified as far as I can tell.
I’ll try to add reproduction instructions that don’t require my pip branch…
Issue Analytics
- State:
- Created 3 years ago
- Comments:19 (19 by maintainers)
Top GitHub Comments
All of TUF dependencies are already pip dependencies (so succesfully vendored) except SSL and iso8601 (which is a single file library).
I’m researching more clever alternatives as both of these options mean a massive PR: ~700 actual code lines would need to change and the possibility of a namespace mistake is real. I’ll try to have a possible solution for discussion by tomorrow.
Regarding the other pain points you mentioned …
Agreed but probably not worth to change before the planned refactor? Definitely something to consider together with #1136 and #881. Maybe this warrants a separate over-arching module architecture design issue? Also https://github.com/theupdateframework/tuf/issues/1134#issuecomment-690091176 seems related.
Agreed but IMO low-prio.
unittest_toolbox
should probably also be subjected to a revision.Agreed but see both comments above and #1135.
I know. 😕 I’ve been meaning to at least submit an issue for this for a long time (I will do this right now). FWIW, I’ve fixed this a long time ago in in-toto and have created a ticket in securesystemslib, which both adopted their linter config from tuf (see https://github.com/secure-systems-lab/securesystemslib/issues/243).
I know. 😕 I think a sensible linter config would catch this (see above).