1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, fetchpatch
6, python
7, scripttest
8, pytz
9, pbr
10, tempita
11, decorator
12, sqlalchemy
13, six
14, sqlparse
15, testrepository
16}:
17
18buildPythonPackage rec {
19 pname = "sqlalchemy-migrate";
20 version = "0.13.0";
21
22 src = fetchPypi {
23 inherit pname version;
24 sha256 = "1y0lcqii7b4vp7yh9dyxrl4i77hi8jkkw7d06mgdw2h458ljxh0b";
25 };
26
27 patches = [
28 # See: https://review.openstack.org/#/c/608382/
29 # https://github.com/openstack/sqlalchemy-migrate/pull/18
30 (fetchpatch {
31 url = "https://github.com/openstack/sqlalchemy-migrate/commit/a5d69a17d9354ec1a792493280f96484740cf7ff.patch";
32 sha256 = "1qyfq2m7w7xqf0r9bc2x42qcra4r9k9l9g1jy5j0fvlb6bvvjj07";
33 })
34 ./python3.11-comp.diff
35 ];
36
37 postPatch = ''
38 substituteInPlace test-requirements.txt \
39 --replace "ibm_db_sa>=0.3.0;python_version<'3.0'" "" \
40 --replace "ibm-db-sa-py3;python_version>='3.0'" "" \
41 --replace "tempest-lib>=0.1.0" "" \
42 --replace "testtools>=0.9.34,<0.9.36" "" \
43 --replace "pylint" ""
44 '';
45
46 nativeCheckInputs = [ scripttest pytz testrepository ];
47 propagatedBuildInputs = [ pbr tempita decorator sqlalchemy six sqlparse ];
48
49 doCheck = !stdenv.isDarwin;
50
51 checkPhase = ''
52 export PATH=$PATH:$out/bin
53 echo sqlite:///__tmp__ > test_db.cfg
54 # depends on ibm_db_sa
55 rm migrate/tests/changeset/databases/test_ibmdb2.py
56 # wants very old testtools
57 rm migrate/tests/versioning/test_schema.py
58 # transient failures on py27
59 substituteInPlace migrate/tests/versioning/test_util.py --replace "test_load_model" "noop"
60 ${python.interpreter} setup.py test
61 '';
62
63 meta = with lib; {
64 homepage = "https://opendev.org/x/sqlalchemy-migrate";
65 description = "Schema migration tools for SQLAlchemy";
66 license = licenses.asl20;
67 maintainers = teams.openstack.members ++ (with maintainers; [ makefu ]);
68 broken = lib.versionAtLeast sqlalchemy.version "2.0.0";
69 };
70}