Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Rust package guidelines #33

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions _sources/contributor/guidelines.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ are necessary to satisfy bioconda policies:
- the ``requirements/build`` keyword in ``meta.yaml`` should be changed to
``requirements/host``

.. _c-cpp:

C/C++
-----

Expand Down Expand Up @@ -481,6 +483,80 @@ some ideas on what to try:
<https://github.com/bioconda/bioconda-recipes/tree/master/recipes/soapdenovo>`_
have many fixes to makefiles

Rust
----

The Rust compiler is included with the special macro ``{{ compiler('rust') }}``. In addition,
if your package relies on the C/C++ compilers, either directly, or indirectly through
building dependencies, use the :ref:`macros for those compilers <c-cpp>` too.

Keeping in line with `conda-forge policies <https://conda-forge.org/docs/maintainer/adding_pkgs/#licenses-of-included-dependencies>`_,
all (Rust) dependencies of your package should have their license included in the package.
This can be done by including, and using, |cargo-bundle-licenses|_ in the build process.
However, make sure to include the license files in the package (see below).

.. |cargo-bundle-licenses| replace:: ``cargo-bundle-licenses``
.. _cargo-bundle-licenses: https://github.com/sstadick/cargo-bundle-licenses

Lastly, there are some Cargo flags that are recommended for making the build process
as reproducible as possible across different systems. |locked|_ ensures the builds is
deterministic by asserting that the exact same dependencies and versions are used as in
the ``Cargo.lock`` file. |no-track|_ to prevent Cargo from tracking the installed binaries,
mbhall88 marked this conversation as resolved.
Show resolved Hide resolved
ensuring a clean and reproducible build environment for the package. ``--root $PREFIX``
to install the package into the correct place in the Conda environment. ``--path`` to
mbhall88 marked this conversation as resolved.
Show resolved Hide resolved
specify the path to the package source code (usually the current directory ``.``).
mbhall88 marked this conversation as resolved.
Show resolved Hide resolved

.. |locked| replace:: ``--locked``
.. _locked: https://doc.rust-lang.org/cargo/commands/cargo-install.html#manifest-options
.. |no-track| replace:: ``--no-track``
.. _no-track: https://doc.rust-lang.org/cargo/commands/cargo-install.html#install-options

Wrapping it all up, a typical Rust recipe would look like this:

.. code-block:: yaml

{% set version = "0.1.0" %}
{% set name = "mypackage" %}

package:
name: {{ name }}
version: {{ version }}

source:
url: https://github.com/USERNAME/{{ name }}/archive/{{ version }}.tar.gz
sha256: 1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef

build:
number: 0
run_exports:
- {{ pin_subpackage('mypackage', max_pin="x.x") }}
script:
- cargo-bundle-licenses --format yaml --output THIRDPARTY.yml
- cargo install -v --locked --no-track --root $PREFIX --path .

requirements:
build:
- {{ compiler('rust') }}
- cargo-bundle-licenses
# - {{ compiler('c') }} add these C/C++ compilers if needed
# - {{ compiler('cxx') }}

test:
commands:
- mypackage --version

about:
home: https://example.com
license: MIT
license_file:
- LICENSE # the license file for your package
- THIRDPARTY.yml # this file is generated by cargo-bundle-licenses
summary: A Rust package

extra:
recipe-maintainers:
- @username # your GitHub username

Haskell
-------

Expand Down