#1 Add a platform-python subpackage
Merged 6 years ago by torsava. Opened 6 years ago by torsava.
rpms/ torsava/python-setuptools platform-python  into  master

@@ -0,0 +1,58 @@ 

+ From 62effe4db3d51c42531bf3f333bf82a3928358bf Mon Sep 17 00:00:00 2001

+ From: Tomas Orsava <torsava@redhat.com>

+ Date: Wed, 9 Aug 2017 14:46:01 +0200

+ Subject: [PATCH] Run test on a version specific pip

+ 

+ pip3 for Python 3, pip2 for Python 2, because the other might not be installed

+ ---

+  setuptools/tests/test_develop.py    | 2 +-

+  setuptools/tests/test_namespaces.py | 6 +++---

+  2 files changed, 4 insertions(+), 4 deletions(-)

+ 

+ diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py

+ index ad7cfa0..c1b6e22 100644

+ --- a/setuptools/tests/test_develop.py

+ +++ b/setuptools/tests/test_develop.py

+ @@ -167,7 +167,7 @@ class TestNamespaces:

+          target = tmpdir / 'packages'

+          # use pip to install to the target directory

+          install_cmd = [

+ -            'pip',

+ +            'pip%s' % sys.version_info.major,

+              'install',

+              str(pkg_A),

+              '-t', str(target),

+ diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py

+ index 721cad1..a71fd69 100644

+ --- a/setuptools/tests/test_namespaces.py

+ +++ b/setuptools/tests/test_namespaces.py

+ @@ -30,7 +30,7 @@ class TestNamespaces:

+          targets = site_packages, path_packages

+          # use pip to install to the target directory

+          install_cmd = [

+ -            'pip',

+ +            'pip%s' % sys.version_info.major,

+              'install',

+              str(pkg_A),

+              '-t', str(site_packages),

+ @@ -38,7 +38,7 @@ class TestNamespaces:

+          subprocess.check_call(install_cmd)

+          namespaces.make_site_dir(site_packages)

+          install_cmd = [

+ -            'pip',

+ +            'pip%s' % sys.version_info.major,

+              'install',

+              str(pkg_B),

+              '-t', str(path_packages),

+ @@ -88,7 +88,7 @@ class TestNamespaces:

+          target = tmpdir / 'packages'

+          # use pip to install to the target directory

+          install_cmd = [

+ -            'pip',

+ +            'pip%s' % sys.version_info.major,

+              'install',

+              str(pkg_A),

+              '-t', str(target),

+ -- 

+ 2.13.3

+ 

file modified
+151 -57
@@ -1,36 +1,36 @@ 

- # Dependencies for check and wheel introduce circular dependencies

- # Set this to 0 after we've bootstrapped.

- %{!?_with_bootstrap: %global bootstrap 0}

+ %global srcname setuptools

  

- %if ! 0%{?bootstrap}

- %global with_check 1

- %global build_wheel 1

- %else

- %global with_check 0

- %global build_wheel 0

- %endif

+ # Bootstrapping does not affect the platform-python-setuptools subpackage

+ %bcond_with bootstrap

+ %bcond_with tests

  

- %if 0%{?fedora}

- %global with_python3 1

- %else

+ %bcond_without python2

+ %bcond_without python3

+ %bcond_without platform_python

+ 

+ %if ! 0%{?fedora}

+ # disable Python 3 if not Fedora

+ %global _without_python3 1

  # define some macros for RHEL 6

  %global __python2 %__python

  %global python2_sitelib %python_sitelib

  %endif

  

- %global srcname setuptools

- %if 0%{?build_wheel}

- %global python2_wheelname %{srcname}-%{version}-py2.py3-none-any.whl

+ %if %{without bootstrap}

+ %global python_wheelname %{srcname}-%{version}-py2.py3-none-any.whl

+ %if %{with python2}

+ %global python2_wheelname %python_wheelname

  %global python2_record %{python2_sitelib}/%{srcname}-%{version}.dist-info/RECORD

- %if 0%{?with_python3}

- %global python3_wheelname %python2_wheelname

+ %endif

+ %if %{with python3}

+ %global python3_wheelname %python_wheelname

  %global python3_record %{python3_sitelib}/%{srcname}-%{version}.dist-info/RECORD

  %endif

  %endif

  

  Name:           python-setuptools

  Version:        36.2.0

- Release:        3%{?dist}

+ Release:        6%{?dist}

  Summary:        Easily build and distribute Python packages

  

  Group:          Applications/System
@@ -38,29 +38,44 @@ 

  URL:            https://pypi.python.org/pypi/%{srcname}

  Source0:        https://files.pythonhosted.org/packages/source/s/%{srcname}/%{srcname}-%{version}.zip

  

+ # Run test on a version specific pip: pip3 for Python 3, pip2 for Python 2,

+ # because the other might not be installed

+ Patch0:         0001-Run-test-on-a-version-specific-pip.patch

+ 

  BuildArch:      noarch

+ 

+ %if %{with python2}

  BuildRequires:  python2-devel

- %if 0%{?build_wheel}

+ %if %{without bootstrap}

  BuildRequires:  python2-pip

  BuildRequires:  python2-wheel

- %endif

- %if 0%{?with_check}

+ %endif # without bootstrap

+ %if %{with test}

  BuildRequires:  python2-pytest

  BuildRequires:  python2-mock

  BuildRequires:  python2-backports-unittest_mock

- %endif # with_check

+ %endif # with tests

+ %endif # with python2

  

- %if 0%{?with_python3}

+ %if %{with python3}

  BuildRequires:  python3-devel

- %if 0%{?with_check}

+ %if %{with tests}

  BuildRequires:  python3-pytest

  BuildRequires:  python3-mock

- %endif # with_check

- %if 0%{?build_wheel}

+ %endif # with tests

+ %if %{without bootstrap}

  BuildRequires:  python3-pip

  BuildRequires:  python3-wheel

- %endif # build_wheel

- %endif # with_python3

+ %endif # without bootstrap

+ %endif # with python3

+ 

+ %if %{with platform_python}

+ BuildRequires:  platform-python-devel

+ BuildRequires:  platform-python-libs-devel

+ %if %{with tests}

+ BuildRequires:  platform-python-pytest

+ %endif # with tests

+ %endif # with platform_python

  

  # We're now back to setuptools as the package.

  # Keep the python-distribute name active for a few releases.  Eventually we'll
@@ -68,7 +83,6 @@ 

  Provides: python-distribute = %{version}-%{release}

  Obsoletes: python-distribute < 0.6.36-2

  

- 

  %description

  Setuptools is a collection of enhancements to the Python distutils that allow

  you to more easily build and distribute Python packages, especially ones that
@@ -77,9 +91,12 @@ 

  This package also contains the runtime components of setuptools, necessary to

  execute the software that requires pkg_resources.py.

  

+ 

+ %if %{with python2}

  %package -n python2-setuptools

  Summary:        Easily build and distribute Python packages

  %{?python_provide:%python_provide python2-setuptools}

+ 

  %description -n python2-setuptools

  Setuptools is a collection of enhancements to the Python distutils that allow

  you to more easily build and distribute Python packages, especially ones that
@@ -88,16 +105,15 @@ 

  This package also contains the runtime components of setuptools, necessary to

  execute the software that requires pkg_resources.py.

  

- %if 0%{?with_python3}

+ %endif # with python2

+ 

+ 

+ %if %{with python3}

  %package -n python3-setuptools

  Summary:        Easily build and distribute Python 3 packages

  Group:          Applications/System

  %{?python_provide:%python_provide python3-setuptools}

  

- # Note: Do not need to Require python3-backports-ssl_match_hostname because it

- # has been present since python3-3.2.  We do not ship python3-3.0 or

- # python3-3.1 anywhere

- 

  %description -n python3-setuptools

  Setuptools is a collection of enhancements to the Python 3 distutils that allow

  you to more easily build and distribute Python 3 packages, especially ones that
@@ -106,11 +122,30 @@ 

  This package also contains the runtime components of setuptools, necessary to

  execute the software that requires pkg_resources.py.

  

- %endif # with_python3

+ %endif # with python3

+ 

+ 

+ %if %{with platform_python}

+ %package -n platform-python-setuptools

+ Summary:        Easily build and distribute Python 3 packages

+ Group:          Applications/System

+ 

+ %description -n platform-python-setuptools

+ Setuptools is a collection of enhancements to the Python 3 distutils that allow

+ you to more easily build and distribute Python 3 packages, especially ones that

+ have dependencies on other packages.

+ 

+ This package also contains the runtime components of setuptools, necessary to

+ execute the software that requires pkg_resources.py.

+ 

+ %endif # with platform_python

+ 

  

  %prep

  %setup -q -n %{srcname}-%{version}

  

+ %patch0 -p1

+ 

  # We can't remove .egg-info (but it doesn't matter, since it'll be rebuilt):

  #  The problem is that to properly execute setuptools' setup.py,

  #   it is needed for setuptools to be loaded as a Distribution
@@ -130,27 +165,48 @@ 

  # These tests require internet connection

  rm setuptools/tests/test_integration.py 

  

+ 

  %build

- %if 0%{?build_wheel}

+ %if %{with python2}

+ %if %{without bootstrap}

  %py2_build_wheel

  %else

  %py2_build

  %endif

+ %endif # with python2

  

- %if 0%{?with_python3}

- %if 0%{?build_wheel}

+ %if %{with python3}

+ %if %{without bootstrap}

  %py3_build_wheel

  %else

  %py3_build

  %endif

- %endif # with_python3

+ %endif # with python3

+ 

+ %if %{with platform_python}

+ # Platform Python build does not need to build the wheel

+ %platform_py_build

+ %endif # with platform_python

+ 

  

  %install

- # Must do the python3 install first because the scripts in /usr/bin are

- # overwritten with every setup.py install (and we want the python2 version

- # to be the default for now).

- %if 0%{?with_python3}

- %if 0%{?build_wheel}

+ # Must do the platform-python and python3 install first because the scripts in

+ # /usr/bin are overwritten with every setup.py install (and we want the python2

+ # version to be the default for now).

+ %if %{with platform_python}

+ %platform_py_install

+ 

+ # Delete all executables under /usr/bin, we don't want them for platform-python

+ rm %{buildroot}%{_bindir}/*

+ 

+ rm -rf %{buildroot}%{platform_python_sitelib}/setuptools/tests

+ 

+ find %{buildroot}%{platform_python_sitelib} -name '*.exe' | xargs rm -f

+ %endif # with platform_python

+ 

+ 

+ %if %{with python3}

+ %if %{without bootstrap}

  %py3_install_wheel %{python3_wheelname}

  

  # TODO: we have to remove this by hand now, but it'd be nice if we wouldn't have to
@@ -163,57 +219,95 @@ 

  %endif

  

  rm -rf %{buildroot}%{python3_sitelib}/setuptools/tests

- %if 0%{?build_wheel}

+ %if %{without bootstrap}

  sed -i '/^setuptools\/tests\//d' %{buildroot}%{python3_record}

  %endif

  

  find %{buildroot}%{python3_sitelib} -name '*.exe' | xargs rm -f

- %endif # with_python3

+ %endif # with python3

  

- %if 0%{?build_wheel}

+ 

+ %if %{with python2}

+ %if %{without bootstrap}

  %py2_install_wheel %{python2_wheelname}

  %else

  %py2_install

  %endif

  

  rm -rf %{buildroot}%{python2_sitelib}/setuptools/tests

- %if 0%{?build_wheel}

+ %if %{without bootstrap}

  sed -i '/^setuptools\/tests\//d' %{buildroot}%{python2_record}

  %endif

  

  find %{buildroot}%{python2_sitelib} -name '*.exe' | xargs rm -f

+ %endif # with python2

  

  # Don't ship these

  rm -r docs/{Makefile,conf.py,_*}

  

- %if 0%{?with_check}

+ 

+ %if %{with tests}

  %check

+ %if %{with python2}

  #LANG=en_US.utf8 PYTHONPATH=$(pwd) py.test

+ %endif # with python2

  

- %if 0%{?with_python3}

+ %if %{with python3}

  LANG=en_US.utf8 PYTHONPATH=$(pwd) py.test-%{python3_version}

- %endif # with_python3

- %endif # with_check

+ %endif # with python3

+ 

+ %if %{with platform_python}

+ LANG=en_US.utf8 PYTHONPATH=$(pwd) %{__platform_python} -m pytest

+ %endif # with platform_python

+ %endif # with tests

+ 

  

+ %if %{with python2}

  %files -n python2-setuptools

  %license LICENSE

  %doc docs/* CHANGES.rst README.rst

  %{python2_sitelib}/*

  %{_bindir}/easy_install

  %{_bindir}/easy_install-2.*

+ %endif # with python2

  

- %if 0%{?with_python3}

+ %if %{with python3}

  %files -n python3-setuptools

- %license LICENSE CHANGES.rst README.rst

- %doc docs/*

+ %license LICENSE

+ %doc docs/* CHANGES.rst README.rst

  %{python3_sitelib}/easy_install.py

  %{python3_sitelib}/pkg_resources/

  %{python3_sitelib}/setuptools*/

  %{python3_sitelib}/__pycache__/*

  %{_bindir}/easy_install-3.*

- %endif # with_python3

+ %endif # with python3

+ 

+ %if %{with platform_python}

+ %files -n platform-python-setuptools

+ %license LICENSE

+ %doc docs/* CHANGES.rst README.rst

+ %{platform_python_sitelib}/easy_install.py

+ %{platform_python_sitelib}/pkg_resources/

+ %{platform_python_sitelib}/setuptools*/

+ %{platform_python_sitelib}/__pycache__/*

+ %endif # with platform_python

+ 

  

  %changelog

+ * Wed Aug 09 2017 Tomas Orsava <torsava@redhat.com> - 36.2.0-6

+ - Add the platform-python subpackage

+ - Disable tests so platform-python stack can be bootstrapped

+   (https://fedoraproject.org/wiki/Changes/Platform_Python_Stack)

+ 

+ * Wed Aug 09 2017 Tomas Orsava <torsava@redhat.com> - 36.2.0-5

+ - Add Patch 0 that fixes a test suite failure on Python 3 in absence of

+   the Python 2 version of pip

+ - Move docs to their proper place

+ 

+ * Wed Aug 09 2017 Tomas Orsava <torsava@redhat.com> - 36.2.0-4

+ - Switch macros to bcond's and make Python 2 optional to facilitate building

+   the Python 2 and Python 3 modules.

+ 

  * Tue Aug 08 2017 Michal Cyprian <mcyprian@redhat.com> - 36.2.0-3

  - Revert "Add --executable option to easy_install command"

    This enhancement is currently not needed and it can possibly

These are changes needed for the Platform Python Stack Fedora change.

The Platform module on which everything else will depend will contain dnf, and that needs Python. To make everything work, we need to build an independent minimal Python stack containing all the libraries needed to build and run dnf, and that includes python-setuptools.

We're creating the pull request now, so you can review the changes, but please don't build the platform-python subpackage until we push platform-python itself into Rawhide/f27.

We'll let you know when this can be built (or we'll build it).

If you have any comments on the change, please let us know by this Thursday (2017-08-17). We will have to push and build everything by the end of the week to comply with the Fedora 27 schedule.
If the change looks good, you can merge it -- or let us know and we'll handle the merging and building for you.

Bootstrapping pytest

Because the tests of setuptools need pytest and at the same time pytest needs setuptools to be built, setuptools first needs to be built without tests. Therefore I have disabled the bcond'ed tests for now in this PR. When pytest is ready, we'll rebuild this package with tests.

4 new commits added

  • Rename bcond check to tests and add platform_python tests
  • Add the platform-python subpackage
  • Add Patch that fixes a test suite failure on Python 3
  • Switch macros to bcond's and make Python 2 optional
6 years ago

Since this is at the beginning of the build order, we'll merge & build on Thursday morning if no feedback is given by then.

Looks fine to me.

Note that we are behind upstream currently version wise... I am trying to get the new needed pytest packages reviewed and added in so we can run tests on the newer versions.

Merge and build when you are ready.

@kevin thanks. CC me (mhroncok @ rh) on the new pytest packages if you need a reviewer.

Pull-Request has been merged by torsava

6 years ago