Skip to content

Commit 94be816

Browse files
committed
Adding setuptools_scm section to knowledge base
1 parent a659797 commit 94be816

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

src/maintainer/knowledge_base.rst

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ shouldn't be, because some packages built with mpi don't preclude other packages
467467
from using the no-mpi variant of the library (e.g. for a long time, fenics used mpi with no-mpi hdf5 since there was no
468468
parallel hdf5 yet. This works fine, though some features may not be available).
469469

470-
Typically, if there is a preference it will be for the serial build, such that installers/requirers of the package
470+
Typically, if there is a preference it will be for the serial build, such that installers/requirers of the package
471471
only get the mpi build if explicitly requested. We use a higher build number for the ``nompi`` variant in this case.
472472

473473
Here is an example build section:
@@ -1050,6 +1050,51 @@ To skip the pypy builds, do the following,
10501050
skip: True # [python_impl == 'pypy']
10511051
10521052
1053+
Using setuptools_scm
1054+
====================
1055+
1056+
The Python module `setuptools_scm <https://github.com/pypa/setuptools_scm>`_
1057+
can be used to manage a package's version automatically from metadata, such as git tags.
1058+
The package's version string is thus not specified anywhere in the package,
1059+
but encoded in it at install-time.
1060+
1061+
For conda-build this warrants some attention because the metadata is often not available.
1062+
The are two options to proceed:
1063+
1064+
* For Python package also available on PyPi:
1065+
Use the PyPi tarball as a source, as it will have the metadata encoded
1066+
(in such a way that ``setuptools_scm`` knows how to find it).
1067+
1068+
* Specify the environment variable ``SETUPTOOLS_SCM_PRETEND_VERSION`` with the version string.
1069+
If specified this environment variable is the principle source for ``setuptools_scm``.
1070+
There are two ways how to do this:
1071+
1072+
- If you are using build scripts, in ``build.sh`` specify:
1073+
1074+
.. code-block:: bash
1075+
1076+
export SETUPTOOLS_SCM_PRETEND_VERSION="$PKG_VERSION"
1077+
1078+
and in ``bld.bat`` specify:
1079+
1080+
.. code-block:: bash
1081+
1082+
set SETUPTOOLS_SCM_PRETEND_VERSION=%PKG_VERSION%
1083+
1084+
Whereby you use that ``PKG_VERSION`` has been set with the version string,
1085+
see `Environment variables <https://docs.conda.io/projects/conda-build/en/latest/user-guide/environment-variables.html#env-vars>`_.
1086+
1087+
- Otherwise, if you are directly building from ``meta.yaml``, use for example:
1088+
1089+
.. code-block:: yaml
1090+
1091+
build:
1092+
# [...]
1093+
script:
1094+
- export SETUPTOOLS_SCM_PRETEND_VERSION="{{ version }}" # [unix]
1095+
- set SETUPTOOLS_SCM_PRETEND_VERSION="{{ version }}" # [win]
1096+
- "{{ PYTHON }} -m pip install . -vv"
1097+
10531098
.. _centos7:
10541099

10551100
Using CentOS 7

0 commit comments

Comments
 (0)