From fa52f5bd4bf51ebc685e74eead0f0781ead21b51 Mon Sep 17 00:00:00 2001 From: Alex Chalk Date: Thu, 29 Sep 2022 15:20:50 -0400 Subject: [PATCH 1/2] Add support for building bcrypt 4 (rust) --- overrides/default.nix | 38 ++++++++++++++++++++++++++++++------- tests/bcrypt/default.nix | 6 ++++++ tests/bcrypt/poetry.lock | 32 +++++++++++++++++++++++++++++++ tests/bcrypt/pyproject.toml | 15 +++++++++++++++ tests/default.nix | 1 + 5 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 tests/bcrypt/default.nix create mode 100644 tests/bcrypt/poetry.lock create mode 100644 tests/bcrypt/pyproject.toml diff --git a/overrides/default.nix b/overrides/default.nix index 59584e8..437a8e7 100644 --- a/overrides/default.nix +++ b/overrides/default.nix @@ -194,13 +194,37 @@ lib.composeManyExtensions [ dontUseCmakeConfigure = true; } ); - - bcrypt = super.bcrypt.overridePythonAttrs ( - old: { - buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.libffi ]; - } - ); - + bcrypt = + let + getCargoHash = version: { + "4.0.0" = "sha256-HvfRLyUhlXVuvxWrtSDKx3rMKJbjvuiMcDY6g+pYFS0="; + }.${version} or ( + lib.warn "Unknown bcrypt version: '${version}'. Please update getCargoHash." lib.fakeHash + ); + sha256 = getCargoHash super.bcrypt.version; + in + super.bcrypt.overridePythonAttrs ( + old: { + buildInputs = (old.buildInputs or [ ]) + ++ [ pkgs.libffi ] + ++ lib.optionals (lib.versionAtLeast old.version "4" && stdenv.isDarwin) + [ pkgs.darwin.apple_sdk.frameworks.Security pkgs.libiconv ]; + nativeBuildInputs = with pkgs; + (old.nativeBuildInputs or [ ]) + ++ lib.optionals (lib.versionAtLeast old.version "4") + (with pkgs.rustPlatform; [ rust.rustc rust.cargo cargoSetupHook self.setuptools-rust ]); + } // lib.optionalAttrs (lib.versionAtLeast old.version "4") rec { + cargoDeps = + pkgs.rustPlatform.fetchCargoTarball + { + src = old.src; + sourceRoot = "${old.pname}-${old.version}/src/_bcrypt"; + name = "${old.pname}-${old.version}"; + sha256 = getCargoHash old.version; + }; + cargoRoot = "src/_bcrypt"; + } + ); bjoern = super.bjoern.overridePythonAttrs ( old: { buildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.libev ]; diff --git a/tests/bcrypt/default.nix b/tests/bcrypt/default.nix new file mode 100644 index 0000000..b6765f2 --- /dev/null +++ b/tests/bcrypt/default.nix @@ -0,0 +1,6 @@ +{ lib, poetry2nix, runCommand }: +poetry2nix.mkPoetryApplication { + pyproject = ./pyproject.toml; + poetrylock = ./poetry.lock; + src = lib.cleanSource ./.; +} diff --git a/tests/bcrypt/poetry.lock b/tests/bcrypt/poetry.lock new file mode 100644 index 0000000..7f2bdb8 --- /dev/null +++ b/tests/bcrypt/poetry.lock @@ -0,0 +1,32 @@ +[[package]] +name = "bcrypt" +version = "4.0.0" +description = "Modern password hashing for your software and your servers" +category = "main" +optional = false +python-versions = ">=3.6" + +[package.extras] +tests = ["pytest (>=3.2.1,!=3.3.0)"] +typecheck = ["mypy"] + +[metadata] +lock-version = "1.1" +python-versions = "^3.8" +content-hash = "b775516313a0ee51e973c6e8bfbb07650bd437a9261289defb8015738864b749" + +[metadata.files] +bcrypt = [ + {file = "bcrypt-4.0.0-cp36-abi3-macosx_10_10_universal2.whl", hash = "sha256:845b1daf4df2dd94d2fdbc9454953ca9dd0e12970a0bfc9f3dcc6faea3fa96e4"}, + {file = "bcrypt-4.0.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl", hash = "sha256:8780e69f9deec9d60f947b169507d2c9816e4f11548f1f7ebee2af38b9b22ae4"}, + {file = "bcrypt-4.0.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1c3334446fac200499e8bc04a530ce3cf0b3d7151e0e4ac5c0dddd3d95e97843"}, + {file = "bcrypt-4.0.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bfb67f6a6c72dfb0a02f3df51550aa1862708e55128b22543e2b42c74f3620d7"}, + {file = "bcrypt-4.0.0-cp36-abi3-manylinux_2_24_x86_64.whl", hash = "sha256:7c7dd6c1f05bf89e65261d97ac3a6520f34c2acb369afb57e3ea4449be6ff8fd"}, + {file = "bcrypt-4.0.0-cp36-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:594780b364fb45f2634c46ec8d3e61c1c0f1811c4f2da60e8eb15594ecbf93ed"}, + {file = "bcrypt-4.0.0-cp36-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:2d0dd19aad87e4ab882ef1d12df505f4c52b28b69666ce83c528f42c07379227"}, + {file = "bcrypt-4.0.0-cp36-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:bf413f2a9b0a2950fc750998899013f2e718d20fa4a58b85ca50b6df5ed1bbf9"}, + {file = "bcrypt-4.0.0-cp36-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:ede0f506554571c8eda80db22b83c139303ec6b595b8f60c4c8157bdd0bdee36"}, + {file = "bcrypt-4.0.0-cp36-abi3-win32.whl", hash = "sha256:dc6ec3dc19b1c193b2f7cf279d3e32e7caf447532fbcb7af0906fe4398900c33"}, + {file = "bcrypt-4.0.0-cp36-abi3-win_amd64.whl", hash = "sha256:0b0f0c7141622a31e9734b7f649451147c04ebb5122327ac0bd23744df84be90"}, + {file = "bcrypt-4.0.0.tar.gz", hash = "sha256:c59c170fc9225faad04dde1ba61d85b413946e8ce2e5f5f5ff30dfd67283f319"}, +] diff --git a/tests/bcrypt/pyproject.toml b/tests/bcrypt/pyproject.toml new file mode 100644 index 0000000..d65b618 --- /dev/null +++ b/tests/bcrypt/pyproject.toml @@ -0,0 +1,15 @@ +[tool.poetry] +name = "test_bcrypt" +version = "0.1.0" +description = "" +authors = [] + +[tool.poetry.dependencies] +python = "^3.8" +bcrypt = "*" + +[tool.poetry.dev-dependencies] + +[build-system] +requires = ["poetry>=0.12"] +build-backend = "poetry.masonry.api" diff --git a/tests/default.nix b/tests/default.nix index 5a0d3f2..8226777 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -76,6 +76,7 @@ builtins.removeAttrs editable-egg = skipOSX (callTest ./editable-egg { }); ansible-molecule = callTest ./ansible-molecule { }; + bcrypt = callTest ./bcrypt { }; mk-poetry-packages = callTest ./mk-poetry-packages { }; markupsafe2 = callTest ./markupsafe2 { }; pendulum = callTest ./pendulum { }; From 60ef92b6b028ca8923a8a824e126d215464611ec Mon Sep 17 00:00:00 2001 From: Alex Chalk Date: Thu, 29 Sep 2022 18:19:37 -0400 Subject: [PATCH 2/2] Add empty test file --- tests/bcrypt/test_bcrypt.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/bcrypt/test_bcrypt.py diff --git a/tests/bcrypt/test_bcrypt.py b/tests/bcrypt/test_bcrypt.py new file mode 100644 index 0000000..e69de29