From 175805ab7e115bc9b031af9b4f23d2520d33275a Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Wed, 30 Sep 2015 14:59:49 +0200 Subject: Python packaging of PKI client library A new setup.py in base/common/python makes it possible to bundle the pki client library and upload it on PyPI. The setup.py in the root directory is only used for tox and testing. It's a cleaner and less fragile approach than to support two different build flavors with one setup.py The 'release' alias from setup.cfg creates and uploads a source distribution and an universal wheel: $ sudo yum install python-wheel python-setuptools $ cd base/common/python $ python setup.py release The 'packages' alias just creates the source distribution and wheel: $ python setup.py packages The version number is taken from the Version and Release fields of pki-core.spec. --- .gitignore | 5 +++ base/common/python/setup.cfg | 6 +++ base/common/python/setup.py | 99 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 base/common/python/setup.cfg create mode 100644 base/common/python/setup.py diff --git a/.gitignore b/.gitignore index 172610bb1..2feeda176 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,8 @@ dist MANIFEST *.pyc __pycache__ + +/base/common/python/build/ +/base/common/python/dist/ +/base/common/python/dogtag_pki.egg-info/ + diff --git a/base/common/python/setup.cfg b/base/common/python/setup.cfg new file mode 100644 index 000000000..ad4348612 --- /dev/null +++ b/base/common/python/setup.cfg @@ -0,0 +1,6 @@ +[bdist_wheel] +universal = 1 + +[aliases] +packages = clean --all egg_info bdist_wheel sdist --format=zip +release = packages register upload diff --git a/base/common/python/setup.py b/base/common/python/setup.py new file mode 100644 index 000000000..16c1d1760 --- /dev/null +++ b/base/common/python/setup.py @@ -0,0 +1,99 @@ +# Authors: +# Christian Heimes +# +# This program 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; version 2 of the License. +# +# This program 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 this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2015 Red Hat, Inc. +# All rights reserved. +# +"""Dogtag client library + +In order to build wheels the wheel and setuptools packages are required: + + $ sudo yum install python-wheel python-setuptools + +The 'release' alias builds and uploads a source distribution and universal +wheel. The version and release number are taken from pki-core.spec file. + + $ python setup.py release + +The 'packages' alias just creates the files locally: + + $ python setup.py packages + +For a complete list of all available commands (except for aliases): + + $python setup.py --help-commands +""" + +import re +try: + from setuptools import setup +except ImportError: + from distutils.core import setup + + +def get_version(specfile='../../../specs/pki-core.spec'): + version_re = re.compile('^Version:\s*(\d+\.\d+\.\d+)') + release_re = re.compile('^Release:.*?([\d\.]+)') + version = release = None + with open(specfile) as f: + for line in f: + if version is None: + match = version_re.match(line) + if match is not None: + version = match.group(1) + if release is None: + match = release_re.match(line) + if match is not None: + release = match.group(1) + if version is not None and release is not None: + break + if version is None or release is None: + raise ValueError(version, release) + return "%s.%s" % (version, release) + +VERSION = get_version() + +setup( + author='Dogtag Certificate System Team', + author_email='pki-devel@redhat.com', + name='dogtag-pki', + version=VERSION, + description='Client library for Dogtag Certificate System', + long_description="""\ +This package contains the REST client for Dogtag PKI. + +The Dogtag Certificate System is an enterprise-class open source +Certificate Authority (CA). It is a full-featured system, and has been +hardened by real-world deployments. It supports all aspects of certificate +lifecycle management, including key archival, OCSP and smartcard management, +and much more. The Dogtag Certificate System can be downloaded for free +and set up in less than an hour.""", + license='GPL', + keywords='pki x509 cert certificate', + url='http://pki.fedoraproject.org/', + packages=['pki'], + requirements=['python-nss', 'requests', 'six'], + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Web Environment', + 'Intended Audience :: System Administrators', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.4', + 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)', + 'Topic :: Security :: Cryptography', + ], +) -- cgit