Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssl draft #1223

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
54 changes: 54 additions & 0 deletions recipes/recipes_emscripten/ssl/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash


rm $PREFIX/lib/libcrypto.so
rm $PREFIX/lib/libssl.so

export LDFLAGS="-s MODULARIZE=1 -s LINKABLE=1 -s EXPORT_ALL=1 \
-s WASM=1 -s SIDE_MODULE=1 -sWASM_BIGINT"


# include "include" in CFLAGS
INCLUDE_FLAGS="-I$PREFIX/include/python3.11 -I$PREFIX/include/ -I Include/ -I . -I Include/internal/"


# 'PY_STDMODULE_CFLAGS': '-DNDEBUG -g -fwrapv -O3 -Wall -O2 -g0 -fPIC '
# '-DPY_CALL_TRAMPOLINE -fdiagnostics-color=always '
# '-std=c11 -Werror=implicit-function-declaration '
# '-fvisibility=hidden -I./Include/internal -I. '
# '-I./Include -sUSE_BZIP2=1 -sUSE_ZLIB=1',

PY_STDMODULE_CFLAGS="-DNDEBUG -g -fwrapv -O3 -Wall -O2 -g0 -fPIC \
-DPY_CALL_TRAMPOLINE -fdiagnostics-color=always \
-std=c11 -Werror=implicit-function-declaration \
-fvisibility=hidden -I./Include/internal -I."







echo "INCLUDE_FLAGS: $INCLUDE_FLAGS"

STDLIB_MODULE_CFLAGS=$PY_STDMODULE_CFLAGS


echo "EM_FORGE_SIDE_MODULE_LDFLAGS $EM_FORGE_SIDE_MODULE_LDFLAGS"

# OPENSSL_THREADS declares that OPENSSL is threadsafe. We are single threaded so everything is threadsafe.
emcc $STDLIB_MODULE_CFLAGS $INCLUDE_FLAGS -c Modules/_ssl.c -o _ssl.o \
-DOPENSSL_THREADS -s WASM_BIGINT

SIDE_MODULE_LDFLAGS="$EM_FORGE_SIDE_MODULE_LDFLAGS"



PKG_BUILD_DIR=$PREFIX/lib/python3.11
mkdir -p ${PKG_BUILD_DIR}
emcc _ssl.o -lssl -L $PREFIX/lib $SIDE_MODULE_LDFLAGS -o ${PKG_BUILD_DIR}/_ssl.so \
-fPIC -s MODULARIZE=1 -s LINKABLE=1 -s EXPORT_ALL=1 \
-s WASM=1 -s SIDE_MODULE=1 -s WASM_BIGINT

cp Lib/ssl.py $PREFIX/lib/python3.11/ssl.py

46 changes: 46 additions & 0 deletions recipes/recipes_emscripten/ssl/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
context:
version: "3.11.3" # lets use same as python
name: "ssl"

package:
name: ${{ name }}
version: ${{ version }}

source:
url: https://www.python.org/ftp/python/${{version}}/Python-${{version}}.tgz
sha256: 1a79f3df32265d9e6625f1a0b31c28eb1594df911403d11f3320ee1da1b3e048

build:
number: 0

requirements:
build:
- ${{ compiler("c") }}
host:
- openssl ==1.1.1w
- python
run:
- openssl ==1.1.1w
- python

tests:
- script: pytester
requirements:
build:
- pytester
run:
- pytester-run
files:
recipe:
- test_ssl.py


about:
license: Python-2.0
license_file: LICENSE
extra:
recipe-maintainers:
- DerThorsten



24 changes: 24 additions & 0 deletions recipes/recipes_emscripten/ssl/src/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[project]
name = "ssl"
authors = [
{ name="Pyodide"},
]
description = "Unvendored ssl for Pyodide"
version = "1.0.0"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.sdist]
ignore-vcs = true

[tool.hatch.build.targets.wheel]
ignore-vcs = true
include = [
"_ssl.so",
"ssl.py",
]
exclude = [
"Python-*",
]
7 changes: 7 additions & 0 deletions recipes/recipes_emscripten/ssl/test_ssl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


def test_import():

# check if can use pythons ssl
# module
import ssl
Loading