Skip to content

Python decentralized on IPFS, or🐍 in 🌌.

License

Notifications You must be signed in to change notification settings

koenvaneijk/spacesnake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌌🐍 spacesnake - Python decentralized on IPFS

Leveraging decentralized storage technology IPFS for hash-verified Python script/module distribution! Create unstoppable Python applications which can be accessed from anywhere in the universe. Enjoy the assurance that no changes were made to your script (as long as the hash matches).

Contents

Get started

Install from PyPi

pip install spacesnake

Note: Make sure your local IPFS node is running. The easiest way to set up a local IPFS node is by installing IPFS Desktop. By default, spacesnake expects your IPFS node to be at [https://127.0.0.1:5001], but you can override this with the SPACESNAKE_IPFS_NODE_URL environment variable.

Warning: IPFS is still experimental and work in progress. Also, security.

Warning: Always inspect scripts/hashes before you run them. Only run scripts from trusted sources.

To inspect an example "Hello world!" script from IPFS:

spacesnake script QmPzrKNqpMVypixkQDVAQc8MeF8PTuKtnwr91hfE3DAJ6j --inspect

To run an example "Hello world!" script straight from IPFS:

spacesnake script QmPzrKNqpMVypixkQDVAQc8MeF8PTuKtnwr91hfE3DAJ6j

Or importing modules:

import spacesnake # Required for IPFS imports to work
from QmcEuJMSci6SeMUu1xTCtVZmu8FHCnSKUUGp7nav6cuDEj import SnakeSpace

snake = SnakeSpace()
snake.fire_lazers()

Features

  • Import IPFS paths straight from your Python scripts!
  • Run Python scripts and modules straight from IPFS
  • Push your scripts/modules to IPFS to make them available globally and forever.

How it works

  • The spacesnake CLI wraps the runpy module from the Python standard library, with some IPFS-sauce.
  • spacesnake also implements an importer, which takes care of all the IPFS storage and caching magic behind the scenes!

The best way to make sure your script remains available to the world is by sharing with as many people as you can. That way, redundancy across the IPFS network increases for your script or module! Alternatively, you can use pinning services like Pinata to guarantee to some extent your scripts remain available.

Uploading your Python scripts to IPFS

You can use the spacesnake CLI to easily publish a script or module to IPFS, or you can use IPFS desktop to pin the file manually. Using the CLI takes care of import resolution so it makes sure your entire script is published!

Like so:

spacesnake push my_script.py

After confirmation returns the hash of the IPFS pin in stdout:

QmPzrKNqpMVypixkQDVAQc8MeF8PTuKtnwr91hfE3DAJ6j

You can skip confirmation with the -y flag:

spacesnake push my_script.py -y

You can then run the script:

spacesnake script QmPzrKNqpMVypixkQDVAQc8MeF8PTuKtnwr91hfE3DAJ6j

To do

  • Add tests!
  • Add IPFS gateway support (eliminates the need for a local IPFS node, but requires a trusted IPFS gateway)
  • Add script encryption/decryption with key or passphrase/password
  • Add IPNS support for pointers to IPFS CIDs

Feedback?

About

Python decentralized on IPFS, or🐍 in 🌌.

Topics

Resources

License

Stars

Watchers

Forks

Languages