1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 hatchling,
7 fasteners,
8 libcloud,
9 pillow,
10 pytestCheckHook,
11 sqlalchemy,
12 sqlmodel,
13}:
14
15buildPythonPackage rec {
16 pname = "sqlalchemy-file";
17 version = "0.6.0";
18 pyproject = true;
19
20 src = fetchFromGitHub {
21 owner = "jowilf";
22 repo = "sqlalchemy-file";
23 rev = version;
24 hash = "sha256-gtW7YA/rQ48tnqPdypMnSqqtwb90nhAkiQNhgEr1M3I=";
25 };
26
27 build-system = [ hatchling ];
28
29 dependencies = [
30 libcloud
31 sqlalchemy
32 ];
33
34 nativeCheckInputs = [
35 pytestCheckHook
36 fasteners
37 pillow
38 sqlmodel
39 ];
40
41 preCheck = ''
42 # used in get_test_container in tests/utils.py
43 # fixes FileNotFoundError: [Errno 2] No such file or directory: '/tmp/storage/...'
44 mkdir .storage
45 export LOCAL_PATH="$PWD/.storage"
46 '';
47
48 disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [
49 # very flaky, sandbox issues?
50 # libcloud.storage.types.ContainerDoesNotExistError
51 # sqlite3.OperationalError: attempt to write a readonly database
52 "tests/test_content_type_validator.py"
53 "tests/test_image_field.py"
54 "tests/test_image_validator.py"
55 "tests/test_metadata.py"
56 "tests/test_multiple_field.py"
57 "tests/test_multiple_storage.py"
58 "tests/test_processor.py"
59 "tests/test_single_field.py"
60 "tests/test_size_validator.py"
61 "tests/test_sqlmodel.py"
62 ];
63
64 pythonImportsCheck = [
65 "sqlalchemy_file"
66 "sqlalchemy_file.file"
67 "sqlalchemy_file.types"
68 "sqlalchemy_file.helpers"
69 ];
70
71 meta = with lib; {
72 description = "SQLAlchemy extension for attaching files to SQLAlchemy model and uploading them to various storage with Apache Libcloud";
73 homepage = "https://github.com/jowilf/sqlalchemy-file";
74 changelog = "https://github.com/jowilf/sqlalchemy-file/blob/${src.rev}/CHANGELOG.md";
75 license = licenses.mit;
76 maintainers = with maintainers; [ pbsds ];
77 };
78}