################################################################################
#
# python3-distutils.cygclass - for building Python 3.x modules with Distutils
#
# Part of cygport - Cygwin packaging application
# Copyright (C) 2006-2020 Cygport authors
# Provided by the Cygwin project <https://cygwin.com/>
#
# cygport is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cygport is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cygport.  If not, see <https://www.gnu.org/licenses/>.
#
################################################################################

warning "python3-distutils.cygclass: python distutils is deprecated. Please migrate to the python-wheel cygclass."

#****h* Cygclasses/python3-distutils.cygclass
#  DESCRIPTION
#  Distutils is a deprecated method for building and installing Python
#  libraries and programs.  The build is defined by a setup.py file in the
#  top source directory, which controls the installation of files and the
#  building of C Python extensions.  Many such packages are hosted on the
#  Python Package Index (PyPI, previously known as Cheeseshop).
#
#  This cygclass handles the building of Python 3.x distutils-based packages.
#  INHERITS
#  python.org.cygclass, python3.cygclass
#  REQUIRES
#  python3
#****
ORIG_PN=${ORIG_PN:-${PN#python3-}}

inherit python.org python3

#****C* python3-distutils.cygclass/python3_distutils_compile
#  SYNOPSIS
#  python3_distutils_compile [OPTIONS]
#  DESCRIPTION
#  Runs the setup.py 'build' command, to which any arguments are passed.
#****
python3_distutils_compile() {
	if [ ! -e setup.py ]
	then
		error "No Python Distutils module detected"
	fi

	${PYTHON3} setup.py build "${@}" || error "setup.py build failed"
}

#****I* python3-distutils.cygclass/python3_distutils_install
#  SYNOPSIS
#  python3_distutils_install [OPTIONS]
#  DESCRIPTION
#  Runs the setup.py 'install' phase, setting the root argument to install
#  into $D.  All arguments are passed to the setup.py 'install' command.
#****
python3_distutils_install() {
	if [ ! -e setup.py ]
	then
		error "No Python Distutils module detected"
	fi

	${PYTHON3} setup.py "${@}" install --no-compile --prefix=/usr --root=${D} || error "setup.py install failed"
}

#****o* python3-distutils.cygclass/src_compile (python3-distutils)
#  DEFINITION
src_compile() {
	lndirs
	cd ${B}
	python3_distutils_compile
}
#****

#****o* python3-distutils.cygclass/src_install (python3-distutils)
#  DEFINITION
src_install() {
	cd ${B}
	python3_distutils_install
}
#****

readonly -f python3_distutils_compile python3_distutils_install
