Skip to content

Instantly share code, notes, and snippets.

@ugexe
Last active September 22, 2017 17:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ugexe/ec5fe910d3187c46a4f8e634423cb4ea to your computer and use it in GitHub Desktop.
Notes on perl6 meta and dependency specs
                                                {                                           ________________________________ 
                                                    "meta-spec" : "1",                                                      | (not sure if CUR needs to know meta-spec version)
                                                    "perl"      : "6.c",                                                    |       ------------
                                                                                __                                          |                   |
                                                    "name" : "Foo",               |                                         |                   |
                                             __                                   |                                         |                   |
                                            |       "auth" : "me@cpan.org",       |_______ Distribution DepSpec             |                   |
                                            |       "api"  : "2",                 |(Foo:auth<me@cpan.org>:api<2>:ver<1>)    |                   |
                 Module DepSpec ____________|       "ver"  : "1",               --                                          |                   |
      (Foo:auth<me@cpan.org>:api<2>:ver<1>) |                                                                               |                   |
 (Foo::Baz:auth<me@cpan.org>:api<2>:ver<1>) |       "provides" : {                                                          |                   |
                                            |           "Foo" : "lib/Foo.pm6",                                              |___ META6 Spec     |
                                            |__         "Foo::Baz" : "lib/Foo/Baz.pm6"                                      |                   |
                                                    },                                                                      |                   |
                                                                                                                            |                   |__ CUR Extended META6 Spec
                                                    "build-depends" : [ ],                                                  |                   |
                                                    "test-depends"  : [ ],                                                  |                   |
                                                    "depends"       : [ ],                                                  |                   |
                                                    "<other fields defined in S22>" : "...",                                |                   |
                                                                                                                            |                   |
                                                    "resources"     : {                                                     |                   |
                                                        "config.json",                                                      |                   |
                                                        "libraries/MyLib"                    _______________________________|                   |
                                                    },                                                                                          |
                                                                                                                                                |
                                                    "files" : {                                                                                 |
                                                        "bin/foo.pl6" : "<path-after-install>.pl6",                                             |
                                                        "resources/config.json" : "<path-after-install>.json",                                  |
                                                        "resources/libraries/MyLib" : "[lib]?<path-after-install>.[so|dll|dylib]"               |
                                                    }                                                                               ____________|
                                                }

META6 Spec

Package description format containing the various required (all shown) and optional (not all shown) fields required for tools to search and install

CUR Extended META6 Spec

This is like META6 Spec, except it adds some fields to hold values that are implied by other fields. e.g. expands resources libraries into their full names, provides a place for bin files, etc without a runtime calculation penalty each time.

Module DepSpec

Similar to CompUnit::DependencySpecification - these are the fields of the META6 spec that can be used to identify specific modules. This small subset gets saved (in a non-json format) to allow CUR to do faster lookups. The format is a string that can roundtripped to a hash and back fairly easily, with any nested levels of a given hash ignored (so nested hashes can still be useful for extensions).

One cannot reasonably pass a hash data structure on the command line. You would not want to zef install "{ :name<...> }", and you probably don't want to declare all of your dependencies like this if you are just working on an idea. These are two reasons why its important to establish how to declare a dependency as a string, with a final reason being obvious: It's how you declare a dependency inside your perl6 code itself (via use).

Distribution DepSpec

Similar to Module DepSpec. This is not ideal because URI might refer to either one-of-many distributions containing a URI module or a distribution by the name URI. Note this is primarily only a problem for package managers like zef (in rakudo DepSpec is used only for finding -modules-), but a solution for this may be shared with a solution to "how to use a module from containing distribution only?" without hardcoding auth/ver/api for every version bump ala use Foo::Baz:auth<$*AUTH>:ver<$*VER>:api<$*API>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment