python3-cryptography: move from meta-python

* inherit new setuptools_rust class (which inherits new pyo3 class, which
  inherits cargo and python3-dir).
* RDEPENDS on python3-pytest-subtests for ptest
* Copy pyproject.toml for ptest as it defines the pytest.marker(s) needed
* Use 'cargo bitbake' to generate the crate:// SRC_URIs
   - Needed some hacks to the Cargo.toml in src/rust/ to make this work (probably
     only package.repository was strictly required):

     [package]
     description = "cryptography includes both high level recipes and low level interfaces to common cryptographic algorithms such as symmetric ciphers, message digests, and key derivation functions."
     homepage = "https://github.com/pyca/cryptography"
     repository = "https://github.com/pyca/cryptography"

* Add patches to src/rust/Cargo.toml to fix cargo errors including  pem version
* Add check-memfree.py to ptest to check for sufficient free memory

(From OE-Core rev: 27bd134c899d00d93806ecb0a62ec3f30b1e6ec6)

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Tim Orling
2022-03-12 12:53:54 -08:00
committed by Richard Purdie
parent 8af946e718
commit c6f79207f8
5 changed files with 196 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
From ec8d3f3c61280c8140b34ed1479baef5e706f064 Mon Sep 17 00:00:00 2001
From: Tim Orling <tim.orling@konsulko.com>
Date: Fri, 14 Jan 2022 22:02:25 -0800
Subject: [PATCH] Cargo.toml: specify pem version
pem = "1.0" is not resolving, specify the current
pem = { version: "1.0.2"}
Upstream-Status: Pending
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
src/rust/Cargo.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml
index 617167d0..174eaa80 100644
--- a/src/rust/Cargo.toml
+++ b/src/rust/Cargo.toml
@@ -9,7 +9,7 @@ publish = false
lazy_static = "1"
pyo3 = { version = "0.15.1" }
asn1 = { version = "0.8.7", default-features = false, features = ["derive"] }
-pem = "1.0"
+pem = { version = "1.0.2" }
chrono = { version = "0.4", default-features = false, features = ["alloc", "clock"] }
ouroboros = "0.13"
--
2.30.2

View File

@@ -0,0 +1,28 @@
From 4b73298b214a5b69ea6edf3c2e21dd82b2b29708 Mon Sep 17 00:00:00 2001
From: Tim Orling <tim.orling@konsulko.com>
Date: Fri, 14 Jan 2022 22:34:59 -0800
Subject: [PATCH 2/2] Cargo.toml: edition 2018 -> 2021
Upstream-Status: Pending
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
src/rust/Cargo.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml
index 174eaa80..7ad053d9 100644
--- a/src/rust/Cargo.toml
+++ b/src/rust/Cargo.toml
@@ -2,7 +2,7 @@
name = "cryptography-rust"
version = "0.1.0"
authors = ["The cryptography developers <cryptography-dev@python.org>"]
-edition = "2018"
+edition = "2021"
publish = false
[dependencies]
--
2.30.2

View File

@@ -0,0 +1,10 @@
#!/usr/bin/env python3
# https://stackoverflow.com/questions/22102999/get-total-physical-memory-in-python/28161352
import sys
meminfo = dict((i.split()[0].rstrip(':'),int(i.split()[1])) for i in open('/proc/meminfo').readlines())
mem_free = meminfo['MemTotal']/1024./1024.
if mem_free < 2.:
raise RuntimeError("Insufficient free memory({:.3f}): requires > 2 GB".format(mem_free))
sys.exit(1)
else:
print("Free memory: {:.3f} GB".format(mem_free))

View File

@@ -0,0 +1,4 @@
#!/bin/sh
if ./check-memfree.py; then
pytest -vvvv tests/
fi