glyph
A proof-of-concept package manager for Cairo contracts/libraries. Distribution through pypi. Installation through existing package managers -- pip, pipenv, poetry.
Intended to be a lightweight layer on top of existing python package management. Sole responsibility is collecting contracts/libraries registered to the contracts
namespace package, and copying their contents to a new contracts/lib
folder.
NOTE: solely experimental to play around one potential strategy, doubtful that this would be a real package management solution for the ecosystem
Usage
Install with pip install cairo-glyph
. Additionally, pip install cairo-nile
and nile init
to intialize a starter project.
Check out the help command (auto-gen from code, will always be more up to date than this README):
(venv) sam@sam:~/dev/eth/tmp$ glyph --help
Usage: glyph [OPTIONS] COMMAND [ARGS]...
A proof-of-concept package manager for Cairo.
Options:
--install-completion Install completion for the current shell.
--show-completion Show completion for the current shell, to copy it or
customize the installation.
--help Show this message and exit.
Commands:
clean Remove everything in the lib directory
use Install one or all added cairo packages in the project
Use all libraries installed to the venv:
(venv) sam@sam:~/dev/eth/tmp$ glyph use --all
๐ Discovering installed contracts...
โ
Done.
For now, nothing is installed. To change that, do a pip install cairo-placeholder
Then do it again:
(venv) $ glyph use --all
๐ Discovering installed contracts...
โข Using contracts.placeholder
โ
Done.
If we inspect our project directory we now see it's installed in a contracts/lib
folder:
โโโ accounts.json
โโโ contracts
โ โโโ contract.cairo
โ โโโ libs
โ โโโ placeholder
โ โโโ contract.cairo
โโโ Makefile
โโโ tests
โ โโโ test_contract.p
Your Own Library Setup
In order to allow your contracts to be installed, a few conventions must be followed.
contracts # The "namespace package" that the contracts are installed to
โโโ placeholder # The library you are distributing
โโโ contract.cairo
โโโ __init__.py # Required to be installable.
setup.py # The installer
The actual setup.py
will look something like this:
from setuptools import setup
setup(
name="placeholder",
version="1",
description="",
long_description="",
author="Jane Doe",
author_email="[email protected]",
license="MIT License",
packages=["contracts.placeholder"],
# Include all extra package data. Possible to include *.cairo only
package_data={"": ["*"]},
zip_safe=False,
)
If using poetry, have pyproject.toml like:
[tool.poetry]
name = "cairo-placeholder"
version = "0.0.2"
description = "Example project for cairo-glyph"
authors = ["Your Name
"]
license = "MIT License"
readme = "README.md"
packages = [
{ include = "contracts/*" },
]
[tool.poetry.dependencies]
python = "^3.7"
cairo-nile = "^0.3.0"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Once distributed on pypi, one could:
(venv) $ pip install cairo-glyph cairo-placeholder
...
(venv) $ glyph use placeholder
๐ Discovering installed contracts...
โข Using contracts.placeholder
โ
Done.
Adding the following to your project:
contracts/
โโโ libs
โโโ placeholder
โโโ contract.cairo