contrib/setup-pytype.sh
author Pierre-Yves David <pierre-yves.david@octobus.net>
Tue, 26 Mar 2024 13:46:44 +0000
changeset 51552 49faa72b994e
parent 49652 03792c1ed341
permissions -rwxr-xr-x
streamclone: stop listing files for entries that have no volatile files This will save a lot of python related time. This significantly boost performance. The following number comes from a large private repository using perf::stream-locked-section: base-line: 35.04 seconds prev-change: 24.51 seconds (-30%) prev-change: 20.88 seconds (-40%) prev-change: 14.22 seconds (-60%) this-change: 11.58 seconds (-67% from baseline; -18% from prev)

#!/bin/bash

set -e
set -u

# Find the python3 setup that would run pytype
PYTYPE=`which pytype`
PYTHON3=`head -n1 ${PYTYPE} | sed -s 's/#!//'`

# Existing stubs that pytype processes live here
TYPESHED=$(${PYTHON3} -c "import pytype; print(pytype.__path__[0])")/typeshed/stubs
HG_STUBS=${TYPESHED}/mercurial

echo "Patching typeshed at $HG_STUBS"

rm -rf ${HG_STUBS}
mkdir -p ${HG_STUBS}

cat > ${HG_STUBS}/METADATA.toml <<EOF
version = "0.1"
EOF


mkdir -p ${HG_STUBS}/mercurial/cext ${HG_STUBS}/mercurial/thirdparty/attr

touch ${HG_STUBS}/mercurial/__init__.pyi
touch ${HG_STUBS}/mercurial/cext/__init__.pyi
touch ${HG_STUBS}/mercurial/thirdparty/__init__.pyi

ln -sf $(hg root)/mercurial/cext/*.{pyi,typed} \
       ${HG_STUBS}/mercurial/cext
ln -sf $(hg root)/mercurial/thirdparty/attr/*.{pyi,typed} \
       ${HG_STUBS}/mercurial/thirdparty/attr