diff --git a/projects/python-windows/build b/projects/python-windows/build new file mode 100644 index 0000000..8d016fa --- /dev/null +++ b/projects/python-windows/build @@ -0,0 +1,66 @@ +#!/bin/bash +[% c("var/set_default_env") -%] +distdir=/var/tmp/dist/[% project %] +[% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %] +# Set up compiler + +mkdir -p /var/tmp/build +tar -C /var/tmp/build -xf [% c('input_files_by_name/python') %] +tar -C /var/tmp/build -xf [% c('input_files_by_name/meson') %] +tar -C /var/tmp/build -xf [% c('input_files_by_name/ninja') %] +tar -C /var/tmp/build -xf [% c('input_files_by_name/python-buildscript') %] +# Unpack dependencies +PATH=/var/tmp/build/meson-[% c("meson_version") %]:"$PATH" +PATH=/var/tmp/build/ninja:"$PATH" +# Add dependencies to PATH + +patch /var/tmp/build/Python-[% c("version") %]/Modules/getbuildinfo.c < $rootdir/omit-build-timestamp.patch +# Python includes build timestamp by default +patch /var/tmp/build/cross-python-[% c("cp_githash") %]/meson.build << 'EOF' +113c113 +< add_project_link_arguments('-municode', '-mconsole', '-static-libgcc', language:'c') +--- +> add_project_link_arguments('-municode', '-mconsole', '-static-libgcc', '-Wl,-Bstatic', '-lwinpthread', '-Wl,-Bdynamic', language:'c') +1076c1076 +< python_libraries = both_libraries( +--- +> libpython = shared_library( +1086,1087d1085 +< +< libpython = python_libraries.get_shared_lib() +EOF +# Patch build script to statically link pthread +ranlib /var/tmp/dist/mingw-w64/[% c("arch") %]-w64-mingw32/lib/libwinpthread.a +# Prepare libwinpthread for static linking + +# This is a hack. (TODO: refactor) +# We need to link this statically, because we aren't shipping the mingw runtime. +# https://stackoverflow.com/questions/14665691/static-linking-with-libwinpthread + + +mkdir -p /var/tmp/build/cross-python-[% c("cp_githash") %]/subprojects/packagecache +cp [% c('input_files_by_name/sqlite-src') %] /var/tmp/build/cross-python-[% c("cp_githash") %]/subprojects/packagecache/sqlite-amalgamation-3250100.zip +cp [% c('input_files_by_name/sqlite-patch') %] /var/tmp/build/cross-python-[% c("cp_githash") %]/subprojects/packagecache/sqlite-3250100-1-wrap.zip +cp [% c('input_files_by_name/zlib-src') %] /var/tmp/build/cross-python-[% c("cp_githash") %]/subprojects/packagecache/zlib-1.2.11.tar.gz +cp [% c('input_files_by_name/zlib-patch') %] /var/tmp/build/cross-python-[% c("cp_githash") %]/subprojects/packagecache/zlib-1.2.11-4-wrap.zip +# Project pulls in sqlite, zlib, and build files. +# Download them outside, in rbm, to avoid container network access. + +cd /var/tmp/build/cross-python-[% c("cp_githash") %] +# Enter the build directory + +LDFLAGS="-Wl,--no-insert-timestamp" meson.py -Dsource=../Python-[% c("version") %] --cross-file cross-files/x86_64-w64-mingw32.txt --prefix=$distdir builddir +# cf. ./configure +ninja -C builddir +# cf. make +ninja -C builddir install +# cf. make install + +find $distdir -name '*.a' -exec rm '{}' + +# These files don't reproduce, and are useless + +cd /var/tmp/dist +[% c('tar', { + tar_src => [ project ], + tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'), + }) %] diff --git a/projects/python-windows/config b/projects/python-windows/config new file mode 100644 index 0000000..955e167 --- /dev/null +++ b/projects/python-windows/config @@ -0,0 +1,53 @@ +# vim: filetype=yaml sw=2 +version: 3.8.5 +meson_version: 0.55.1 +cp_githash: cb160097d0df4b510e011aa263a37150bfab8939 +filename: 'python-[% c("lsb_release/id") %]-[% c("lsb_release/release") %]-[% c("var/build_id") %].tar.gz' +var: + container: + use_container: 1 + deps: + - xz-utils + - build-essential + - python3 + - pkg-config + - zip + - git # maybe possible to omit these + compiler: mingw-w64 + +input_files: + - project: container-image + - project: '[% c("var/compiler") %]' + name: '[% c("var/compiler") %]' + - project: ninja + name: ninja + - name: python + URL: 'https://www.python.org/ftp/python/[% c("version") %]/Python-[% c("version") %].tar.xz' + sig_ext: asc + gpg_keyring: python.gpg + - name: meson + URL: 'https://github.com/mesonbuild/meson/releases/download/[% c("meson_version") %]/meson-[% c("meson_version") %].tar.gz' + sig_ext: asc + gpg_keyring: meson.gpg + - name: python-buildscript + URL: 'https://github.com/v-finance/cross-python/archive/[% c("cp_githash") %].tar.gz' + sha256sum: 4f427bbd1601235ad26553ec2ca10a309124849df4436e76afdb84af7bd6584b + - name: '[% c("var/compiler") %]' + project: '[% c("var/compiler") %]' + - name: zlib-src + filename: zlib-1.2.11.tar.gz + URL: http://zlib.net/fossils/zlib-1.2.11.tar.gz + sha256sum: c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 + - name: zlib-patch + filename: zlib-1.2.11-4-wrap.zip + URL: https://wrapdb.mesonbuild.com/v1/projects/zlib/1.2.11/4/get_zip + sha256sum: f733976fbfc59e0bcde01aa9469a24eeb16faf0a4280b17e9eaa60a301d75657 + - name: sqlite-src + filename: sqlite-amalgamation-3250100.zip + URL: https://www.sqlite.org/2018/sqlite-amalgamation-3250100.zip + sha256sum: 6c68b6364fa0e01d9d05088ba473ac4e7a6fbc64f9b9aeb6d830f944e2a1fa03 + - name: sqlite-patch + filename: sqlite-3250100-1-wrap.zip + URL: https://wrapdb.mesonbuild.com/v1/projects/sqlite/3250100/1/get_zip + sha256sum: cbb697a1e4649cf6b7f28d82048109d87ccbf01106e1d5a68f763d4685d8607c + - filename: omit-build-timestamp.patch diff --git a/projects/python-windows/omit-build-timestamp.patch b/projects/python-windows/omit-build-timestamp.patch new file mode 100644 index 0000000..896095f --- /dev/null +++ b/projects/python-windows/omit-build-timestamp.patch @@ -0,0 +1,8 @@ +8c8 +< #ifdef __DATE__ +--- +> #if defined(__DATE__) && defined(EMIT_BUILD_TIMESTAMP) +16c16 +< #ifdef __TIME__ +--- +> #if defined(__TIME__) && defined(EMIT_BUILD_TIMESTAMP)