From 2586dc50e0bfe7c88d54eaee2c090a2a6188e5c9 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Mon, 7 Oct 2019 08:54:14 -0400 Subject: [PATCH] maybe a typing downgrade is easier other approach fails because we cannot upgrade pytest to fix attrs incompatiblity because pytest has dropped python 2.7 support in 5.x series --- overlays.nix | 26 ++++++++++++++------------ typing.nix | 30 ++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 typing.nix diff --git a/overlays.nix b/overlays.nix index 837bb90..25a69fb 100644 --- a/overlays.nix +++ b/overlays.nix @@ -5,18 +5,20 @@ self: super: { python27 = super.python27.override { packageOverrides = python-self: python-super: { - # A newer version of Hypothesis is required for compatibility with the - # typing module which gets pulled in by some dependency or other. - # - # A bug report filed against nixpkgs - - # https://github.com/NixOS/nixpkgs/issues/70431 - hypothesis = python-super.callPackage ./hypothesis.nix { }; - - # The newer hypothesis requires a newer attrs. - attrs = python-super.callPackage ./attrs.nix { }; - - # The newer hypothesis or attrs breaks the pytest test suite. - pytest = python-super.callPackage ./pytest.nix { }; + # # A newer version of Hypothesis is required for compatibility with the + # # typing module which gets pulled in by some dependency or other. + # # + # # A bug report filed against nixpkgs - + # # https://github.com/NixOS/nixpkgs/issues/70431 + # hypothesis = python-super.callPackage ./hypothesis.nix { }; + + # # The newer hypothesis requires a newer attrs. + # attrs = python-super.callPackage ./attrs.nix { }; + + # # The newer hypothesis or attrs breaks the pytest test suite. + # pytest = python-super.callPackage ./pytest.nix { }; + + typing = python-super.callPackage ./typing.nix { }; # new tahoe-lafs dependency eliot = python-super.callPackage ./eliot.nix { }; diff --git a/typing.nix b/typing.nix new file mode 100644 index 0000000..84c0874 --- /dev/null +++ b/typing.nix @@ -0,0 +1,30 @@ +{ lib, buildPythonPackage, fetchPypi, pythonOlder, isPy3k, isPyPy, python }: + +let + testDir = if isPy3k then "src" else "python2"; + +in buildPythonPackage rec { + pname = "typing"; + version = "3.6.6"; + + src = fetchPypi { + inherit pname version; + sha256 = "sha256:0ba9acs4awx15bf9v3nrs781msbd2nx826906nj6fqks2bvca9s0"; + }; + + # Error for Python3.6: ImportError: cannot import name 'ann_module' + # See https://github.com/python/typing/pull/280 + # Also, don't bother on PyPy: AssertionError: TypeError not raised + doCheck = pythonOlder "3.6" && !isPyPy; + + checkPhase = '' + cd ${testDir} + ${python.interpreter} -m unittest discover + ''; + + meta = with lib; { + description = "Backport of typing module to Python versions older than 3.5"; + homepage = https://docs.python.org/3/library/typing.html; + license = licenses.psfl; + }; +} -- GitLab