Skip to content

Commit a7ac947

Browse files
authored
Merge pull request #1274 from tdegeus/setuptools_scm
Adding setuptools_scm section to knowledge base
2 parents a659797 + 5c2bf0e commit a7ac947

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 means that ``setuptools_scm`` must be included as a ``host`` dependency.
1062+
Additionally, some attention because the metadata is often not available in the sources.
1063+
There are two options for how to proceed:
1064+
1065+
* For Python package also available on PyPI:
1066+
Use the PyPi tarball as a source, as it will have the metadata encoded
1067+
(in such a way that ``setuptools_scm`` knows how to find it).
1068+
1069+
* Specify the environment variable ``SETUPTOOLS_SCM_PRETEND_VERSION`` with the version string.
1070+
If specified this environment variable is the principle source for ``setuptools_scm``.
1071+
There are two ways how to do this:
1072+
1073+
- If you are using build scripts, in ``build.sh`` specify:
1074+
1075+
.. code-block:: bash
1076+
1077+
export SETUPTOOLS_SCM_PRETEND_VERSION="$PKG_VERSION"
1078+
1079+
and in ``bld.bat`` specify:
1080+
1081+
.. code-block:: bash
1082+
1083+
set SETUPTOOLS_SCM_PRETEND_VERSION=%PKG_VERSION%
1084+
1085+
Whereby you use that ``PKG_VERSION`` has been set with the version string,
1086+
see `Environment variables <https://docs.conda.io/projects/conda-build/en/latest/user-guide/environment-variables.html#env-vars>`_.
1087+
1088+
- Otherwise, if you are directly building from ``meta.yaml``, use for example:
1089+
1090+
.. code-block:: yaml
1091+
1092+
build:
1093+
# [...]
1094+
script_env:
1095+
- SETUPTOOLS_SCM_PRETEND_VERSION={{version}}
1096+
script: "{{ PYTHON }} -m pip install . -vv"
1097+
10531098
.. _centos7:
10541099

10551100
Using CentOS 7

0 commit comments

Comments
 (0)