Merge pull request #307098 from r-ryantm/auto-update/cilium-cli
[NixPkgs.git] / pkgs / development / python-modules / setuptools-scm / setup-hook.sh
blobf8c30f91ca07bddce3e562f41c2f368418af6337
1 # Let built package know its version.
2 # Usually, when a package uses setuptools-scm as a build-time dependency, it
3 # expects to get the package version from SCM data. However, while doing a nix
4 # build, the source tree doesn't contain SCM data, so we should almost always
5 # get the version from the derivation attribute.
6 version-pretend-hook() {
7 if [ -z "$dontPretendSetuptoolsSCMVersion" -a -z "$SETUPTOOLS_SCM_PRETEND_VERSION" ]; then
8 echo Setting SETUPTOOLS_SCM_PRETEND_VERSION to $version
9 export SETUPTOOLS_SCM_PRETEND_VERSION="$version"
13 # Include all tracked files.
14 # When a package uses setuptools-scm as a build-time dependency, it usually
15 # expects it to include all scm-tracked files in the built package, by default.
16 # This is the official setuptools-scm behavior, documented in
17 # https://setuptools-scm.readthedocs.io/en/latest/usage/#file-finders-hook-makes-most-of-manifestin-unnecessary
18 # and https://setuptools.pypa.io/en/latest/userguide/datafiles.html.
19 # However, while doing a nix build, the source tree doesn't contain SCM data,
20 # so it would include only `.py` files by default.
21 # We generate a MANIFEST.in automatically that includes all tracked files to
22 # emulate this behavior of setuptools-scm.
23 include-tracked-files-hook() {
24 if [ -z "$dontIncludeSetuptoolsSCMTrackedFiles" ]; then
25 echo Including all tracked files automatically
26 old_manifest="$(if [ -f MANIFEST.in ]; then cat MANIFEST.in; fi)"
27 echo 'global-include **' > MANIFEST.in
28 echo "$old_manifest" >> MANIFEST.in
32 preBuildHooks+=(version-pretend-hook include-tracked-files-hook)