Import python modules by their hash.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NOTES.md 1.8 KiB

4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142
  1. Aliases:
  2. from a local file, kinda like requirements.txt, maps name to hash,
  3. either package/module name, or an author/public key name.
  4. This has to be treated specially. If two aliases appear to be the same, but one is fetched a "secure" IPFS hash, it MUST be compared w/ what ever secure hash the two aliases had in common. Otherwise a malicious package could "pretend" that it hash the sha256 that's the same, but provide a bad IPFS hash, and then we'd load the malicous package instead
  5. Example:
  6. from cas.a.jmg.utils import aiter, anext
  7. Make sure that when an alias is used, that the same module is returned when a
  8. direct hash import is used.
  9. Local cache:
  10. if a directory like ~/.cas_cache exists, use it's contents automatically,
  11. and if it's writable, write any network fetched imported data to it.
  12. Features:
  13. add:
  14. file
  15. url
  16. ipfs hash
  17. git(?)hub?
  18. init cache:
  19. Loading resources from yourself (package):
  20. sys.modules[__name__] returns a valid module while your are being initalized, even for __main__, though may not work due to it not being a package, but probably can be emulated via __file__
  21. use importlib.resources: https://docs.python.org/3.7/library/importlib.html#module-importlib.resources
  22. > Loaders that wish to support resource reading should implement a get_resource_reader(fullname) method as specified by importlib.abc.ResourceReader.
  23. Hash options:
  24. urn old ietf draft: https://datatracker.ietf.org/doc/draft-thiemann-hash-urn/
  25. - not up to date
  26. hash-uri: https://github.com/hash-uri/hash-uri
  27. - this looks best
  28. multihash: https://github.com/multiformats/multihash
  29. - no URI specification
  30. ipfs uri: https://github.com/ipfs/in-web-browsers/blob/master/ADDRESSING.md
  31. - not a hash, but useful for IPFS names
  32. ni: https://tools.ietf.org/html/rfc6920
  33. - complicated, not well supported