A proof-of-concept package manager for Cairo contracts/libraries

Overview

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:

"] 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"">
[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
You might also like...
A deployer and package manager for OceanBase open-source software.

OceanBase Deploy OceanBase Deploy ๏ผˆ็ฎ€็งฐ OBD๏ผ‰ๆ˜ฏ OceanBase ๅผ€ๆบ่ฝฏไปถ็š„ๅฎ‰่ฃ…้ƒจ็ฝฒๅทฅๅ…ทใ€‚OBD ๅŒๆ—ถไนŸๆ˜ฏๅŒ…็ฎก็†ๅ™จ๏ผŒๅฏไปฅ็”จๆฅ็ฎก็† OceanBase ๆ‰€ๆœ‰็š„ๅผ€ๆบ่ฝฏไปถใ€‚ๆœฌๆ–‡ไป‹็ปๅฆ‚ไฝ•ๅฎ‰่ฃ… OBDใ€ไฝฟ็”จ OBD ๅ’Œ OBD ็š„ๅ‘ฝไปคใ€‚ ๅฎ‰่ฃ… OBD ๆ‚จๅฏไปฅไฝฟ็”จไปฅไธ‹ๆ–น

A wrapper for the apt package manager.

A wrapper for the apt package manager.

a simple proof system I made to learn math without any mistakes

math_up a simple proof system I made to learn math without any mistakes 0. Short Introduction test yourself, enjoy your math! math_up is an NBG-based,

๐Ÿ† A ranked list of awesome Python open-source libraries and tools. Updated weekly.

Best-of Python ๐Ÿ† A ranked list of awesome Python open-source libraries & tools. Updated weekly. This curated list contains 230 awesome open-source pr

Tool to generate wrappers for Linux libraries allowing for dlopen()ing them without writing any boilerplate

Dynload wrapper This program will generate a wrapper to make it easy to dlopen() shared objects on Linux without writing a ton of boilerplate code. Th

Control System Packer is a lightweight, low-level program to transform energy equations into the compact libraries for control systems.
Control System Packer is a lightweight, low-level program to transform energy equations into the compact libraries for control systems.

Control System Packer is a lightweight, low-level program to transform energy equations into the compact libraries for control systems. Packer supports Python ๐Ÿ , C ๐Ÿ’ป and C++ ๐Ÿ’ป libraries.

๐ŸŒˆPython cheatsheet for all standard libraries(Continuously Updated)

Python Standard Libraries Cheatsheet Depend on Python v3.9.8 All code snippets have been tested to ensure they work properly. Fork me on GitHub. ไธญๆ–‡ En

Get a list of the top-10 rejected libraries in your WhiteSource inventory
Get a list of the top-10 rejected libraries in your WhiteSource inventory

WhiteSource Top 10 Rejected Libraries Generate a spreadsheet listing the 10 most common libraries in your WhiteSource inventory that were rejected by

An ongoing curated list of frameworks, libraries, learning tutorials, software and resources in Python Language.
An ongoing curated list of frameworks, libraries, learning tutorials, software and resources in Python Language.

Python Development Welcome to the world of Python. An ongoing curated list of frameworks, libraries, learning tutorials, software and resources in Pyt

Owner
Sam Barnes
Sam Barnes
Cairo-bloom - A naive bloom filter implementation in Cairo

?? cairo-bloom A naive bloom filter implementation in Cairo. A Bloom filter is a

Sam Barnes 37 Oct 1, 2022
Xoroshiro-cairo - A xoroshiro128** pseudorandom number generator implementation in Cairo

xoroshiro-cairo A xoroshiro128** pseudorandom number generator implementation in

Milan Cermak 26 Oct 5, 2022
Cairo-integer-types - A library for bitwise integer types (e.g. int64 or uint32) in Cairo, with a test suite

The Cairo bitwise integer library (cairo-bitwise-int v0.1.1) The Cairo smart tes

null 27 Sep 23, 2022
A command line interface tool converting starknet warp transpiled outputs into readable cairo contracts.

warp-to-cairo warp-to-cairo is a simple tool converting starknet warp outputs (NethermindEth/warp) outputs into readable cairo contracts. The warp out

Michael K 5 Jun 10, 2022
Installer, package manager, build wrapper and version manager for Piccolo

Piccl Installer, package manager, build wrapper and version manager for Piccolo

null 1 Dec 19, 2021
Black-Scholes library implemented as a Cairo smart contract

Cairo Black-Scholes Library Black-Scholes library implemented as a Cairo smart contract. All inputs, outputs, and internal calculations use 27-digit f

Aditya Raghavan 47 Dec 19, 2022
Cairo hooks for pre-commit

pre-commit-cairo Cairo hooks for pre-commit. See pre-commit for more details Using pre-commit-cairo with pre-commit Add this to your .pre-commit-confi

Fran Algaba 16 Sep 21, 2022
A simple and easy to use Python's PIP configuration manager, similar to the Arch Linux's Java manager.

PIPCONF - The PIP configuration manager If you need to manage multiple configurations containing indexes and trusted hosts for PIP, this project was m

Joรฃo Paulo Carvalho 11 Nov 30, 2022
ArinjoyTheDev 1 Jul 17, 2022
Expense-manager - Expense manager with python

Expense_manager TO-DO Source extractor: Credit Card, Wallet Destination extracto

null 1 Feb 13, 2022