<commit_before>#!/bin/bash

# This is early hack for building tiny docker image that contains
# - statically linked version of python
# - pythonshare-server

cd "$(dirname $0)"

PYTHONSHARE_DOCKER_DIR="$(pwd)"

cd ..

# Destination
INSTALL_ROOT=${PYTHONSHARE_DOCKER_DIR}/static-install

# Install prefix under INSTALL_ROOT
INSTALL_PREFIX=/usr
INSTALL_DIR=$INSTALL_ROOT/$INSTALL_PREFIX

# Sources
PYTHONSHARE_DIR=$(pwd)
if [ -z "$PYTHON_DIR" ]; then
    echo "PYTHON_DIR is not defined." >&2
    echo "Usage: PYTHON_DIR=/path/to/git/cpython $0"
    exit 1
fi
if [ ! -f "$PYTHON_DIR/configure" ]; then
    echo "Invalid PYTHON_DIR: cannot find '$PYTHON_DIR/configure'"
    exit 1
fi
if [ "$(grep ^VERSION= $PYTHON_DIR/configure)" != "VERSION=2.7" ]; then
    echo "Invalid Python version in PYTHON_DIR: branch 2.7 required"
    exit 1
fi

## Build and install static Python
cd "$PYTHON_DIR"
#./configure LINKFORSHARED=" " LDFLAGS="-static -static-libgcc -Wl,--no-export-dynamic" CPPFLAGS="-static -fpic" --disable-shared --prefix "$INSTALL_DIR"
( nice make -j 16 install 2>&1 | tee make_static_build.log ) || {
    echo "building and installing static Python from '$PYTHON_DIR' to '$INSTALL_DIR' failed" >&2
    exit 1
}

## Build and install Pythonshare using just compiled Python
bash -c "
export PYTHONHOME=$INSTALL_DIR
export PYTHONPATH=$INSTALL_DIR/lib/python27.zip
cd \"$PYTHONSHARE_DIR\"
$INSTALL_DIR/bin/python setup.py install --prefix \"$INSTALL_DIR\"
sed -e 's:#!/usr/bin/env python2:#!$INSTALL_PREFIX/bin/python2:1' -i '$INSTALL_DIR/bin/pythonshare-server' '$INSTALL_DIR/bin/pythonshare-client'
cp ../utils/pycosh.py $INSTALL_DIR/lib/python2.7/site-packages<commit_msg>Pythonshare docker: run configure on CPython<commit_after>#!/bin/bash

# This is early hack for building tiny docker image that contains
# - statically linked version of python
# - pythonshare-server

cd "$(dirname $0)"

PYTHONSHARE_DOCKER_DIR="$(pwd)"

cd ..

# Destination where to install static Python and Pythonshare
# and from which Docker filesystem will be created.
INSTALL_ROOT=${PYTHONSHARE_DOCKER_DIR}/static-install

# Install prefix under INSTALL_ROOT
INSTALL_PREFIX=/usr
INSTALL_DIR=$INSTALL_ROOT/$INSTALL_PREFIX

# Sources where to find Pythonshare and Python
PYTHONSHARE_DIR=$(pwd)
if [ -z "$PYTHON_DIR" ]; then
    echo "PYTHON_DIR is not defined." >&2
    echo "Usage: PYTHON_DIR=/path/to/git/cpython $0"
    exit 1
fi
if [ ! -f "$PYTHON_DIR/configure" ]; then
    echo "Invalid PYTHON_DIR: cannot find '$PYTHON_DIR/configure'"
    exit 1
fi
if [ "$(grep ^VERSION= $PYTHON_DIR/configure)" != "VERSION=2.7" ]; then
    echo "Invalid Python version in PYTHON_DIR: branch 2.7 required"
    exit 1
fi

## Build and install static Python
cd "$PYTHON_DIR"
./configure LINKFORSHARED=" " LDFLAGS="-static -static-libgcc -Wl,--no-export-dynamic" CPPFLAGS="-static -fpic" --disable-shared --prefix "$INSTALL_DIR"
( nice make -j 16 install 2>&1 | tee make_static_build.log ) || {
    echo "building and installing static Python from '$PYTHON_DIR' to '$INSTALL_DIR' failed" >&2
    exit 1
}

## Build and install Pythonshare using just compiled Python
bash -c "
export PYTHONHOME=$INSTALL_DIR
export PYTHONPATH=$INSTALL_DIR/lib/python27.zip
cd \"$PYTHONSHARE_DIR\"
$INSTALL_DIR/bin/python setup.py install --prefix \"$INSTALL_DIR\"
sed -e 's:#!/usr/bin/env python2:#!$INSTALL_PREFIX/bin/python2:1' -i '$INSTALL_DIR/bin/pythonshare-server' '$INSTALL_DIR/bin/pythonshare-client'
cp ../utils/pycosh.py $INSTALL_DIR/lib/python2.7/site-packages
{'fraction_non_alphanumeric': 0.13053348467650397, 'fraction_numerical': 0.013053348467650397, 'mean_word_length': 4.604133545310016, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2550602', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1239, 'n_words': 329}