ethpm / py-ethpm

This library is deprecated. ethPM python tooling is now located in web3.py
MIT License
24 stars 13 forks source link

CLI maybe? #150

Open pipermerriam opened 5 years ago

pipermerriam commented 5 years ago

What was wrong?

It's still kind of hard for people to work with ethpm packages.

  1. Vyper might add support for using EthPM for contract interfaces
  2. Web3.py supports working with packages but right now you have to do a bit of configuration to make it work.
  3. Maybe we get Solidity onboard at some point, or web3.js, or brownie, or ....

But other than the first two which are snake charmer projects, it's likely that the 3rd party projects end up implementing support in their own

How can it be fixed?

This has me thinking about the concept of filesystem installs for ethpm packages. I implemented this once in populus a long time ago:

https://github.com/ethereum/populus/blob/4e9cc1efcea2333f48ceec9081ef5392d87608e8/populus/packages/installation.py

I'm wondering if there's utility in shipping a CLI for installing packages to disk as well as going ahead and defining the specification for the layout of packages on disk so that 3rd party integration is well supported. This would lower barrier to using EthPM based features for both Vyper and Web3.py use case and should reduce some barriers to adding support to some of those other 3rd party frameworks.

Here's the general layout as I remember it from the Populus implementation.

ROUGH Filesystem Installation Spec

The below is written using UNIX environment variable syntax for simplicity sake.

To install a package a user must provide the following information.

The PACKAGE_IDENTIFIER concept should be fully fleshed out, potentially using a URI scheme, however for this spec, I'll define two identifier types which can generally be mapped to URI schemes.

Installation of packages is a recursive operation, with the top level namespace being comprised of user specified packages and deeper name spacing being the dependencies of the user specified packages. Here is what a single package namespace looks like.

|--- CWD
  |---PACKAGES_DIR
    |--- ethpm.lock
    |--- <package-name>
    | |--- package.json
    | |--- SRC/<package-source-tree>
    | |--- PACKAGES_DIR  (same directory format containing installed dependencies for this package.
    |   |--- <...>
    |--- <...>

When a user installs a package, the directory structure above is lazily created. Each top level package is installed to it's own directory as follows.

Within that directory, the following files and directories are created.

Each $PACKAGES_DIR contains a top level file named ethpm.lock. The purpose of this file is track what packages are installed and what mechanism they were installed with. This is necessary to preserve the information of where packages came from in for packages installed via mechanisms like registry URIs. The file structure is out of scope for this spec but it would contain thing like the following.