From b1b5c494502495e8361c24da768b079acadc4417 Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 16 Dec 2018 19:17:12 -0500 Subject: project: imported pydist.sh from sbpython2, revised for python-3.x. --- project/pydist.sh | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100755 project/pydist.sh (limited to 'project/pydist.sh') diff --git a/project/pydist.sh b/project/pydist.sh new file mode 100755 index 0000000..14617b8 --- /dev/null +++ b/project/pydist.sh @@ -0,0 +1,154 @@ +#!/bin/sh + +# pydist.sh: a reference-only, development-time script +# objective: generate pydist.mk based on the scripts found +# under $PYTHON_SRCDIR/Lib, excluding the 'test' +# and 'plat-*' sub-directories. + +if [ -z "$PYTHON_SRCDIR" ]; then + printf 'Variable PYTHON_SRCDIR is not set!\n' + exit 2 +fi + +cd "$PYTHON_SRCDIR"/Lib || exit 2 + +pydirs=$(find . -type d | grep -v -e '^\./test' -e '^./plat-' | sort) +pysrcs=$(mktemp) +pypycs=$(mktemp) + +if [ -z $pysrcs ]; then + exit 2 +fi + +if [ -z $pypycs ]; then + exit 2 +fi + +printf 'PYCOPY = $(PROJECT_DIR)/project/pycopy.sh\n' +printf 'PYCABI = cpython-$(PYTHON_MAJOR)$(PYTHON_MINOR)\n' +printf 'PYCOPY_PYTHON = $(NICKNAME)\n' +printf 'PYCOPY_PREFIX = $(PREFIX)\n\n' + +printf 'PYDIST_LIBDIR = lib\n' +printf 'PYDIST_PYCDIR = lib/$(NICKNAME)\n\n\n' + +printf 'PYDIST_SYSCFG_SRCS = \\\n' +printf '\t$(PYDIST_PYCDIR)/./_sysconfigdata__$(PYTHON_PLATFORM)_.py\n\n' + +cpvar=$(printf '\tcp -p $(%s)' 'PYDIST_SYSCFG_SRCS') +printf '%-80s$(DESTDIR)/$(LIBDIR)/$(PACKAGE)\n' "$cpvar" >> $pysrcs + +cpvar=$(printf '\tcp -p $(%s:$(PYDIST_PYCDIR)/./%%.py=$(PYDIST_PYCDIR)/./__pycache__/%%.%s.pyc)' \ + 'PYDIST_SYSCFG_SRCS' '$(PYCABI)') +printf '%s \\\n\t\t$(DESTDIR)/$(LIBDIR)/$(PACKAGE)/./__pycache\n' "$cpvar" >> $pypycs + +for pydir in $pydirs; do + if [ $(find "$pydir" -maxdepth 1 -name '*.py' | wc -l) != '0' ]; then + pyvar=$(printf "PYDIST_%s_SRCS" $pydir \ + | sed -e 's@\_\.@@g' -e 's@/@_@g' -e 's@-@_@g' \ + | tr "[:lower:]" "[:upper:]") + + printf "%s = "'\\'"\n" "$pyvar" + pyvars="$pyvars $pyvar" + + cpvar=$(printf '\tcp -p $(%s)' "$pyvar") + printf '%-80s$(DESTDIR)/$(LIBDIR)/$(PACKAGE)/%s\n' "$cpvar" "$pydir" >> $pysrcs + + case $pydir/ in + ./lib2to3/tests/data/* ) + ;; + * ) + cpvar=$(printf '\tcp -p $(%s:$(PYDIST_PYCDIR)/%s/%%.py=$(PYDIST_PYCDIR)/%s/./__pycache__/%%.%s.pyc)' \ + "$pyvar" $pydir $pydir '$(PYCABI)') + printf '%s \\\n\t\t$(DESTDIR)/$(LIBDIR)/$(PACKAGE)/%s/./__pycache__\n' "$cpvar" "$pydir" >> $pypycs + esac + + for pysrc in $pydir/*.py; do + if [ $pysrc != $pydir/py3_test_grammar.py ]; then + printf "\t"'$(PYDIST_PYCDIR)/'"%s "'\\'"\n" $pysrc + fi + done | sort; + + echo + fi +done + +printf '\n\n' +printf 'pydist.tag:\n' + +for pydir in $pydirs; do + if [ $pydir == '.' ]; then + printf '\tmkdir -p $(PYDIST_PYCDIR)/./__pycache__\n' + else + printf '\tmkdir -p $(PYDIST_PYCDIR)/%s\n' $pydir + printf '\tmkdir -p $(PYDIST_PYCDIR)/%s/./__pycache__\n' $pydir + fi +done + +printf '\ttouch pydist.tag\n' +printf '\n\n' + +for pydir in $pydirs; do + pyrule=$(printf '$(PYDIST_PYCDIR)/'"%s/%s.py:" "$pydir" '%') + printf "%-80s"'$(SOURCE_DIR)/Lib/'"%s/%s.py"' pydist.tag\n' "$pyrule" "$pydir" '%' + + pyrule_python=$(printf "\t\t"'PYCOPY_PYTHON=$(PYCOPY_PYTHON)') + pyrule_prefix=$(printf "\t\t"'PYCOPY_PREFIX=$(PYCOPY_PREFIX)') + pyrule_dstdir=$(printf "\t\t"'PYCOPY_DSTDIR=$(PYDIST_PYCDIR)/'"%s" "$pydir") + + printf "%s"' \\\n' "$pyrule_python" + printf "%s"' \\\n' "$pyrule_prefix" + printf "%s"' \\\n' "$pyrule_dstdir" + printf '\t\t$(PYCOPY) $<\n\n' +done + +printf 'PYDIST_PY_SRCS = \\\n' + +for pyvar in PYDIST_SYSCFG_SRCS $pyvars; do + printf "\t"'$('"%s"') \\\n' $pyvar +done + +printf '\n\n' +printf 'pydist-py-srcs:\t$(PYDIST_PY_SRCS)\n\n' +printf 'pydist-py-srcs-clean:\n' +printf '\trm -f $(PYDIST_PY_SRCS)\n' +printf '\trm -f pydist.tag\n\n' +printf 'clean:\tpydist-py-srcs-clean\n\n' + +printf '\n\n' +printf 'pydist-install-tree:\n' + +for pydir in $pydirs; do + if [ $pydir == '.' ]; then + printf '\tmkdir -p $(DESTDIR)/$(LIBDIR)/$(PACKAGE)/./__pycache__\n' + else + printf '\tmkdir -p $(DESTDIR)/$(LIBDIR)/$(PACKAGE)/%s\n' $pydir + printf '\tmkdir -p $(DESTDIR)/$(LIBDIR)/$(PACKAGE)/%s/./__pycache__\n' $pydir + fi +done + +printf '\n\n' +printf 'pydist-install-py: $(PYDIST_PY_SRCS)\n' +printf 'pydist-install-py: pydist-install-tree\n' +printf 'pydist-install-py:\n' +cat $pysrcs + +printf '\n\n' +printf 'pydist-install-pyc: $(PYCGEN_OBJS)\n' +printf 'pydist-install-pyc: pydist-install-tree\n' +printf 'pydist-install-pyc:\n' +cat $pypycs + +printf '\n\n' +printf 'install-app:\tpydist-install-py\n' +printf 'install-app:\tpydist-install-pyc\n' + +printf '\n\n' +printf '.PHONY:\tpydist-py-srcs\n' +printf '.PHONY:\tpydist-py-srcs-clean\n\n' + +printf '.PHONY:\tpydist-install-tree\n' +printf '.PHONY:\tpydist-install-py\n' +printf '.PHONY:\tpydist-install-pyc\n' + +exit 0 -- cgit v1.2.3