Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5a67b130b9b4
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 21f6cb79a708
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jan 2, 2017

  1. Python: script names now include full path

    Certain programs, like zim, calibre and now also apparently mercurial,
    rely on sys.argv[0] providing not just the script name but the full
    path.
    
    The Python docs [1] state the following on the matter:
    
    > argv[0] is the script name (it is operating system dependent whether
    this is a full pathname or not).
    
    Therefore, scripts should not expect to receive a full path.
    Unfortunately some do. While this can be considered a bug, there doesn't
    seem any reason not to provide the full path. Therefore we now provide
    the full path.
    
    [1]
    https://docs.python.org/3.5/library/sys.html?highlight=sys.argv#sys.argv
    FRidh committed Jan 2, 2017

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    grahamc Graham Christensen
    Copy the full SHA
    d68aba4 View commit details
  2. zim: remove postFixup, include checkPhase, disable tests

    - wrap-python.nix used to set sys.argv[0] to the name of the script, but
    it now sets the path so we won't have to do it here anymore
    - tests were not found, so the correct file is now invoked
    FRidh committed Jan 2, 2017
    Copy the full SHA
    21f6cb7 View commit details
Showing with 6 additions and 5 deletions.
  1. +5 −4 pkgs/applications/office/zim/default.nix
  2. +1 −1 pkgs/development/interpreters/python/wrap-python.nix
9 changes: 5 additions & 4 deletions pkgs/applications/office/zim/default.nix
Original file line number Diff line number Diff line change
@@ -30,12 +30,13 @@ pythonPackages.buildPythonApplication rec {
export makeWrapperArgs="--prefix XDG_DATA_DIRS : $out/share --argv0 $out/bin/.zim-wrapped"
'';

postFixup = ''
substituteInPlace $out/bin/.zim-wrapped \
--replace "sys.argv[0] = 'zim'" "sys.argv[0] = '$out/bin/zim'"
# RuntimeError: could not create GtkClipboard object
doCheck = false;

checkPhase = ''
python test.py
'';

doCheck = true;

meta = {
description = "A desktop wiki";
2 changes: 1 addition & 1 deletion pkgs/development/interpreters/python/wrap-python.nix
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ makeSetupHook {
import sys
import site
import functools
sys.argv[0] = '"'$(basename "$f")'"'
sys.argv[0] = '"'$(readlink -f "$f")'"'
functools.reduce(lambda k, p: site.addsitedir(p, k), ['"$([ -n "$program_PYTHONPATH" ] && (echo "'$program_PYTHONPATH'" | sed "s|:|','|g") || true)"'], site._init_pathinfo())
'';