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

add Python.NET recipe #159

Merged
merged 25 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c77a1af
dotnet: update to v6.0.11
Livius90 Nov 9, 2022
cccad24
Merge branch 'DynamicDevices:master' into master
Livius90 Nov 12, 2022
313b3dd
python: Add Python.NET v3.0.1
Livius90 Nov 12, 2022
5872fdb
python3-clr-loader: fix typo
Livius90 Nov 12, 2022
57389e3
pythonnet: fix proxy config
Livius90 Nov 12, 2022
fa62409
pythonnet: separated folder for nuget downloads and cache
Livius90 Nov 13, 2022
76a6a45
python3-clr-loader: test proxy
Livius90 Nov 17, 2022
1195469
dotnet restore try to fix #1
Livius90 Nov 20, 2022
fed7aad
dotnet restore next try
Livius90 Nov 20, 2022
6624e00
dotnet restore try some http env settings
Livius90 Nov 21, 2022
099ebb0
dotnet restore fix libcurl-native syntax
Livius90 Nov 21, 2022
8f49947
dotnet restore curl fix
Livius90 Nov 21, 2022
0c251a9
dotnet restore test http download
Livius90 Nov 26, 2022
d650837
dotnet restore http next try
Livius90 Nov 26, 2022
b92326e
dotnet restore test DNS
Livius90 Nov 27, 2022
0d89725
dotnet restore, dns fix not works, revert some parts
Livius90 Nov 27, 2022
85ed263
dotnet restore fix, version appending fix in __init__.py
Livius90 Nov 27, 2022
a571e81
fix endline, restore original yml
Livius90 Nov 27, 2022
7424f94
fix again endline
Livius90 Nov 27, 2022
6ffbb6c
fix again endline and trigger a new fetch
Livius90 Nov 27, 2022
4383f75
append endline in do_patch, restore latest package versions
Livius90 Nov 27, 2022
38c93c7
do_configure:prepend() must be used for version append
Livius90 Nov 27, 2022
c3bb690
append __version__ only if it is does not exist
Livius90 Nov 27, 2022
7f96e54
fix typo
Livius90 Nov 27, 2022
a99642d
if proxy used, it must be defined in task environment
Livius90 Nov 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conf/layer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ PREFERRED_VERSION_nuget-native ?= "5.2.0"
PREFERRED_VERSION_msbuild ?= "16.6"
PREFERRED_VERSION_msbuild-native ?= "16.6"

LAYERSERIES_COMPAT_mono = "dunfell gatesgarth hardknott honister kirkstone langdale"
LAYERSERIES_COMPAT_mono = "kirkstone langdale"
1 change: 1 addition & 0 deletions recipes-mono/images/test-image-mono.bb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ DEFAULT_TEST_SUITES:pn-${PN}:prepend = "dotnet "
IMAGE_INSTALL += "msbuild \
dotnet \
dotnet-helloworld \
python3-pythonnet \
"

IMAGE_BASENAME = "${PN}"
Expand Down
56 changes: 56 additions & 0 deletions recipes-python/python3-clr-loader/python3-clr-loader.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
DESCRIPTION = "Implements a generic interface for loading one of the CLR (.NET) runtime implementations and calling simple functions on them."
HOMEPAGE = "http://pythonnet.github.io"
SECTION = "devel/python"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=cdef1cb9133877183afac105849a771e"

inherit python_flit_core

CLR_LOADER_VERSION = "0.2.4"
PV = "${CLR_LOADER_VERSION}+git${SRCPV}"
SRC_URI = "git://github.com/pythonnet/clr-loader.git;protocol=https;branch=master;tag=v${CLR_LOADER_VERSION}"

DOTNET_MIN_REQ_VERSION ?= "6.0.0"

DEPENDS += " \
dotnet-native (>= ${DOTNET_MIN_REQ_VERSION}) \
${PYTHON_PN}-setuptools-scm-native \
${PYTHON_PN}-toml-native \
"

RDEPENDS:${PN} += " \
dotnet (>= ${DOTNET_MIN_REQ_VERSION}) \
${PYTHON_PN}-cffi \
"

S = "${WORKDIR}/git"

# NuGet uses $HOME/.nuget/packages to store packages by default
# but we should not use anything outside the build root of packages.
# Use a separated folder for nuget downloads and cache in WORKDIR.
export NUGET_PACKAGES="${WORKDIR}/nuget-packages"
export NUGET_HTTP_CACHE_PATH="${WORKDIR}/nuget-http-cache"

# Workaround for dotnet restore issue, define custom proxy in a .bbappend
# and/or in layer.conf or local.conf if dotnet restore was failed.
# Override DOTNET_HTTP_PROXY and DOTNET_HTTPS_PROXY in layer.conf or local.conf if needed
DOTNET_HTTP_PROXY ?= ""
DOTNET_HTTPS_PROXY ?= ""
export http_proxy="${DOTNET_HTTP_PROXY}"
export https_proxy="${DOTNET_HTTPS_PROXY}"

do_configure:prepend() {
if ! grep -Fq __version__ ${S}/clr_loader/__init__.py
then
printf "\n__version__ = \"${CLR_LOADER_VERSION}\"\n" >> ${S}/clr_loader/__init__.py
fi
}

do_compile[network] = "1"

do_compile:prepend() {
python3 setup.py build_dotnet
cp -R ${S}/build/lib/clr_loader/ffi/dlls ${S}/clr_loader/ffi/
}

BBCLASSEXTEND = "native"
78 changes: 78 additions & 0 deletions recipes-python/python3-pythonnet/python3-pythonnet.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
DESCRIPTION = "Python.NET is a package that gives Python programmers nearly seamless integration with .NET Framework, .NET Core and Mono runtime on Windows, Linux and macOS."
HOMEPAGE = "http://pythonnet.github.io"
SECTION = "devel/python"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=8e800b2b69ab79d37187ed4eb522060d"

inherit python_flit_core

PYTHONNET_VERSION = "3.0.1"
PV = "${PYTHONNET_VERSION}+git${SRCPV}"
SRC_URI = "git://github.com/pythonnet/pythonnet.git;protocol=https;branch=master;tag=v${PYTHONNET_VERSION}"

DOTNET_MIN_REQ_VERSION ?= "6.0.0"

# Python.NET’s documentation - Loading a Runtime
# https://pythonnet.github.io/pythonnet/python.html#loading-a-runtime
# Default runtime is .NET Core (coreclr).
PYTHONNET_DEFAULT_RUNTIME ?= "coreclr"
PYTHONNET_ENV = "#!/bin/bash\n\nexport PYTHONNET_RUNTIME=${PYTHONNET_DEFAULT_RUNTIME}\n"

DEPENDS += " \
dotnet-native (>= ${DOTNET_MIN_REQ_VERSION}) \
${PYTHON_PN}-clr-loader-native \
${PYTHON_PN}-setuptools-scm-native \
${PYTHON_PN}-toml-native \
"

RDEPENDS:${PN} += " \
bash \
dotnet (>= ${DOTNET_MIN_REQ_VERSION}) \
${PYTHON_PN}-pycparser \
${PYTHON_PN}-clr-loader \
"

S = "${WORKDIR}/git"

# NuGet uses $HOME/.nuget/packages to store packages by default
# but we should not use anything outside the build root of packages.
# Use a separated folder for nuget downloads and cache in WORKDIR.
export NUGET_PACKAGES="${WORKDIR}/nuget-packages"
export NUGET_HTTP_CACHE_PATH="${WORKDIR}/nuget-http-cache"

# Workaround for dotnet restore issue, define custom proxy in a .bbappend
# and/or in layer.conf or local.conf if dotnet restore was failed.
# Override DOTNET_HTTP_PROXY and DOTNET_HTTPS_PROXY in layer.conf or local.conf if needed
DOTNET_HTTP_PROXY ?= ""
DOTNET_HTTPS_PROXY ?= ""
export http_proxy="${DOTNET_HTTP_PROXY}"
export https_proxy="${DOTNET_HTTPS_PROXY}"

do_configure:prepend() {
if ! grep -Fq __version__ ${S}/pythonnet/__init__.py
then
printf "\n__version__ = \"${PYTHONNET_VERSION}\"\n" >> ${S}/pythonnet/__init__.py
fi
}

do_compile[network] = "1"

do_compile:prepend() {
python3 setup.py build_dotnet
cp -r ${S}/build/lib/pythonnet/runtime/Python.Runtime.* ${S}/pythonnet/runtime/
}

do_install:prepend() {
cwd=$(pwd)
printf "${PYTHONNET_ENV}" > ${WORKDIR}/dotnet-env.sh

install -d ${D}${sysconfdir}/profile.d
install -d ${D}${PYTHON_SITEPACKAGES_DIR}

install -m 644 ${S}/clr.py ${D}${PYTHON_SITEPACKAGES_DIR}
install -m 644 ${WORKDIR}/dotnet-env.sh ${D}${sysconfdir}/profile.d

cd ${D}${PYTHON_SITEPACKAGES_DIR}
python3 -m py_compile clr.py
cd ${cwd}
}