Skip to content

Commit

Permalink
repo: add python-bcrypt patches
Browse files Browse the repository at this point in the history
- python-bcrypt-allow-subinterpreters.patch
- python-bcrypt-prefix-ceph.patch

Together, these allow us to build a renamed python-bcrypt package, as
ceph_bcrypt.

This will allow us to bypass the thorny pyo3 issues we have with various
mgr modules exploding at runtime.

References: #20
  • Loading branch information
bazaah committed Mar 23, 2024
1 parent 246af22 commit 8576de3
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
13 changes: 13 additions & 0 deletions python-bcrypt-allow-subinterpreters.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/_bcrypt/Cargo.toml b/src/_bcrypt/Cargo.toml
index a9c7f7c..02317c8 100644
--- a/src/_bcrypt/Cargo.toml
+++ b/src/_bcrypt/Cargo.toml
@@ -6,7 +6,7 @@ edition = "2018"
publish = false

[dependencies]
-pyo3 = { version = "0.20.0", features = ["abi3"] }
+pyo3 = { git = "https://git.st8l.com/luxolus/pyo3", tag = "v0.20.3-subint+1", features = ["abi3", "unsafe-allow-subinterpreters"] }
bcrypt = "0.15"
bcrypt-pbkdf = "0.10.0"
base64 = "0.21.5"
56 changes: 56 additions & 0 deletions python-bcrypt-prefix-ceph.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
diff --git a/pyproject.toml b/pyproject.toml
index e365c8c..6e27a0d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -10,7 +10,7 @@ requires = [
build-backend = "setuptools.build_meta"

[project]
-name = "bcrypt"
+name = "ceph_bcrypt"
# When updating this, also update lib.rs
version = "4.1.2"
authors = [
@@ -41,7 +41,7 @@ homepage = "https://github.com/pyca/bcrypt/"
[tool.setuptools]
zip-safe = false
package-dir = {"" = "src"}
-packages = ["bcrypt"]
+packages = ["ceph_bcrypt"]

[tool.setuptools.dynamic]
readme = {file = "README.rst", content-type = "text/x-rst"}
@@ -57,7 +57,7 @@ select = ['E', 'F', 'I', 'N', 'W', 'UP', 'RUF']
line-length = 79

[tool.ruff.isort]
-known-first-party = ["bcrypt", "tests"]
+known-first-party = ["ceph_bcrypt", "tests"]

[tool.mypy]
show_error_codes = true
diff --git a/setup.py b/setup.py
index 13694c4..160abdd 100644
--- a/setup.py
+++ b/setup.py
@@ -35,7 +35,7 @@ try:
setup(
rust_extensions=[
RustExtension(
- "bcrypt._bcrypt",
+ "ceph_bcrypt._bcrypt",
"src/_bcrypt/Cargo.toml",
py_limited_api="auto",
rust_version=(
diff --git a/tests/test_bcrypt.py b/tests/test_bcrypt.py
index 68c00fb..0661573 100644
--- a/tests/test_bcrypt.py
+++ b/tests/test_bcrypt.py
@@ -1,6 +1,6 @@
import pytest

-import bcrypt
+import ceph_bcrypt as bcrypt

_test_vectors = [
(

0 comments on commit 8576de3

Please sign in to comment.