Skip to content

Commit

Permalink
Merge pull request #174000 from mweinelt/pep621-optional-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mweinelt authored May 22, 2022
2 parents f01320c + 272430c commit bc38fca
Show file tree
Hide file tree
Showing 44 changed files with 97 additions and 96 deletions.
7 changes: 4 additions & 3 deletions doc/languages-frameworks/python.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -982,12 +982,13 @@ in python.withPackages(ps: [ps.blaze])).env
#### Optional extra dependencies

Some packages define optional dependencies for additional features. With
`setuptools` this is called `extras_require` and `flit` calls it `extras-require`. A
`setuptools` this is called `extras_require` and `flit` calls it
`extras-require`, while PEP 621 calls these `optional-dependencies`. A
method for supporting this is by declaring the extras of a package in its
`passthru`, e.g. in case of the package `dask`

```nix
passthru.extras-require = {
passthru.optional-dependencies = {
complete = [ distributed ];
};
```
Expand All @@ -997,7 +998,7 @@ and letting the package requiring the extra add the list to its dependencies
```nix
propagatedBuildInputs = [
...
] ++ dask.extras-require.complete;
] ++ dask.optional-dependencies.complete;
```

Note this method is preferred over adding parameters to builders, as that can
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/networking/syncplay/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ buildPythonApplication rec {
};

propagatedBuildInputs = [ twisted certifi ]
++ twisted.extras-require.tls
++ twisted.optional-dependencies.tls
++ lib.optional enableGUI pyside2;
nativeBuildInputs = lib.optionals enableGUI [ qt5.wrapQtAppsHook ];

Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/office/paperless-ngx/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ py.pkgs.pythonPackages.buildPythonApplication rec {
threadpoolctl
tika
tqdm
twisted.extras-require.tls
twisted.optional-dependencies.tls
txaio
tzlocal
urllib3
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/python-modules/Mako/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ buildPythonPackage rec {
markupsafe
];

passthru.extras-require = {
passthru.optional-dependencies = {
babel = [
babel
];
Expand All @@ -39,7 +39,7 @@ buildPythonPackage rec {
checkInputs = [
pytestCheckHook
mock
] ++ passthru.extras-require.babel;
] ++ passthru.optional-dependencies.babel;

disabledTests = lib.optionals isPyPy [
# https://github.com/sqlalchemy/mako/issues/315
Expand Down
6 changes: 3 additions & 3 deletions pkgs/development/python-modules/adb-shell/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ buildPythonPackage rec {
rsa
];

passthru.extras-require = {
passthru.optional-dependencies = {
async = [
aiofiles
];
Expand All @@ -47,8 +47,8 @@ buildPythonPackage rec {
pycryptodome
pytestCheckHook
]
++ passthru.extras-require.async
++ passthru.extras-require.usb;
++ passthru.optional-dependencies.async
++ passthru.optional-dependencies.usb;

disabledTests = lib.optionals (pythonAtLeast "3.10") [
# Tests are failing with Python 3.10
Expand Down
8 changes: 4 additions & 4 deletions pkgs/development/python-modules/androidtv/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ buildPythonPackage rec {
pure-python-adb
];

passthru.extras-require = {
passthru.optional-dependencies = {
async = [
aiofiles
];
inherit (adb-shell.extras-require) usb;
inherit (adb-shell.optional-dependencies) usb;
};

checkInputs = [
mock
pytestCheckHook
]
++ passthru.extras-require.async
++ passthru.extras-require.usb;
++ passthru.optional-dependencies.async
++ passthru.optional-dependencies.usb;

disabledTests = [
# Requires git but fails anyway
Expand Down
6 changes: 3 additions & 3 deletions pkgs/development/python-modules/autobahn/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ buildPythonPackage rec {
mock
pytest-asyncio
pytestCheckHook
] ++ passthru.extras-require.scram
++ passthru.extras-require.serialization;
] ++ passthru.optional-dependencies.scram
++ passthru.optional-dependencies.serialization;

postPatch = ''
substituteInPlace setup.py \
Expand All @@ -89,7 +89,7 @@ buildPythonPackage rec {
"autobahn"
];

passthru.extras-require = rec {
passthru.optional-dependencies = rec {
all = accelerate ++ compress ++ encryption ++ nvx ++ serialization ++ scram ++ twisted ++ ui ++ xbr;
accelerate = [ /* wsaccel */ ];
compress = [ python-snappy ];
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/python-modules/buildbot/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ let
pyyaml
]
# tls
++ twisted.extras-require.tls;
++ twisted.optional-dependencies.tls;

checkInputs = [
treq
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/python-modules/clize/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ buildPythonPackage rec {
six
];

passthru.extras-require = {
passthru.optional-dependencies = {
datetime = [
python-dateutil
];
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/python-modules/dask/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ buildPythonPackage rec {
"dask.diagnostics"
];

passthru.extras-require = {
passthru.optional-dependencies = {
complete = [ distributed ];
};

Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/python-modules/datashader/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ buildPythonPackage rec {
param
pyct
scipy
] ++ dask.extras-require.complete;
] ++ dask.optional-dependencies.complete;

checkInputs = [
pytestCheckHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ buildPythonPackage rec {
pytz
];

passthru.extras-require.taggit = [
passthru.optional-dependencies.taggit = [
django-taggit
];

checkInputs = passthru.extras-require.taggit;
checkInputs = passthru.optional-dependencies.taggit;

checkPhase = ''
runHook preCheck
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/python-modules/fastapi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ buildPythonPackage rec {
pytest-asyncio
sqlalchemy
trio
] ++ passlib.extras-require.bcrypt;
] ++ passlib.optional-dependencies.bcrypt;

patches = [
# Bump starlette, https://github.com/tiangolo/fastapi/pull/4483
Expand Down
10 changes: 5 additions & 5 deletions pkgs/development/python-modules/flask-security-too/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ buildPythonPackage rec {
passlib
];

passthru.extras-require = {
passthru.optional-dependencies = {
babel = [
babel
flask-babel
Expand Down Expand Up @@ -95,10 +95,10 @@ buildPythonPackage rec {
pytestCheckHook
zxcvbn
]
++ passthru.extras-require.babel
++ passthru.extras-require.common
++ passthru.extras-require.fsqla
++ passthru.extras-require.mfa;
++ passthru.optional-dependencies.babel
++ passthru.optional-dependencies.common
++ passthru.optional-dependencies.fsqla
++ passthru.optional-dependencies.mfa;


pythonImportsCheck = [ "flask_security" ];
Expand Down
6 changes: 3 additions & 3 deletions pkgs/development/python-modules/httpcore/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ buildPythonPackage rec {
sniffio
];

passthru.extras-require = {
passthru.optional-dependencies = {
http2 = [ h2 ];
socks = [ socksio ];
};
Expand All @@ -56,8 +56,8 @@ buildPythonPackage rec {
trio
trustme
uvicorn
] ++ passthru.extras-require.http2
++ passthru.extras-require.socks;
] ++ passthru.optional-dependencies.http2
++ passthru.optional-dependencies.socks;

pythonImportsCheck = [ "httpcore" ];

Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/python-modules/httpx-socks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ buildPythonPackage rec {
python-socks
];

passthru.extras-require = {
passthru.optional-dependencies = {
asyncio = [ async-timeout ];
trio = [ trio ];
};
Expand Down
8 changes: 4 additions & 4 deletions pkgs/development/python-modules/httpx/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ buildPythonPackage rec {
async_generator
];

passthru.extras-require = {
passthru.optional-dependencies = {
http2 = [ h2 ];
socks = [ socksio ];
brotli = if isPyPy then [ brotlicffi ] else [ brotli ];
Expand All @@ -63,9 +63,9 @@ buildPythonPackage rec {
trustme
typing-extensions
uvicorn
] ++ passthru.extras-require.http2
++ passthru.extras-require.brotli
++ passthru.extras-require.socks;
] ++ passthru.optional-dependencies.http2
++ passthru.optional-dependencies.brotli
++ passthru.optional-dependencies.socks;

postPatch = ''
substituteInPlace setup.py \
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/python-modules/ibis-framework/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ buildPythonPackage rec {
pytest-mock
pytest-randomly
pytest-xdist
] ++ lib.concatMap (name: passthru.extras-require.${name}) testBackends;
] ++ lib.concatMap (name: passthru.optional-dependencies.${name}) testBackends;

preBuild = ''
# setup.py exists only for developer convenience and is automatically generated
Expand Down Expand Up @@ -139,7 +139,7 @@ buildPythonPackage rec {
] ++ map (backend: "ibis.backends.${backend}") testBackends;

passthru = {
extras-require = {
optional-dependencies = {
clickhouse = [ clickhouse-cityhash clickhouse-driver lz4 ];
dask = [ dask pyarrow ];
datafusion = [ datafusion ];
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/python-modules/ldaptor/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ buildPythonPackage rec {
six
twisted
zope_interface
] ++ twisted.extras-require.tls;
] ++ twisted.optional-dependencies.tls;

checkInputs = [
twisted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ buildPythonPackage rec {
six
twisted
autobahn
] ++ autobahn.extras-require.twisted
++ twisted.extras-require.tls;
] ++ autobahn.optional-dependencies.twisted
++ twisted.optional-dependencies.tls;

checkInputs = [
treq
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/python-modules/magic-wormhole/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ buildPythonPackage rec {
click
humanize
txtorcon
] ++ autobahn.extras-require.twisted
++ twisted.extras-require.tls;
] ++ autobahn.optional-dependencies.twisted
++ twisted.optional-dependencies.tls;

checkInputs = [
mock
Expand Down
8 changes: 4 additions & 4 deletions pkgs/development/python-modules/passlib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ buildPythonPackage rec {
sha256 = "defd50f72b65c5402ab2c573830a6978e5f202ad0d984793c8dde2c4152ebe04";
};

passthru.extras-require = {
passthru.optional-dependencies = {
argon2 = [ argon2-cffi ];
bcrypt = [ bcrypt ];
totp = [ cryptography ];
};

checkInputs = [
pytestCheckHook
] ++ passthru.extras-require.argon2
++ passthru.extras-require.bcrypt
++ passthru.extras-require.totp;
] ++ passthru.optional-dependencies.argon2
++ passthru.optional-dependencies.bcrypt
++ passthru.optional-dependencies.totp;

meta = with lib; {
description = "A password hashing library for Python";
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/python-modules/pure-python-adb/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildPythonPackage rec {
sha256 = "0kdr7w2fhgjpcf1k3l6an9im583iqkr6v8hb4q1zw30nh3bqkk0f";
};

passthru.extras-require = {
passthru.optional-dependencies = {
async = [
aiofiles
];
Expand All @@ -28,7 +28,7 @@ buildPythonPackage rec {
checkInputs = [
pytestCheckHook
]
++ passthru.extras-require.async;
++ passthru.optional-dependencies.async;

pythonImportsCheck = [
"ppadb.client"
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/python-modules/pygatt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ buildPythonPackage rec {
pyserial
];

passthru.extras-require.GATTTOOL = [
passthru.optional-dependencies.GATTTOOL = [
pexpect
];

Expand All @@ -34,7 +34,7 @@ buildPythonPackage rec {
nose
pytestCheckHook
]
++ passthru.extras-require.GATTTOOL;
++ passthru.optional-dependencies.GATTTOOL;

postPatch = ''
# Not support for Python < 3.4
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/python-modules/python-barcode/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ buildPythonPackage rec {
setuptools-scm
];

passthru.extras-require = {
passthru.optional-dependencies = {
images = [
pillow
];
Expand All @@ -38,7 +38,7 @@ buildPythonPackage rec {

checkInputs = [
pytestCheckHook
] ++ passthru.extras-require.images;
] ++ passthru.optional-dependencies.images;

pythonImportsCheck = [ "barcode" ];

Expand Down
Loading

0 comments on commit bc38fca

Please sign in to comment.