Reicher82 / python / sbpython3

Forked from python/sbpython3 3 years ago
Clone
Blob Blame History Raw
#!/bin/sh

# pydist.sh: a reference-only, development-time script
# objective: generate pydist.in based on the scripts found
#            under $PYTHON_SRCDIR/Lib, excluding the 'test'
#            and 'plat-*' sub-directories.

set -eu

export LC_ALL=C

if [ -z "${PYTHON_SRCDIR:-}" ]; then
	printf 'Variable PYTHON_SRCDIR is not set!\n'
	exit 2
fi

cd -- "$PYTHON_SRCDIR/Lib"

pydirs=$(find . -type d | grep -v -e '^\./test' -e '^./plat-' | sort)

for pydir in $pydirs; do
	if [ $pydir = '.' ]; then
		pysrcs=*.py
		printf 'PYCDIR(,1)_\n'
	else
		pydir=${pydir#./}

		if ls $pydir/*.py > /dev/null 2>&1; then
			pysrcs=$pydir/*.py
			printf 'PYCDIR(%s,1)\n' $pydir
		else
			pysrcs=
			printf 'PYCDIR(%s,0)\n' $pydir
		fi

	fi

	for pysrc in $(printf '%s' "$pysrcs" | sort); do
		if [ "${pysrc##*/}" != 'py3_test_grammar.py' ]; then
			printf 'PYCSRC(%s)\n' "$pysrc"
		fi
	done

	printf '\n'
done