question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add parameter to ignore collisions possible ?

See original GitHub issue

Hi,

this project is amazing, thanks for sharing it.

I wonder if I could add nix packages (pyls-mypy and sorts) when they cause collisions as in

collision between /nix/store/y04m7z8k5p2d725v4csw32md7w64j4h9-python3-3.7.6-env/bin/.chardetect-wrapped' and /nix/store/2ry9dqdgjzy8p699ri0sp1rq86bvmdah-python3-3.7.7-env/bin/.chardetect-wrapped’

I hoped something along the lines (snippet incomplete) of

let
  myMachnix =
    let
      mach-nix = import (builtins.fetchGit {
        url = "https://github.com/DavHau/mach-nix/";
        ref = "2.0.0";
      });
    in
    mach-nix.mkPython {
      disable_checks = true;
      requirements = ''
        notebook
        pandas
        numpy

        dropbox
        lockfile

        curlify
        openpyxl
        xlrd
        tqdm
        requests

        cython >= 0.23.5
        bokeh == 0.12.7
        flexx == 0.4.1
        normality == 0.6.1
        dataset == 0.8.0
        tornado
      '';
    };
  in
  {
    home.packages = with pkgs; [
      ((python3.withPackages (pkgs: with pkgs; [
        # for emacs, also https://nixos.wiki/wiki/Vim#Vim_as_a_Python_IDE
        python-language-server
        # the following plugins are optional, they provide type checking, import sorting and code formatting
        pyls-mypy # sind in nixpkgs, nicht in pypi
        pyls-isort
        pyls-black
      ])).override (args: { ignoreCollisions = true; })) # doesn't ignore collisions with mach-nix env though
      myMachnix
    ];
  }

would do. But it seems I had to add the override to myMachnix as well. I just don’t know how to do that.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
DavHaucommented, Jun 10, 2020

OK, I think I get the problem now. You are trying to mix two different python environments. The ignoreColisions only applies to each of the environments individually, but not for the combination of both. I guess the way you try to mix environments doesn’t work in general. But there are other ways to do it.

First of all, it is not really necessary to manually mix python packages from nixpkgs into mach-nix. All python packages from nixpkgs are available to mach-nix already, just put them into the requirements of mach-nix like this: (note: python-jsonrpc-server causes some strange bug which is fixed by switching the provider)

let
  pkgs = import <unstable>;
  myMachnix =
    let
      mach-nix = import (builtins.fetchGit {
        url = "https://github.com/DavHau/mach-nix/";
        ref = "2.0.0";
      });
    in
    mach-nix.mkPython {
      disable_checks = true;
      requirements = ''
        notebook
        pyls-mypy
        pyls-isort
        pyls-black
      '';
      providers = {
        # python-jsonrpc-server seems to cause a strange bug when installing from pypi.
        # We change its provider to nixpkgs
        python-jsonrpc-server = "nixpkgs";
      };
    };
in
myMachnix


If you really need to mix two environments, then you could use the lower level mach nix function machnix.machNix to generate pythonOverrides and a package selector for the mach-nix part, and then mix this together with some packages you take from nixpkgs: (I don’t really like this interface yet and will probably change it in an upcoming release)

let
  pkgs = import <unstable> {};
  machnix_src = builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "2.0.0";
  };
  machnix = import machnix_src;
  autoPatchelfHook = import "${machnix_src}/mach_nix/nix/auto_patchelf_hook.nix" {inherit (pkgs) fetchurl makeSetupHook writeText;};
  result = machnix.machNix {
    requirements = ''
      notebook
    '';
    python = pkgs.python3;
  };
  overrides_machnix = result.overrides pkgs.pythonManylinuxPackages.manylinux1 pkgs.autoPatchelfHook;
  my_python = pkgs.python3.override {
    packageOverrides = overrides_machnix;
  };
in
my_python.withPackages (ps: with ps; (result.select_pkgs ps) ++ [
  python-language-server
  pyls-mypy
  pyls-isort
  pyls-black
])

EDIT: Another bug prevents prevents this from working: https://github.com/DavHau/mach-nix/issues/27

0reactions
573commented, Jun 15, 2020

I think I got your example now:

{ # `git ls-remote https://github.com/nixos/nixpkgs-channels nixos-unstable`
  nixpkgs-rev ? "ddf87fb1baf8f5022281dad13fb318fa5c17a7c6"
, pkgsPath ? builtins.fetchTarball {
    name = "nixpkgs-${nixpkgs-rev}";
    url = "https://github.com/nixos/nixpkgs/archive/${nixpkgs-rev}.tar.gz";
  }
  , pkgs ? import pkgsPath {}
  , ...
}:
with import <nixpkgs>{};
let
  myMachnix =
    let
      mach-nix = import (builtins.fetchGit {
        url = "https://github.com/DavHau/mach-nix/";
        ref = "2.0.0";
      });
    in
    mach-nix.mkPython {
      disable_checks = true;
      requirements = ''
        cffi
        aiohttp
        notebook
        # ... all my other reqs.

        # for emacs, also https://nixos.wiki/wiki/Vim#Vim_as_a_Python_IDE
        python-language-server

        # https://github.com/DavHau/mach-nix/issues/24
        pyls-mypy
        pyls-isort
        pyls-black
      '';
      providers = {
        # python-jsonrpc-server seems to cause a strange bug when installing from pypi.
        # We change its provider to nixpkgs
        python-jsonrpc-server = "nixpkgs";
      };
    };
    aiohttp = pkgs.python3Packages.aiohttp.overridePythonAttrs {
      doCheck = false;
      doInstallCheck = false;
    };
    cffi = pkgs.python3Packages.cffi.overridePythonAttrs {
      doCheck = false;
      doInstallCheck = false;
    };
  in
  {
    home.packages = with pkgs; [
      (myMachnix.override (args: {
        # see https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/interpreters/python/wrapper.nix
        ignoreCollisions = true;
        }))
    ];
}

is working no problems.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scripting API: Physics.IgnoreCollision - Unity - Manual
If ignore is false, collisions can occur. Set ignore to true to ignore collisions. See Also: Physics.IgnoreLayerCollision. using UnityEngine; using System.
Read more >
How do i get some objects to ignore collision with a specific ...
Then you can either set the collision matrix in: Edit > Projects Settings > Physics2D. Or you can use Physics2D.IgnoreLayerCollision().
Read more >
How To Ignore Collision Between Two Objects On The Call Of ...
Now i go to: Edit > Project Settings > Physics Here i can check the box which will turn off collisions between my...
Read more >
HANDLECOLLISIONS | NOHANDLECOLLISIONS
Use the HANDLECOLLISIONS and NOHANDLECOLLISIONS parameters to control whether or not Replicat tries to resolve duplicate-record and missing-record errors when ...
Read more >
Oracle GoldenGate: Handle Collision Parameter and its usage
The HANDLECOLLISIONS parameter is used to overcome these collisions. There are 3 types of Collisions: Insert Collision – When a row is inserted ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found