2020-05-15 13:41:26 +03:00
|
|
|
---
|
|
|
|
layout: developer-doc
|
|
|
|
title: Enso Libraries Packaging
|
|
|
|
category: distribution
|
|
|
|
tags: [packaging, distribution, layout]
|
|
|
|
order: 2
|
|
|
|
---
|
|
|
|
|
2020-05-13 19:27:16 +03:00
|
|
|
# Enso Libraries Packaging
|
2020-07-21 15:59:40 +03:00
|
|
|
|
|
|
|
Given the nature of Enso as an open-source programming language and platform, it
|
|
|
|
is crucial that we provide users with an extensible package management system.
|
|
|
|
This document describes the current state of our packaging efforts, as well as
|
|
|
|
future directions and enhancements to it.
|
2020-05-13 19:27:16 +03:00
|
|
|
|
|
|
|
<!-- MarkdownTOC levels="2,3" autolink="true" -->
|
|
|
|
|
|
|
|
- [Enso Package Structure](#enso-package-structure)
|
|
|
|
- [The `src` Directory](#the-src-directory)
|
|
|
|
- [The `polyglot` Directory](#the-polyglot-directory)
|
|
|
|
- [The `package.yaml` File](#the-packageyaml-file)
|
2020-08-18 18:04:53 +03:00
|
|
|
- [The `visualization` Directory](#the-visualization-directory)
|
2020-05-15 13:41:26 +03:00
|
|
|
- [Build Reproducibility](#build-reproducibility)
|
2020-05-13 19:27:16 +03:00
|
|
|
|
|
|
|
<!-- /MarkdownTOC -->
|
|
|
|
|
|
|
|
## Enso Package Structure
|
2020-07-21 15:59:40 +03:00
|
|
|
|
2020-05-13 19:27:16 +03:00
|
|
|
The general directory structure of an Enso package is as follows:
|
|
|
|
|
|
|
|
```
|
|
|
|
My_Package
|
|
|
|
├── package.yaml
|
|
|
|
├── polyglot
|
|
|
|
│ ├── java
|
|
|
|
│ │ └── jar.jar
|
|
|
|
│ └── js
|
|
|
|
│ └── library.js
|
2020-08-18 18:04:53 +03:00
|
|
|
├── src
|
|
|
|
│ ├── Main.enso
|
|
|
|
│ └── Sub_Module
|
|
|
|
│ ├── Helper.enso
|
|
|
|
│ └── Util.enso
|
2020-10-09 15:05:22 +03:00
|
|
|
├── visualization (optional)
|
|
|
|
│ └── ...
|
|
|
|
└── data (optional)
|
2020-05-13 19:27:16 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
### The `src` Directory
|
2020-07-21 15:59:40 +03:00
|
|
|
|
2020-05-13 19:27:16 +03:00
|
|
|
The `src` directory contains all Enso sources, organized in a hierarchical
|
2020-07-21 15:59:40 +03:00
|
|
|
structure. The structure of this directory dictates how particular modules are
|
|
|
|
imported in all of Enso code.
|
2020-05-13 19:27:16 +03:00
|
|
|
|
2020-07-21 15:59:40 +03:00
|
|
|
Note that all files and directories in this subtree must be named according to
|
|
|
|
the Enso style for referent names (i.e. `Upper_Snake_Case`, see
|
2020-05-15 13:41:26 +03:00
|
|
|
[the syntax specification](../syntax/naming.md#naming-constructs)).
|
2020-05-13 19:27:16 +03:00
|
|
|
|
|
|
|
A file located at the path `My_Package/src/Sub_Module/Helper.enso` will be
|
|
|
|
imported like so:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
import My_Package.Sub_Module.Helper
|
|
|
|
```
|
|
|
|
|
|
|
|
Please note the following:
|
|
|
|
|
|
|
|
- The name of the package appears as the first segment of the name.
|
2020-07-21 15:59:40 +03:00
|
|
|
- The package name is not specified by the containing directory's name, but
|
|
|
|
rather it is described in the `package.yaml` file.
|
2020-05-13 19:27:16 +03:00
|
|
|
|
|
|
|
The exact transformation is as follows:
|
|
|
|
|
|
|
|
1. The name of the package becomes the first segment of the qualified module
|
|
|
|
name.
|
|
|
|
2. Any subdirectories on the path from the `src` directory to the source file
|
|
|
|
are appended as consecutive segments.
|
2020-07-21 15:59:40 +03:00
|
|
|
3. The name of the source file, with the `.enso` extension stripped, becomes the
|
|
|
|
last segment.
|
2020-05-13 19:27:16 +03:00
|
|
|
|
|
|
|
### The `polyglot` Directory
|
2020-07-21 15:59:40 +03:00
|
|
|
|
2020-05-13 19:27:16 +03:00
|
|
|
The `polyglot` directory contains per-language subdirectories containing files
|
|
|
|
used by the supported polyglot languages. The contents of each subdirectory is
|
|
|
|
specified on a per-language basis, in the
|
2020-05-15 13:41:26 +03:00
|
|
|
[polyglot documentation](../polyglot/README.md).
|
2020-05-13 19:27:16 +03:00
|
|
|
|
2020-10-09 15:05:22 +03:00
|
|
|
### The `data` Directory
|
|
|
|
|
|
|
|
The `data` directory contains any data files and resources that the user needs
|
|
|
|
quick access to. Allows referring to resource files in a location-independent
|
|
|
|
way, by using the `Enso_Project.data` method.
|
|
|
|
|
2020-05-13 19:27:16 +03:00
|
|
|
### The `package.yaml` File
|
2020-07-21 15:59:40 +03:00
|
|
|
|
|
|
|
`package.yaml` describes certain package metadata, such as its name, authors and
|
|
|
|
version. It also includes the list of extra dependencies of the package
|
2020-07-21 11:14:26 +03:00
|
|
|
(dependencies that are not present in the resolver or need a version override).
|
2020-05-13 19:27:16 +03:00
|
|
|
The following is an example of this manifest file.
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
license: MIT
|
|
|
|
name: My_Package
|
|
|
|
version: 1.0.1
|
2021-01-05 17:14:08 +03:00
|
|
|
enso-version: 0.2.0
|
2020-08-31 16:53:33 +03:00
|
|
|
authors:
|
|
|
|
- name: John Doe
|
|
|
|
email: john.doe@example.com
|
|
|
|
maintainers:
|
|
|
|
- name: Jane Doe
|
|
|
|
email: jane.doe@example.com
|
2020-05-20 18:05:22 +03:00
|
|
|
resolver: lts-1.2.0
|
|
|
|
extra-dependencies:
|
2020-07-21 15:59:40 +03:00
|
|
|
- name: Base
|
|
|
|
version: "1.2.0"
|
|
|
|
- name: Http
|
|
|
|
version: "4.5.3"
|
2020-05-13 19:27:16 +03:00
|
|
|
```
|
|
|
|
|
2020-07-21 15:59:40 +03:00
|
|
|
The following is the specification of the manifest fields. Fields marked as
|
|
|
|
**Optional (required for publishing)** are completely optional during
|
|
|
|
development - if not specified, their default values will be used. However, they
|
|
|
|
must be specified before publishing the package. A package missing any of these
|
|
|
|
fields cannot be published.
|
2020-05-13 19:27:16 +03:00
|
|
|
|
|
|
|
#### license
|
2020-07-21 15:59:40 +03:00
|
|
|
|
|
|
|
**Optional (required for publishing)** _String_: The short license name of this
|
2020-07-21 11:14:26 +03:00
|
|
|
package. Defaults to `None`, meaning the package is not safe for use by third
|
|
|
|
parties.
|
2020-05-13 19:27:16 +03:00
|
|
|
|
2020-08-19 15:24:31 +03:00
|
|
|
#### enso-version
|
|
|
|
|
|
|
|
**Optional (required for publishing)** _String_: Specifies the Enso version that
|
|
|
|
should be used for this project. If not set or set to `default`, the default
|
|
|
|
locally installed Enso version will be used. The version should not be `default`
|
|
|
|
if the package is to be published.
|
|
|
|
|
2020-05-13 19:27:16 +03:00
|
|
|
#### version
|
2020-07-21 15:59:40 +03:00
|
|
|
|
|
|
|
**Optional (required for publishing)** _String_: The
|
2020-07-21 11:14:26 +03:00
|
|
|
[semantic versioning](https://semver.org/) string, in the `major.minor.patch`
|
|
|
|
format. If not set, it defaults to `dev` (which can be used for development, but
|
|
|
|
is not a valid version for publishing).
|
2020-05-13 19:27:16 +03:00
|
|
|
|
2020-08-31 16:53:33 +03:00
|
|
|
#### authors
|
2020-07-21 15:59:40 +03:00
|
|
|
|
2020-08-31 16:53:33 +03:00
|
|
|
**Optional** _List of contacts_: The name(s) and contact info(s) of the
|
|
|
|
author(s) of this library.
|
2020-05-13 19:27:16 +03:00
|
|
|
|
2020-08-31 16:53:33 +03:00
|
|
|
A contact is of the form:
|
2020-07-21 15:59:40 +03:00
|
|
|
|
2020-08-31 16:53:33 +03:00
|
|
|
```yaml
|
|
|
|
name: Contact Name
|
|
|
|
email: email@example.com
|
|
|
|
```
|
|
|
|
|
|
|
|
Both `name` and `email` fields are optional, but at least one of them has to be
|
|
|
|
present.
|
|
|
|
|
|
|
|
#### maintainers
|
|
|
|
|
|
|
|
**Optional** _List of contacts_: The name(s) and contact info(s) of the current
|
|
|
|
maintainer(s) of this library, in the same format as `authors` above.
|
2020-05-13 19:27:16 +03:00
|
|
|
|
2020-05-20 18:05:22 +03:00
|
|
|
#### resolver
|
2020-07-21 15:59:40 +03:00
|
|
|
|
|
|
|
**Note** This field is not currently implemented. **Optional (required for
|
|
|
|
publishing)** _String_: The resolver name, used to choose compiler version and
|
|
|
|
basic libraries set. If not set, the system-default resolver will be used.
|
2020-05-13 19:27:16 +03:00
|
|
|
|
|
|
|
> The actionables for this section are:
|
|
|
|
>
|
|
|
|
> - Extend the compiler version to handle version bounds.
|
|
|
|
|
2020-05-20 18:05:22 +03:00
|
|
|
#### extra-dependencies
|
2020-07-21 15:59:40 +03:00
|
|
|
|
|
|
|
**Note** This field is not currently implemented. **Optional** _List of Library
|
|
|
|
objects_: The list of libraries this package requires to function properly and
|
|
|
|
that are not included in the resolver. Defaults to an empty list.
|
2020-05-20 18:05:22 +03:00
|
|
|
|
2020-05-13 19:27:16 +03:00
|
|
|
A library object is of the form:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
name: <name of the library>
|
|
|
|
version: <semver string of the required library version>
|
|
|
|
```
|
|
|
|
|
|
|
|
> The actionables for this section are:
|
|
|
|
>
|
|
|
|
> - Extend the library version field to handle version bounds.
|
2020-05-15 13:41:26 +03:00
|
|
|
|
2020-08-18 18:04:53 +03:00
|
|
|
### The `visualization` Directory
|
|
|
|
|
|
|
|
As Enso is a visual language, a package may contain a specification of how data
|
|
|
|
can be displayed in various tools, for example
|
|
|
|
[Enso IDE](https://github.com/enso-org/ide). The Enso package structure may
|
|
|
|
optionally contain a `visualization` directory which may contain visualization
|
|
|
|
definitions.
|
|
|
|
|
|
|
|
For more information on how visualization definitions should work with the Enso
|
|
|
|
IDE, see
|
|
|
|
[this example](https://dev.enso.org/docs/ide/product/visualizations.html#custom-visualization-example).
|
|
|
|
|
2020-05-15 13:41:26 +03:00
|
|
|
## Build Reproducibility
|
2020-07-21 15:59:40 +03:00
|
|
|
|
2020-05-15 13:41:26 +03:00
|
|
|
It is crucial for any good development environment to provide reproducible
|
|
|
|
builds, such that it is impossible for it to go wrong by mismatching library
|
|
|
|
versions.
|
|
|
|
|
|
|
|
> The actionables for this section are:
|
2020-07-21 15:59:40 +03:00
|
|
|
>
|
|
|
|
> - Decide on the strategies of ensuring consistent library resolution. This may
|
|
|
|
> include hashing the downloaded versions of libraries and publishing
|
2020-05-15 13:41:26 +03:00
|
|
|
> stack-style resolvers for sets of libraries that are proven to work well
|
|
|
|
> together.
|