Unable to get development shell with for a local python package

I am trying to run a shell.nix file very close to the one shown below. I have setup.py file in my python package but even inside nix-shell the live changes in my code are reflected in the my installed version of mypkg. Could someone please help avoid rebuilding and get a development shell for mypkg.

{
  sources ?  import ./nix/sources.nix
, pkgs ?  import sources.nixpkgs { config = { allowUnfree = true; }; }
}:

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "refs/tags/3.1.1";
  }) { pkgs = pkgs; python = "python37"; };

  mypkg = pkgs.python37Packages.buildPythonPackage rec {
    name = "mypkg";
    src = ./.;
    propagatedBuildInputs = [ pythonPkgsWithMach ];
    doCheck = false;
  };

  pythonPkgsWithMach = mach-nix.mkPython rec {
    requirements =  ''
      click
      cython
      pytest
      pytest-runner
      ipython
      numpy
      pandas
      matplotlib
      hvplot
      datashader
      jupyterlab
      scipy
    '';

    providers = {
      click="nixpkgs,wheel";
    };
  };

in

pkgs.stdenv.mkDerivation rec {
  name = "mypkg-dev";
  buildInputs = [
    pythonPkgsWithMach
    mypkg
  ];

  shellHook = ''
    export ENVNAME=${name}
  '';

}

In order to install package in development mode where you edits are directly reflected in the nix-shell environment. Use the following snippet (original link here: https://www.reddit.com/r/NixOS/comments/i16zvd/how_to_make_pycharm_use_nixshell/):

pkgs.mkShell rec {
  name = "56293fb9-mypkg-dev";
  buildInputs = [
    # pythonPkgsWithMach
    pkgs.vscode

    pkgs.python37Packages.virtualenv
    pkgs.python37Packages.pip
    pkgs.python37Packages.setuptools
    pkgs.python37Packages.venvShellHook
  ];

  venvDir = ".venv";

  shellHook = ''
    export ENVNAME="${name}"
    virtualenv --no-setuptools ${venvDir}
    export PATH=$PWD/${venvDir}/bin:$PATH
    export PYTHONPATH=${venvDir}/lib/python3.7/site-packages/:$PYTHONPATH
  '';

  postShellHook = ''
    ln -sf PYTHONPATH/* ${venvDir}/lib/python3.7/site-packages
    # install {{mypkg}} in develop mode
    # python setup.py develop
    pip install -e .
  '';

This also allows you to set python interpreter for vscode (or pycharm if you need) with all the right dependencies. I hope it helps.