summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMetaDark <kira.bruneau@gmail.com>2020-06-06 18:06:28 -0400
committerJon <jonringer@users.noreply.github.com>2020-07-03 12:15:09 -0700
commita408cd9e7ca97fed8fd2acd73d3082806bb73397 (patch)
treee9ea0088db325e6b21b7be27b18a5d2a38e76270
parente932a720893afb61bf320e7bf23f79e6e5ee3472 (diff)
pythonPackages.debugpy: init at 1.0.0b12
-rw-r--r--pkgs/development/python-modules/debugpy/default.nix68
-rw-r--r--pkgs/development/python-modules/debugpy/fix-test-pythonpath.patch12
-rw-r--r--pkgs/development/python-modules/debugpy/hardcode-gdb.patch13
-rw-r--r--pkgs/top-level/python-packages.nix4
4 files changed, 97 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/debugpy/default.nix b/pkgs/development/python-modules/debugpy/default.nix
new file mode 100644
index 000000000000..2d11dee64a8b
--- /dev/null
+++ b/pkgs/development/python-modules/debugpy/default.nix
@@ -0,0 +1,68 @@
+{ stdenv, buildPythonPackage, fetchFromGitHub
+, substituteAll, gdb
+, colorama, django, flask, gevent, psutil, pytest
+, pytest-timeout, pytest_xdist, requests
+, isPy27
+}:
+
+buildPythonPackage rec {
+ pname = "debugpy";
+ version = "1.0.0b12";
+
+ src = fetchFromGitHub {
+ owner = "Microsoft";
+ repo = pname;
+ rev = "v${version}";
+ sha256 = "0sz33aq5qldl7kh4qjf5w3d08l9s77ipcj4i9wfklj8f6vf9w1wh";
+ };
+
+ patches = [
+ # Hard code GDB path (used to attach to process)
+ (substituteAll {
+ src = ./hardcode-gdb.patch;
+ inherit gdb;
+ })
+
+ # Fix importing debugpy in:
+ # - test_nodebug[module-launch(externalTerminal)]
+ # - test_nodebug[module-launch(integratedTerminal)]
+ #
+ # NOTE: The import failures seen in these tests without the patch
+ # will be seen if a user "installs" debugpy by adding it to PYTHONPATH.
+ # To avoid this issue, debugpy should be installed using python.withPackages:
+ # python.withPackages (ps: with ps; [ debugpy ])
+ ./fix-test-pythonpath.patch
+ ];
+
+ # Remove pre-compiled "attach" libraries and recompile for host platform
+ # Compile flags taken from linux_and_mac/compile_linux.sh & linux_and_mac/compile_mac.sh
+ preBuild = ''(
+ set -x
+ cd src/debugpy/_vendored/pydevd/pydevd_attach_to_process
+ rm *.so *.dylib *.dll *.exe *.pdb
+ ${stdenv.cc}/bin/c++ linux_and_mac/attach.cpp -Ilinux_and_mac -fPIC -nostartfiles ${{
+ "x86_64-linux" = "-shared -m64 -o attach_linux_amd64.so";
+ "i686-linux" = "-shared -m32 -o attach_linux_x86.so";
+ "x86_64-darwin" = "-std=c++11 -lc -D_REENTRANT -dynamiclib -arch x86_64 -o attach_x86_64.dylib";
+ "i686-darwin" = "-std=c++11 -lc -D_REENTRANT -dynamiclib -arch i386 -o attach_x86.dylib";
+ }.${stdenv.hostPlatform.system}}
+ )'';
+
+ checkInputs = [
+ colorama django flask gevent psutil pytest
+ pytest-timeout pytest_xdist requests
+ ];
+
+ # Override default arguments in pytest.ini
+ checkPhase = "pytest --timeout 0 -n $NIX_BUILD_CORES"
+ # gevent fails to import zope.interface with Python 2.7
+ + stdenv.lib.optionalString isPy27 " -k 'not test_gevent'";
+
+ meta = with stdenv.lib; {
+ description = "An implementation of the Debug Adapter Protocol for Python";
+ homepage = "https://github.com/microsoft/debugpy";
+ license = licenses.mit;
+ maintainers = with maintainers; [ metadark ];
+ platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "i686-darwin" ];
+ };
+}
diff --git a/pkgs/development/python-modules/debugpy/fix-test-pythonpath.patch b/pkgs/development/python-modules/debugpy/fix-test-pythonpath.patch
new file mode 100644
index 000000000000..751351e03cde
--- /dev/null
+++ b/pkgs/development/python-modules/debugpy/fix-test-pythonpath.patch
@@ -0,0 +1,12 @@
+diff --git a/tests/debug/session.py b/tests/debug/session.py
+index 2b39106..6d45a10 100644
+--- a/tests/debug/session.py
++++ b/tests/debug/session.py
+@@ -625,6 +625,7 @@ class Session(object):
+ if "PYTHONPATH" in self.config.env:
+ # If specified, launcher will use it in lieu of PYTHONPATH it inherited
+ # from the adapter when spawning debuggee, so we need to adjust again.
++ self.config.env.prepend_to("PYTHONPATH", os.environ["PYTHONPATH"])
+ self.config.env.prepend_to("PYTHONPATH", DEBUGGEE_PYTHONPATH.strpath)
+ return self._request_start("launch")
+
diff --git a/pkgs/development/python-modules/debugpy/hardcode-gdb.patch b/pkgs/development/python-modules/debugpy/hardcode-gdb.patch
new file mode 100644
index 000000000000..780cb1aed1c4
--- /dev/null
+++ b/pkgs/development/python-modules/debugpy/hardcode-gdb.patch
@@ -0,0 +1,13 @@
+diff --git a/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py b/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py
+index 6d031b4..ecf21f2 100644
+--- a/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py
++++ b/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py
+@@ -293,7 +293,7 @@ def run_python_code_linux(pid, python_code, connect_debugger_tracing=False, show
+ is_debug = 0
+ # Note that the space in the beginning of each line in the multi-line is important!
+ cmd = [
+- 'gdb',
++ '@gdb@/bin/gdb',
+ '--nw', # no gui interface
+ '--nh', # no ~/.gdbinit
+ '--nx', # no .gdbinit
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index b2b3f85e7160..c86fbf6bde13 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -2718,6 +2718,10 @@ in {
# Alias that we should deprecate
dateutil = self.python-dateutil;
+ debugpy = callPackage ../development/python-modules/debugpy {
+ django = if isPy27 then self.django_1_11 else self.django;
+ };
+
decorator = callPackage ../development/python-modules/decorator { };
deform = callPackage ../development/python-modules/deform { };