Skip to content

Commit

Permalink
add Rust package guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhall88 committed Sep 30, 2024
1 parent 1dca66f commit 9241917
Showing 1 changed file with 76 additions and 0 deletions.
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,
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
specify the path to the package source code (usually the current directory ``.``).

.. |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

0 comments on commit 9241917

Please sign in to comment.