# Fedora: Copy CMake files to the SRCDIR for setuptools to find them.
# https://src.fedoraproject.org/rpms/python-pyside6/blob/rawhide/f/python-pyside6.spec#_282
abinfo "Copying CMake files ..."
cp -v "$BLDDIR"/sources/shiboken6/shibokenmodule/{*.py,*.txt} "$SRCDIR"/sources/shiboken6/shibokenmodule/
cp -v "$BLDDIR"/sources/pyside6/PySide6/*.py "$SRCDIR"/sources/pyside6/PySide6/

# They are NOT user facing tools. Get them out of here.
abinfo "Moving Pyside6 scripts out of /usr/bin ..."
mkdir -pv "$PKGDIR"/usr/lib/python${ABPY3VER}/site-packages/shiboken6_generator/scripts
mkdir -pv "$PKGDIR"/usr/lib/python${ABPY3VER}/site-packages/PySide6/scripts
for file in $(find "$PKGDIR"/usr/bin -mindepth 1 -maxdepth 1 -printf '%P\n') ; do
	if [ "$file" = "shiboken6" ] ; then
		 continue
	fi
	if [ "$file" = "shiboken_tool.py" ] ; then
		# It belongs to shiboken6_generator.
		mv -v "$PKGDIR"/usr/bin/"$file" \
			"$PKGDIR"/usr/lib/python${ABPY3VER}/site-packages/shiboken6_generator/scripts/
		continue
	fi
	# The rest of them goes to PySide6/scrpits.
	mv -v "$PKGDIR"/usr/bin/"$file" \
		"$PKGDIR"/usr/lib/python${ABPY3VER}/site-packages/PySide6/scripts/
done

abinfo "Installing shiboken6 proper for shiboken6_generator ..."
cp -v "$BLDDIR"/sources/shiboken6/generator/shiboken6 "$PKGDIR"/usr/lib/python${ABPY3VER}/site-packages/shiboken6_generator/shiboken6

abinfo "Installing tools ..."
python3 "$SRCDIR"/setup.py --qtpaths=/usr/lib/qt6/bin/qtpaths install_scripts --install-dir="$PKGDIR"/usr/bin/

abinfo "Generating egg_info ..."
env PATH="/usr/lib/qt6/bin:$PATH" python3 "$SRCDIR"/setup.py egg_info

abinfo "Installing Python Egg-info files ..."
for name in PySide6 shiboken6 shiboken6_generator; do
  cp -av $name.egg-info \
        "$PKGDIR"/usr/lib/python${ABPY3VER}/site-packages/
done
