1{
2 lib,
3 buildPythonPackage,
4 dnspython,
5 fetchFromGitHub,
6 protobuf,
7 pythonOlder,
8 mysql80,
9 openssl,
10 pkgs,
11}:
12
13buildPythonPackage rec {
14 pname = "mysql-connector";
15 version = "8.0.33";
16 format = "setuptools";
17
18 disabled = pythonOlder "3.7";
19
20 setupPyBuildFlags = [
21 "--with-mysql-capi=${mysql80}"
22 "--with-openssl-include-dir=${openssl.dev}/include"
23 "--with-openssl-lib-dir=${lib.getLib openssl}/lib"
24 "-L"
25 "${lib.getLib pkgs.zstd}/lib:${lib.getLib mysql80}/lib"
26 ];
27
28 src = fetchFromGitHub {
29 owner = "mysql";
30 repo = "mysql-connector-python";
31 rev = version;
32 hash = "sha256-GtMq7E2qBqFu54hjUotzPyxScTKXNdEQcmgHnS7lBhc=";
33 };
34
35 patches = [
36 # mysql-connector overrides MACOSX_DEPLOYMENT_TARGET to 11.
37 # This makes the installation with nixpkgs fail. I suspect, that's
38 # because stdenv.hostPlatform.darwinSdkVersion is (currently) set to
39 # 10.12. The patch reverts
40 # https://github.com/mysql/mysql-connector-python/commit/d1e89fd3d7391084cdf35b0806cb5d2a4b413654
41 ./0001-Revert-Fix-MacOS-wheels-platform-tag.patch
42 ];
43
44 nativeBuildInputs = [ mysql80 ];
45
46 propagatedBuildInputs = [
47 dnspython
48 protobuf
49 mysql80
50 openssl
51 pkgs.zstd
52 ];
53
54 pythonImportsCheck = [ "mysql" ];
55
56 # Tests require a running MySQL instance
57 doCheck = false;
58
59 meta = with lib; {
60 description = "MySQL driver";
61 longDescription = ''
62 A MySQL driver that does not depend on MySQL C client libraries and
63 implements the DB API v2.0 specification.
64 '';
65 homepage = "https://github.com/mysql/mysql-connector-python";
66 changelog = "https://raw.githubusercontent.com/mysql/mysql-connector-python/${version}/CHANGES.txt";
67 license = licenses.gpl2Only;
68 maintainers = with maintainers; [
69 neosimsim
70 ];
71 };
72}