Skip to content

Commit

Permalink
Removed Python 3 build options
Browse files Browse the repository at this point in the history
The RPM spec file and CMake files have been modified to
always use Python 3, so the options to build with Python 3
are no longer needed.
  • Loading branch information
edewata committed Jan 10, 2020
1 parent b3fd5f2 commit e04868d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 98 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ set(APP_SERVER "tomcat-8.0" CACHE STRING "Application server")
option(WITH_SERVER "Build server package" ON)
option(WITH_JAVADOC "Build Javadoc package" ON)
option(WITH_TEST "Run unit tests" ON)
option(WITH_PYTHON3 "Build with Python 3 support" ON)
option(WITH_PYTHON3_DEFAULT "Build server and scripts with Python 3" OFF)

set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")

Expand Down
18 changes: 8 additions & 10 deletions base/common/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,14 @@ add_custom_target(dogtag_python_client_man_docs ALL
${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Building Python Client Library manual pages")

if(WITH_PYTHON3)
install(
DIRECTORY
pki
DESTINATION
${PYTHON3_SITE_PACKAGES}
FILES_MATCHING PATTERN
*.py
)
endif()
install(
DIRECTORY
pki
DESTINATION
${PYTHON3_SITE_PACKAGES}
FILES_MATCHING PATTERN
*.py
)

install(
DIRECTORY
Expand Down
18 changes: 8 additions & 10 deletions base/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,14 @@ install(
)

# install Python libraries
if(WITH_PYTHON3_DEFAULT)
install(
DIRECTORY
python/pki/server
DESTINATION
${PYTHON3_SITE_PACKAGES}/pki
FILES_MATCHING PATTERN
*.py
)
endif()
install(
DIRECTORY
python/pki/server
DESTINATION
${PYTHON3_SITE_PACKAGES}/pki
FILES_MATCHING PATTERN
*.py
)

# install systemd scripts
install(
Expand Down
23 changes: 7 additions & 16 deletions cmake/Modules/DefinePythonSitePackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,14 @@ function(find_site_packages pythonexecutable targetname)
endfunction(find_site_packages)

# Find default Python
# When WITH_PYTHON3_DEFAULT is enabled, then require Python 3.
if (WITH_PYTHON3_DEFAULT)
if (NOT WITH_PYTHON3)
message(FATAL_ERROR "WITH_PYTHON3_DEFAULT=ON requires WITH_PYTHON3=ON")
endif(NOT WITH_PYTHON3)
# find Python interpreter
set(Python_ADDITIONAL_VERSIONS 3)
find_package(PythonInterp REQUIRED)
# FindPythonInterp doesn't restrict version with ADDITIONAL_VERSIONS
if (PYTHON_VERSION_STRING VERSION_LESS "3.5.0")
message(FATAL_ERROR "Detect Python interpreter < 3.5.0")
endif()
set(Python_ADDITIONAL_VERSIONS 3)
find_package(PythonInterp REQUIRED)
# FindPythonInterp doesn't restrict version with ADDITIONAL_VERSIONS
if (PYTHON_VERSION_STRING VERSION_LESS "3.5.0")
message(FATAL_ERROR "Detect Python interpreter < 3.5.0")
endif()
message(STATUS "Building pki.server for ${PYTHON_VERSION_STRING}")

# Find site-packages for Python 3
if (WITH_PYTHON3)
find_site_packages("python3" PYTHON3_SITE_PACKAGES)
message(STATUS "Building Python 3 pki client package")
endif(WITH_PYTHON3)
find_site_packages("python3" PYTHON3_SITE_PACKAGES)
message(STATUS "Building Python 3 pki client package")
61 changes: 1 addition & 60 deletions pki.spec
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,6 @@ Source: https://github.com/dogtagpki/pki/archive/v%{version}%{?_phase}/pki-%{ver
# Python
################################################################################

# Python 3 packages
%if 0%{!?with_python3:1}
%if 0%{?rhel} && 0%{?rhel} <= 7
# no python3
%else
%global with_python3 1
%endif
%endif

# Use Python 3 for all commands?
%if 0%{!?with_python3_default:1}
%if 0%{?rhel} && 0%{?rhel} <= 7 || 0%{?fedora} && 0%{?fedora} <= 27
%global with_python3_default 0
%else
%global with_python3_default 1
%endif
%endif

################################################################################
# Java
################################################################################
Expand Down Expand Up @@ -227,7 +209,6 @@ BuildRequires: resteasy-core >= 3.0.17-1
BuildRequires: resteasy-jackson2-provider >= 3.0.17-1
%endif

%if 0%{?with_python3}
%if 0%{?rhel}
# no pylint
%else
Expand All @@ -236,10 +217,6 @@ BuildRequires: python3-flake8 >= 2.5.4
BuildRequires: python3-pyflakes >= 1.2.3
%endif

# with_python3
%endif

%if 0%{?with_python3}
BuildRequires: python3
BuildRequires: python3-devel
BuildRequires: python3-cryptography
Expand All @@ -255,9 +232,6 @@ BuildRequires: python3-nss
BuildRequires: python3-requests >= 2.6.0
BuildRequires: python3-six

# with_python3
%endif

BuildRequires: junit
BuildRequires: jpackage-utils >= 0:1.7.5-10
%if 0%{?rhel} && 0%{?rhel} <= 7
Expand Down Expand Up @@ -417,13 +391,9 @@ BuildArch: noarch

Requires: nss >= 3.36.1

%if 0%{?with_python3_default}
Requires: python3-pki = %{version}
Requires(post): python3-pki = %{version}

# with_python3_default
%endif

# Ensure we end up with a useful installation
Conflicts: pki-symkey < %{version}
Conflicts: pki-javadoc < %{version}
Expand All @@ -434,7 +404,6 @@ Conflicts: pki-console-theme < %{version}
The PKI Base Package contains the common and client libraries and utilities
written in Python.

%if 0%{?with_python3}
################################################################################
%package -n python3-pki
################################################################################
Expand All @@ -458,9 +427,6 @@ Requires: python3-six
%description -n python3-pki
This package contains PKI client library for Python 3.

# with_python3 for python3-pki
%endif

################################################################################
%package -n pki-base-java
################################################################################
Expand Down Expand Up @@ -574,7 +540,6 @@ Requires: keyutils
Requires: policycoreutils-python-utils
%endif

%if 0%{?with_python3_default}
%if 0%{?fedora} && 0%{?fedora} <= 27
Requires: python3-pyldap
%else
Expand All @@ -584,9 +549,6 @@ Requires: python3-lxml
Requires: python3-libselinux
Requires: python3-policycoreutils

# with_python3_default
%endif

Requires: selinux-policy-targeted >= 3.13.1-159

%if 0%{?rhel} && 0%{?rhel} <= 7
Expand Down Expand Up @@ -921,10 +883,6 @@ cd build
-DRESTEASY_LIB=%{resteasy_lib} \
-DNSS_DEFAULT_DB_TYPE=%{nss_default_db_type} \
-DBUILD_PKI_CORE:BOOL=ON \
-DWITH_PYTHON3:BOOL=%{?with_python3:ON}%{!?with_python3:OFF} \
%if 0%{?with_python3_default}
-DWITH_PYTHON3_DEFAULT:BOOL=ON \
%endif
-DPYTHON_EXECUTABLE=%{__python3} \
-DWITH_TEST:BOOL=%{?with_test:ON}%{!?with_test:OFF} \
%if ! %{with server} && ! %{with ca} && ! %{with kra} && ! %{with ocsp} && ! %{with tks} && ! %{with tps}
Expand Down Expand Up @@ -1062,30 +1020,22 @@ fi
echo "Scanning Python code with pylint"
################################################################################

%if 0%{?with_python3_default}
%{__python3} ../tools/pylint-build-scan.py rpm --prefix %{buildroot}
if [ $? -ne 0 ]; then
echo "pylint for Python 3 failed. RC: $?"
exit 1
fi

# with_python3_default
%endif

################################################################################
echo "Scanning Python code with flake8"
################################################################################

%if 0%{?with_python3}
python3-flake8 --config ../tox.ini %{buildroot}
if [ $? -ne 0 ]; then
echo "flake8 for Python 3 failed. RC: $?"
exit 1
fi

# with_python3
%endif

%endif

# with server
Expand Down Expand Up @@ -1223,21 +1173,17 @@ fi
%{_javadir}/pki/pki-nsutil.jar
%{_javadir}/pki/pki-certsrv.jar

%if 0%{?with_python3}
################################################################################
%files -n python3-pki
################################################################################

%doc base/common/LICENSE
%doc base/common/LICENSE.LESSER
%if %{with server} && %{?with_python3_default}
%if %{with server}
%exclude %{python3_sitelib}/pki/server
%endif
%{python3_sitelib}/pki

# with_python3
%endif

################################################################################
%files -n pki-tools
################################################################################
Expand Down Expand Up @@ -1325,12 +1271,7 @@ fi
%{_sbindir}/pkidestroy
%{_sbindir}/pki-server
%{_sbindir}/pki-server-upgrade
%if 0%{?with_python3_default}
%{python3_sitelib}/pki/server/

# with_python3_default
%endif

%{_datadir}/pki/etc/tomcat.conf
%dir %{_datadir}/pki/deployment
%{_datadir}/pki/deployment/config/
Expand Down

0 comments on commit e04868d

Please sign in to comment.