##
##  python-setup.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package version
%define       V_python           3.14
%define       V_semantic_version 2.10.0
%define       V_setuptools       80.9.0
%define       V_setuptools_git   1.2
%define       V_setuptools_rust  1.6.0
%define       V_pip              25.2
%define       V_pbr              7.0.1
%define       V_cython           3.1.4
%define       V_incremental      24.7.2
%define       V_packaging        25.0
%define       V_flit             3.12.0
%define       V_versioneer       0.29

#   package information
Name:         python-setup
Summary:      Python Setup Tools
URL:          http://pypi.python.org/pypi/setuptools/
Vendor:       Phillip J. Eby
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Language
License:      PSF/ZPL
Version:      %{V_python}
Release:      20251008

#   list of sources
Source0:      https://files.pythonhosted.org/packages/source/s/setuptools/setuptools-%{V_setuptools}.tar.gz
Source1:      https://files.pythonhosted.org/packages/source/p/pip/pip-%{V_pip}.tar.gz
Source2:      https://files.pythonhosted.org/packages/source/p/pbr/pbr-%{V_pbr}.tar.gz
Source3:      https://files.pythonhosted.org/packages/source/c/cython/cython-%{V_cython}.tar.gz
Source4:      https://files.pythonhosted.org/packages/source/s/setuptools-git/setuptools-git-%{V_setuptools_git}.tar.gz
Source5:      https://files.pythonhosted.org/packages/source/s/setuptools-rust/setuptools-rust-%{V_setuptools_rust}.tar.gz
Source6:      https://files.pythonhosted.org/packages/source/i/incremental/incremental-%{V_incremental}.tar.gz
Source7:      https://files.pythonhosted.org/packages/source/p/packaging/packaging-%{V_packaging}.tar.gz
Source8:      https://files.pythonhosted.org/packages/source/s/semantic_version/semantic_version-%{V_semantic_version}.tar.gz
Source9:      https://files.pythonhosted.org/packages/source/f/flit/flit-%{V_flit}.tar.gz
Source10:     https://files.pythonhosted.org/packages/source/f/flit_core/flit_core-%{V_flit}.tar.gz
Source11:     https://files.pythonhosted.org/packages/source/v/versioneer/versioneer-%{V_versioneer}.tar.gz
Source12:     https://bootstrap.pypa.io/get-pip.py
Patch0:       python-setup.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, python >= %{V_python}
PreReq:       OpenPKG, openpkg >= 20160101, python >= %{V_python}

%description
    This packages provides the Python setup tools.

%track
    prog python-setup:setuptools = {
        version   = %{V_setuptools}
        url       = http://pypi.python.org/pypi/setuptools/
        regex     = setuptools-(__VER__)\.tar\.gz
    }
    prog python-setup:pip = {
        version   = %{V_pip}
        url       = http://pypi.python.org/pypi/pip/
        regex     = pip-(__VER__)\.tar\.gz
    }
    prog python-setup:pbr = {
        version   = %{V_pbr}
        url       = http://pypi.python.org/pypi/pbr/
        regex     = pbr-(__VER__)\.tar\.gz
    }
    prog python-setup:cython = {
        version   = %{V_cython}
        url       = http://pypi.python.org/pypi/cython/
        regex     = cython-(__VER__)\.tar\.gz
    }
    prog python-setup:setuptools-git = {
        version   = %{V_setuptools_git}
        url       = http://pypi.python.org/pypi/setuptools-git/
        regex     = setuptools-git-(__VER__)\.tar\.gz
    }
    prog python-setup:setuptools-rust = {
        version   = %{V_setuptools_rust}
        url       = http://pypi.python.org/pypi/setuptools-rust/
        regex     = setuptools-rust-(__VER__)\.tar\.gz
    }
    prog python-setup:incremental = {
        version   = %{V_incremental}
        url       = http://pypi.python.org/pypi/incremental/
        regex     = incremental-(__VER__)\.tar\.gz
    }
    prog python-setup:packaging = {
        version   = %{V_packaging}
        url       = http://pypi.python.org/pypi/packaging/
        regex     = packaging-(__VER__)\.tar\.gz
    }
    prog python-setup:semantic_version = {
        version   = %{V_semantic_version}
        url       = http://pypi.python.org/pypi/semantic_version/
        regex     = semantic_version-(__VER__)\.tar\.gz
    }
    prog python-setup:flit = {
        version   = %{V_flit}
        url       = http://pypi.python.org/pypi/flit/
        regex     = flit-(__VER__)\.tar\.gz
    }
    prog python-setup:versioneer = {
        version   = %{V_versioneer}
        url       = http://pypi.python.org/pypi/versioneer/
        regex     = versioneer-(__VER__)\.tar\.gz
    }

%prep
    %setup -q -c
    %setup -q -T -D -a 1
    %setup -q -T -D -a 2
    %setup -q -T -D -a 3
    %setup -q -T -D -a 4
    %setup -q -T -D -a 5
    %setup -q -T -D -a 6
    %setup -q -T -D -a 7
    %setup -q -T -D -a 8
    %setup -q -T -D -a 9
    %setup -q -T -D -a 10
    %setup -q -T -D -a 11
    %patch -p0

%build
    (   cd setuptools-%{V_setuptools}
        mv "setuptools/script (dev).tmpl" "setuptools/script-dev.tmpl"
        mv "setuptools/_vendor/jaraco/text/Lorem ipsum.txt" "setuptools/_vendor/jaraco/text/Lorem-ipsum.txt"
        rm -f "setuptools/command/launcher manifest.xml"
        rm -f "build/lib/setuptools/command/launcher manifest.xml"
    ) || exit $?

%install
    export PYTHONPATH=$RPM_BUILD_ROOT%{l_prefix}/lib/python%{V_python}/site-packages
    (   cd setuptools-%{V_setuptools}
        %{l_prefix}/bin/python setup.py install \
            --root=$RPM_BUILD_ROOT \
            --prefix=%{l_prefix}
    ) || exit $?
    (   cd pip-%{V_pip}
        HOME=`pwd` %{l_prefix}/bin/python \
            %{SOURCE get-pip.py} \
            --root=$RPM_BUILD_ROOT \
            --prefix=%{l_prefix} \
            --ignore-installed \
            --no-deps \
            .
    ) || exit $?
    PATH=$PATH:$RPM_BUILD_ROOT%{l_prefix}/bin
    (   cd semantic_version-%{V_semantic_version}
        %{l_prefix}/bin/python setup.py install \
            --root=$RPM_BUILD_ROOT \
            --prefix=%{l_prefix}
    ) || exit $?
    (   cd pbr-%{V_pbr}
        %{l_prefix}/bin/python setup.py install \
            --root=$RPM_BUILD_ROOT \
            --prefix=%{l_prefix}
    ) || exit $?
    (   cd cython-%{V_cython}
        %{l_prefix}/bin/python setup.py install \
            --root=$RPM_BUILD_ROOT \
            --prefix=%{l_prefix}
    ) || exit $?
    (   cd setuptools-git-%{V_setuptools_git}
        %{l_prefix}/bin/python setup.py install \
            --root=$RPM_BUILD_ROOT \
            --prefix=%{l_prefix}
    ) || exit $?
    (   cd setuptools-rust-%{V_setuptools_rust}
        HOME=`pwd` %{l_prefix}/bin/python \
            -m pip install \
            --root=$RPM_BUILD_ROOT \
            --prefix=%{l_prefix} \
            --ignore-installed \
            --no-deps \
            .
    ) || exit $?
    (   cd incremental-%{V_incremental}
        HOME=`pwd` %{l_prefix}/bin/python \
            -m pip install \
            --root=$RPM_BUILD_ROOT \
            --prefix=%{l_prefix} \
            --ignore-installed \
            --no-deps \
            .
    ) || exit $?
    (   cd packaging-%{V_packaging}
        HOME=`pwd` %{l_prefix}/bin/python \
            -m pip install \
            --root=$RPM_BUILD_ROOT \
            --prefix=%{l_prefix} \
            --ignore-installed \
            --no-deps \
            .
    ) || exit $?
    (   cd flit_core-%{V_flit}
        HOME=`pwd` %{l_prefix}/bin/python \
            -m pip install \
            --root=$RPM_BUILD_ROOT \
            --prefix=%{l_prefix} \
            --ignore-installed \
            --no-deps \
            .
    ) || exit $?
    (   cd flit-%{V_flit}
        HOME=`pwd` %{l_prefix}/bin/python \
            -m pip install \
            --root=$RPM_BUILD_ROOT \
            --prefix=%{l_prefix} \
            --ignore-installed \
            --no-deps \
            .
    ) || exit $?
    (   cd versioneer-%{V_versioneer}
        HOME=`pwd` %{l_prefix}/bin/python \
            -m pip install \
            --root=$RPM_BUILD_ROOT \
            --prefix=%{l_prefix} \
            --ignore-installed \
            --no-deps \
            .
    ) || exit $?
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

