Unverified Commit c010fc92 authored by Vladimír Čunát's avatar Vladimír Čunát
Browse files

Merge branch 'staging-next' into staging

parents c4e435ef 0dbfd0e7
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -605,7 +605,7 @@ All parameters from `stdenv.mkDerivation` function are still supported. The foll
* `disabled` ? false: If `true`, package is not build for the particular Python interpreter version.
* `dontWrapPythonPrograms ? false`: Skip wrapping of python programs.
* `installFlags ? []`: A list of strings. Arguments to be passed to `pip install`. To pass options to `python setup.py install`, use `--install-option`. E.g., `installFlags=["--install-option='--cpp_implementation'"]`.
* `format ? "setuptools"`: Format of the source. Valid options are `"setuptools"`, `"flit"`, `"wheel"`, and `"other"`. `"setuptools"` is for when the source has a `setup.py` and `setuptools` is used to build a wheel, `flit`, in case `flit` should be used to build a wheel, and `wheel` in case a wheel is provided. Use `other` when a custom `buildPhase` and/or `installPhase` is needed.
* `format ? "setuptools"`: Format of the source. Valid options are `"setuptools"`, `"pyproject"`, `"flit"`, `"wheel"`, and `"other"`. `"setuptools"` is for when the source has a `setup.py` and `setuptools` is used to build a wheel, `flit`, in case `flit` should be used to build a wheel, and `wheel` in case a wheel is provided. Use `other` when a custom `buildPhase` and/or `installPhase` is needed.
* `makeWrapperArgs ? []`: A list of strings. Arguments to be passed to `makeWrapper`, which wraps generated binaries. By default, the arguments to `makeWrapper` set `PATH` and `PYTHONPATH` environment variables before calling the binary. Additional arguments here can allow a developer to set environment variables which will be available when the binary is run. For example, `makeWrapperArgs = ["--set FOO BAR" "--set BAZ QUX"]`.
* `namePrefix`: Prepends text to `${name}` parameter. In case of libraries, this defaults to `"python3.5-"` for Python 3.5, etc., and in case of applications to `""`.
* `pythonPath ? []`: List of packages to be added into `$PYTHONPATH`. Packages in `pythonPath` are not propagated (contrary to `propagatedBuildInputs`).
@@ -881,7 +881,6 @@ example of such a situation is when `py.test` is used.
    '';
  }
  ```
- Unicode issues can typically be fixed by including `glibcLocales` in `buildInputs` and exporting `LC_ALL=en_US.utf-8`.
- Tests that attempt to access `$HOME` can be fixed by using the following work-around before running tests (e.g. `preCheck`): `export HOME=$(mktemp -d)`

## FAQ
+7 −1
Original line number Diff line number Diff line
@@ -167,12 +167,18 @@
   </listitem>
   <listitem>
    <para>
      The <varname>buildPythonPackage</varname> now sets <varname>strictDeps = true</varname>
      The <varname>buildPythonPackage</varname> function now sets <varname>strictDeps = true</varname>
      to help distinguish between native and non-native dependencies in order to
      improve cross-compilation compatibility. Note however that this may break
      user expressions.
    </para>
   </listitem>
   <listitem>
    <para>
      The <varname>buildPythonPackage</varname> function now sets <varname>LANG = C.UTF-8</varname>
      to enable Unicode support. The <varname>glibcLocales</varname> package is no longer needed as a build input.
    </para>
   </listitem>
   <listitem>
    <para>
      The Syncthing state and configuration data has been moved from
+53 −0
Original line number Diff line number Diff line
# This function provides specific bits for building a setuptools-based Python package.

{ lib
, python
}:

{
# passed to "python setup.py build_ext"
# https://github.com/pypa/pip/issues/881
# Rename to `buildOptions` because it is not setuptools specific?
  setupPyBuildFlags ? []
# Execute before shell hook
, preShellHook ? ""
# Execute after shell hook
, postShellHook ? ""
, ... } @ attrs:

let
  options = lib.concatMapStringsSep " " (option: "--global-option ${option}") setupPyBuildFlags;
in attrs // {
  buildPhase = attrs.buildPhase or ''
    runHook preBuild
    mkdir -p dist
    echo "Creating a wheel..."
    ${python.pythonForBuild.interpreter} -m pip wheel --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist ${options} .
    echo "Finished creating a wheel..."
    runHook postBuild
  '';

  installCheckPhase = ''
    runHook preCheck
    echo "No checkPhase defined. Either provide a checkPhase or disable tests in case tests are not available."; exit 1
    runHook postCheck
  '';

  # With Python it's a common idiom to run the tests
  # after the software has been installed.
  doCheck = attrs.doCheck or true;

  shellHook = attrs.shellHook or ''
    ${preShellHook}
    # Long-term setup.py should be dropped.
    if [ -e pyproject.toml ]; then
      tmp_path=$(mktemp -d)
      export PATH="$tmp_path/bin:$PATH"
      export PYTHONPATH="$tmp_path/${python.pythonForBuild.sitePackages}:$PYTHONPATH"
      mkdir -p $tmp_path/${python.pythonForBuild.sitePackages}
      ${python.pythonForBuild.pkgs.bootstrapped-pip}/bin/pip install -e . --prefix $tmp_path >&2
    fi
    ${postShellHook}
  '';

}
 No newline at end of file
+3 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

let
  setuptools-specific = import ./build-python-package-setuptools.nix { inherit lib python; };
  pyproject-specific = import ./build-python-package-pyproject.nix { inherit lib python; };
  flit-specific = import ./build-python-package-flit.nix { inherit python flit; };
  wheel-specific = import ./build-python-package-wheel.nix { };
  common = import ./build-python-package-common.nix { inherit python; };
@@ -37,7 +38,8 @@ format ? "setuptools"

let
  formatspecific =
    if format == "setuptools" then common (setuptools-specific attrs)
    if format == "pyproject" then common (pyproject-specific attrs)
    else if format == "setuptools" then common (setuptools-specific attrs)
    else if format == "flit" then common (flit-specific attrs)
    else if format == "wheel" then common (wheel-specific attrs)
    else if format == "other" then {}
+2 −0
Original line number Diff line number Diff line
@@ -90,6 +90,8 @@ let self = toPythonModule (python.stdenv.mkDerivation (builtins.removeAttrs attr
  # Enabled to detect some (native)BuildInputs mistakes
  strictDeps = true;

  LANG = "${if python.stdenv.isDarwin then "en_US" else "C"}.UTF-8";

  # Python packages don't have a checkPhase, only an installCheckPhase
  doCheck = false;
  doInstallCheck = doCheck;
Loading