gphotos-sync: 2.14.2 -> 3.04

This commit is contained in:
David Reiss 2022-06-05 16:21:01 -07:00 committed by Robert Schütz
parent 39dff39cf3
commit c9ba04ce8c
2 changed files with 65 additions and 18 deletions

View File

@ -1,54 +1,80 @@
{ lib
, fetchFromGitHub
, python3Packages
, fetchpatch
, python3
, ffmpeg
}:
python3Packages.buildPythonApplication rec {
let
py = python3.override {
packageOverrides = self: super: {
google-auth-oauthlib = super.google-auth-oauthlib.overridePythonAttrs (oldAttrs: rec {
version = "0.5.2b1";
src = fetchFromGitHub {
owner = "gilesknap";
repo = "google-auth-library-python-oauthlib";
rev = "v${version}";
hash = "sha256-o4Jakm/JgLszumrSoTTnU+nc79Ei70abjpmn614qGyc=";
};
});
};
};
in
py.pkgs.buildPythonApplication rec {
pname = "gphotos-sync";
version = "2.14.2";
version = "3.04";
format = "pyproject";
SETUPTOOLS_SCM_PRETEND_VERSION = version;
src = fetchFromGitHub {
owner = "gilesknap";
repo = "gphotos-sync";
rev = version;
sha256 = "0cfmbrdy6w18hb623rjn0a4hnn3n63jw2jlmgn4a2k1sjqhpx3bf";
sha256 = "0mnlnqmlh3n1b6fjwpx2byl1z41vgghjb95598kz5gvdi95iirrs";
};
propagatedBuildInputs = with python3Packages; [
patches = [
./skip-network-tests.patch
];
propagatedBuildInputs = with py.pkgs; [
appdirs
attrs
exif
google-auth-oauthlib
psutil
pyyaml
requests-oauthlib
types-pyyaml
types-requests
];
postPatch = ''
# this is a patched release that we include via packageOverrides above
substituteInPlace setup.cfg \
--replace " @ https://github.com/gilesknap/google-auth-library-python-oauthlib/archive/refs/tags/v0.5.2b1.zip" ""
'';
buildInputs = [
ffmpeg
];
checkInputs = with python3Packages; [
pytestCheckHook
checkInputs = with py.pkgs; [
mock
pytestCheckHook
setuptools-scm
];
checkPhase = ''
preCheck = ''
export HOME=$(mktemp -d)
# patch to skip all tests that do network access
cat >>test/test_setup.py <<EOF
import pytest, requests
requests.Session.__init__ = lambda *args, **kwargs: pytest.skip("no network access")
EOF
pytestCheckPhase
substituteInPlace setup.cfg \
--replace "--cov=gphotos_sync --cov-report term --cov-report xml:cov.xml" ""
'';
meta = with lib; {
description = "Google Photos and Albums backup with Google Photos Library API";
homepage = "https://github.com/gilesknap/gphotos-sync";
license = licenses.mit;
license = licenses.asl20;
maintainers = with maintainers; [ dnr ];
};
}

View File

@ -0,0 +1,21 @@
diff --git a/tests/test_setup.py b/tests/test_setup.py
index 085b110..ea4a7d2 100644
--- a/tests/test_setup.py
+++ b/tests/test_setup.py
@@ -45,7 +45,8 @@ class SetupDbAndCredentials:
return self
def __exit__(self, exc_type=None, exc_value=None, traceback=None):
- self.gp.google_photos_down.close()
+ if hasattr(self.gp, 'google_photos_down'):
+ self.gp.google_photos_down.close()
def test_setup(self, test_name, args=None, trash_db=False, trash_files=False):
self.root = Path("/tmp/gpTests/{}".format(test_name))
@@ -76,3 +77,6 @@ class SetupDbAndCredentials:
def test_done(self):
self.gp.data_store.store()
+
+import pytest, requests
+requests.Session.__init__ = lambda *args, **kwargs: pytest.skip("no network access")