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 graalpy package to make Graalpy available as a Python implementation #20882

Merged
merged 35 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a501193
add graalpy recipe and required python_abi change
timfel Oct 16, 2022
884dd7e
build script for graalpy on graalvm
timfel Nov 5, 2022
12bb156
prepare osx build
timfel Nov 8, 2022
1e6ad40
the graalvm distribution of graalpy is also an openjdk
timfel Nov 10, 2022
99639dc
enable osx packages
timfel Nov 10, 2022
0a0a529
delete linux objects from sulong toolchain on macos
timfel Nov 11, 2022
a9391e4
output graalpy's python_abi directly
timfel Nov 11, 2022
acb27f7
the openjdk package for graalpy needs to match the exact (graalvm-bas…
timfel Nov 11, 2022
def0347
pin all the things to each other
timfel Nov 11, 2022
48ca075
match provided openjdk version to labsjdk version
timfel Nov 11, 2022
23ce8bd
continue to skip builds on windows and osx
timfel Nov 11, 2022
60283a2
add test for graalpy-graalvm
timfel Nov 11, 2022
d13eafa
weak export a dep on graalpy's python_abi when building with it
timfel Nov 11, 2022
17be004
export version range for Python abi
timfel Nov 11, 2022
70a7e90
set macosx deployment target and sdk to 10.10
timfel Nov 12, 2022
65497be
move python_abi output into the python_abi feedstock
timfel Nov 12, 2022
9f0d369
fix osx build JAVA_HOME
timfel Nov 12, 2022
0209399
add backported graalpy patch to include graalpy version in abi tag
timfel Nov 14, 2022
366ce77
update graalpy_abi variable to match python_abi pr
timfel Nov 21, 2022
398c1af
Adapt to current python_abi PR for graalpy
timfel Nov 21, 2022
ddcc188
add run_constraints on python_abi graalpy with the merged build string
timfel Nov 22, 2022
9ea5871
revert temporary build script change
timfel Nov 22, 2022
b1d2f31
Update python_abi build string
timfel Nov 23, 2022
d1ccdf3
Update python_abi build string
timfel Nov 23, 2022
b9414c0
ensure that graalpy site-packages and system site-packages agree
timfel Nov 23, 2022
693fa2d
symlink the graalpy-in-graalvm include directory to the prefix includ…
timfel Nov 23, 2022
3dc54e3
check that noarch packages work on graalpy
timfel Nov 23, 2022
547b219
Fix deps
isuruf Nov 24, 2022
3cce9c9
check pip too
isuruf Nov 24, 2022
fee67f1
Add me to maintainers
isuruf Nov 24, 2022
53535c2
Fix more deps
isuruf Nov 24, 2022
984ce8f
Fix pip requires
isuruf Nov 24, 2022
882ce03
Provide symlink to bin/python3.8
timfel Nov 24, 2022
22b4756
Fix deps again
isuruf Nov 24, 2022
8426c3c
remove redundant info in build string
isuruf Nov 24, 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
18 changes: 18 additions & 0 deletions recipes/graalpy/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Copyright (c) 2022, Oracle and/or its affiliates

The Universal Permissive License (UPL), Version 1.0

Subject to the condition set forth below, permission is hereby granted to any person obtaining a copy of this software, associated documentation and/or data (collectively the "Software"), free of charge and under any and all copyright rights in the Software, and any and all patent rights owned or freely licensable by each licensor hereunder covering either (i) the unmodified Software as contributed to or provided by such licensor, or (ii) the Larger Works (as defined below), to deal in both

(a) the Software, and

(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if one is included with the Software (each a “Larger Work” to which the Software is contributed by such licensors),

without restriction, including without limitation the rights to copy, create derivative works of, display, perform, and distribute the Software and make, use, sell, offer for sale, import, export, have made, and have sold the Software and the Larger Work(s), and to sublicense the foregoing rights on either these or other terms.

This license is subject to the following condition:

The above copyright notice and either this complete permission notice or at a minimum a reference to the UPL must be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

178 changes: 178 additions & 0 deletions recipes/graalpy/build_graalpy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
#!/bin/bash

set -exo pipefail

if [ `uname` = "Darwin" ]; then
MACOS="true"
fi

# this needs to be updated when the target python version of graalpy changes
PY_VERSION=3.8

# set up paths for mx build
export MX_DIR=$SRC_DIR/mx
export PATH=$PATH:$MX_DIR
export MX_PRIMARY_SUITE_PATH=$SRC_DIR/graal/vm

# mx ninja build templates hardcode ar, gcc, g++; symlink these to the conda
# compilers
ln -sf $AR $MX_DIR/ar
ln -sf $CC $MX_DIR/gcc
ln -sf $CXX $MX_DIR/g++

# sulong toolchain wrappers are not recognized and cmake is making trouble
# getting them to compile anything. Make sure to use the sysroot flag, and
# symlink build environment objects
export CFLAGS="$CFLAGS --sysroot $CONDA_BUILD_SYSROOT"
export CXXFLAGS="$CXXFLAGS --sysroot $CONDA_BUILD_SYSROOT"
export LDFLAGS="$LDFLAGS --sysroot $CONDA_BUILD_SYSROOT"
export CPATH="$BUILD_PREFIX/include"
export LIBRARY_PATH="$BUILD_PREFIX/lib"
if [ -z "${MACOS}" ]; then
for filename in $CONDA_BUILD_SYSROOT/../lib/libgcc_s.so*; do
ln -s $filename $CONDA_BUILD_SYSROOT/lib/
done
ln -s $CONDA_BUILD_SYSROOT/../../lib/gcc/x86_64-conda-linux-gnu/*/crtbegin.o $CONDA_BUILD_SYSROOT/lib/
ln -s $CONDA_BUILD_SYSROOT/../../lib/gcc/x86_64-conda-linux-gnu/*/crtbeginS.o $CONDA_BUILD_SYSROOT/lib/
ln -s $CONDA_BUILD_SYSROOT/../../lib/gcc/x86_64-conda-linux-gnu/*/crtend.o $CONDA_BUILD_SYSROOT/lib/
ln -s $CONDA_BUILD_SYSROOT/../../lib/gcc/x86_64-conda-linux-gnu/*/crtendS.o $CONDA_BUILD_SYSROOT/lib/
ln -s $CONDA_BUILD_SYSROOT/../../lib/gcc/x86_64-conda-linux-gnu/*/libgcc.a $CONDA_BUILD_SYSROOT/lib/
fi

# git init an empty repo inside graal, to force mx to pick graal download as
# siblings dir
git init $SRC_DIR/graal
git -C $SRC_DIR/graal config --local user.name "none"
git -C $SRC_DIR/graal config --local user.email "none@example.org"
git -C $SRC_DIR/graal commit --allow-empty -m "dummy commit"

# set environment variables to build a graalpy distribution taken from the
# released graal/mx/mx.vm/ce env file
export MX_PYTHON=${BUILD_PREFIX}/bin/pypy3
export DYNAMIC_IMPORTS=/compiler,/regex,/sdk,/substratevm,/sulong,/tools,/truffle,graalpython
export COMPONENTS=cmp,cov,dap,dis,gu,gvm,icu4j,ins,insight,insightheap,lg,llp,llrc,llrl,llrn,lsp,nfi-libffi,pbm,pmh,poly,polynative,pro,pyn,pynl,rgx,sdk,tfl,tflm
if [ -n "${GRAALPY_STANDALONE_BUILD}" ]; then
export NATIVE_IMAGES=lib:pythonvm,lib:jvmcicompiler,graalvm-native-binutil,graalvm-native-clang,graalvm-native-clang-cl,graalvm-native-clang++,graalvm-native-ld
else
export NATIVE_IMAGES=lib:jvmcicompiler,graalvm-native-binutil,graalvm-native-clang,graalvm-native-clang-cl,graalvm-native-clang++,graalvm-native-ld
fi
export DISABLE_INSTALLABLES=False

# set correct jdk paths
if [ -z "${MACOS}" ]; then
export JAVA_HOME=$SRC_DIR/labsjdk
else
export JAVA_HOME=$SRC_DIR/labsjdk/Contents/Home
fi

# run the build
mx graalvm-show
mx build

if [ -n "${GRAALPY_STANDALONE_BUILD}" ]; then
# move the standalone build artifact into $PREFIX
STANDALONE=`mx standalone-home python`
cp -r $STANDALONE/* $PREFIX

if [ -z "${MACOS}" ]; then
# sulong ensures that the llvm toolchain uses libc++abi.so in the toolchain
# directory by dynamically making sure it's loaded in its toolchain wrappers,
# but the conda build cannot know this and complains
LIBCXX_RPATH=`patchelf --print-rpath $PREFIX/lib/llvm-toolchain/lib/*/libc++.so.1.0`
if [ -n "$LIBCXX_RPATH" ]; then
LIBCXX_RPATH="$LIBCXX_RPATH:\$ORIGIN"
else
LIBCXX_RPATH="\$ORIGIN"
fi
patchelf --set-rpath "$LIBCXX_RPATH" $PREFIX/lib/llvm-toolchain/lib/*/libc++.so.1.0
fi

# match cpython include folder structure
ln -sf $PREFIX/include $PREFIX/include/python${PY_VERSION}

# license is packaged by the build process
cat $PREFIX/LICENSE_GRAALPY.txt $PREFIX/THIRD_PARTY_LICENSE_GRAALPY.txt > $SRC_DIR/LICENSE_GRAALPY.txt
rm $PREFIX/LICENSE_GRAALPY.txt $PREFIX/THIRD_PARTY_LICENSE_GRAALPY.txt
else
GRAALVM=`mx graalvm-home`
mkdir -p $PREFIX/lib/jvm
cp -r $GRAALVM $PREFIX/lib/jvm/
GRAALVM_PREFIX=$PREFIX/lib/jvm/${GRAALVM##*/}

# symlink binaries
mkdir -p $PREFIX/bin/
for i in $GRAALVM_PREFIX/bin/*; do
if [ -x "$i" ]; then
ln -sf "$i" $PREFIX/bin/
fi
done

# sulong ensures that the llvm toolchain uses libc++abi.so in the toolchain
# directory by dynamically making sure it's loaded in its toolchain wrappers,
# but the conda build cannot know this and complains
if [ -z "${MACOS}" ]; then
LIBCXX_RPATH=`patchelf --print-rpath $GRAALVM_PREFIX/lib/llvm/lib/*/libc++.so.1.0`
if [ -n "$LIBCXX_RPATH" ]; then
LIBCXX_RPATH="$LIBCXX_RPATH:\$ORIGIN"
else
LIBCXX_RPATH="\$ORIGIN"
fi
patchelf --set-rpath "$LIBCXX_RPATH" $GRAALVM_PREFIX/lib/llvm/lib/*/libc++.so.1.0
fi

# relativize rpath for jvm libs
if [ -z "${MACOS}" ]; then
# delete graalvm libraries not required for graalpy
rm $GRAALVM_PREFIX/lib/libsplashscreen.so
rm $GRAALVM_PREFIX/lib/libawt_xawt.so
rm $GRAALVM_PREFIX/lib/libjawt.so
rm $GRAALVM_PREFIX/lib/libfontmanager.so
rm $GRAALVM_PREFIX/lib/libjsound.so

for i in $GRAALVM_PREFIX/lib/*.so; do
SO_RPATH=`patchelf --print-rpath $i`
if [ -n "$SO_RPATH" ]; then
SO_RPATH="$SO_RPATH:\$ORIGIN/server"
else
SO_RPATH="\$ORIGIN/server"
fi
patchelf --set-rpath "$SO_RPATH" $i
done
fi

# delete linux bits from sulong's llvm toolchain
if [ -n "${MACOS}" ]; then
rm -rf $GRAALVM_PREFIX/lib/llvm/lib/clang/*/lib/linux/
fi

# match cpython include folder structure
mkdir -p $PREFIX/include/python${PY_VERSION}/
mv $GRAALVM_PREFIX/languages/python/include/* $PREFIX/include/python${PY_VERSION}/
rmdir $GRAALVM_PREFIX/languages/python/include
ln -sf $PREFIX/include/python${PY_VERSION} $GRAALVM_PREFIX/languages/python/include

# license is packaged by the build process
cat $GRAALVM_PREFIX/*LICENSE*.txt $GRAALVM_PREFIX/3rd_party_license*.txt > $SRC_DIR/LICENSE_GRAALPY.txt
fi

# ensure python{PY_VERSION} launcher exists, even though graalpy only ships "python" and "python3"
if [ ! -e "${PREFIX}/bin/python${PY_VERSION}" ]; then
ln -s "${PREFIX}/bin/graalpy" "${PREFIX}/bin/python${PY_VERSION}"
fi

# ensure site-package folder matches cpython, even if graalpy expects the folder somewhere else
graalpy_expected_site_packages=`$PREFIX/bin/graalpy -c 'import site; print(site.getsitepackages()[0])'`
cpython_expected_site_packages=$PREFIX/lib/python${PY_VERSION}/site-packages
if [ -e "${graalpy_expected_site_packages}" ]; then
graalpy_expected_site_packages=$(cd ${graalpy_expected_site_packages}; pwd)
fi
if [ -e "${cpython_expected_site_packages}" ]; then
cpython_expected_site_packages=$(cd ${cpython_expected_site_packages}; pwd)
fi
mkdir -p ${cpython_expected_site_packages}
if [ "${graalpy_expected_site_packages}" != "${cpython_expected_site_packages}" ]; then
# create a link from where graalpy expects site-packages to the system site-packages
rm -rf ${graalpy_expected_site_packages}
mkdir -p $(dirname ${graalpy_expected_site_packages})
ln -sf ${cpython_expected_site_packages} ${graalpy_expected_site_packages}
fi
20 changes: 20 additions & 0 deletions recipes/graalpy/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
graalpy_distribution:
# - standalone
- graalvm

ignore_version:
- python
- curl

# Following are dummy keys to get a single version, as in python_abi
python:
- "2.7"
python_impl:
- '*'
numpy:
- '1.16'

MACOSX_DEPLOYMENT_TARGET: # [osx]
- '10.10' # [osx]
MACOSX_SDK_VERSION: # [osx]
- '10.10' # [osx]
Loading