lemur/setup.py

181 lines
6.0 KiB
Python
Raw Normal View History

2015-06-22 22:47:27 +02:00
"""
Lemur
=====
2015-09-22 00:16:04 +02:00
Is a TLS management and orchestration tool.
2015-06-22 22:47:27 +02:00
:copyright: (c) 2015 by Netflix, see AUTHORS for more
:license: Apache, see LICENSE for more details.
"""
from __future__ import absolute_import
2015-12-01 18:15:53 +01:00
import sys
2015-09-19 00:50:59 +02:00
import json
2015-06-22 22:47:27 +02:00
import os.path
2015-09-19 00:50:59 +02:00
import datetime
2015-06-22 22:47:27 +02:00
from distutils import log
from distutils.core import Command
from pip.download import PipSession
from pip.req import parse_requirements
2015-06-22 22:47:27 +02:00
from setuptools.command.develop import develop
2015-07-21 01:13:42 +02:00
from setuptools.command.install import install
2015-06-22 22:47:27 +02:00
from setuptools.command.sdist import sdist
2015-09-08 06:54:23 +02:00
from setuptools import setup, find_packages
2015-06-22 22:47:27 +02:00
from subprocess import check_output
ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__)))
2015-12-01 18:15:53 +01:00
# When executing the setup.py, we need to be able to import ourselves, this
# means that we need to add the src/ directory to the sys.path.
sys.path.insert(0, ROOT)
about = {}
2017-07-06 05:17:19 +02:00
with open(os.path.join(ROOT, 'lemur', '__about__.py')) as f:
exec(f.read(), about) # nosec: about file is benign
2015-12-01 18:15:53 +01:00
install_requires_g = parse_requirements("requirements.txt", session=PipSession())
install_requires = [str(ir.req) for ir in install_requires_g]
2015-06-22 22:47:27 +02:00
tests_require = [
'pyflakes',
'moto==1.1.25',
2015-07-23 22:01:45 +02:00
'nose==1.3.7',
'pytest==3.3.2',
'factory-boy==2.9.2',
'fake-factory==0.7.2',
'pytest-flask==0.10.0',
'freezegun==0.3.9',
'requests-mock==1.4.0',
2017-09-04 05:41:43 +02:00
'pytest-mock'
2015-06-22 22:47:27 +02:00
]
docs_require = [
'sphinx',
2016-06-23 18:20:35 +02:00
'sphinxcontrib-httpdomain',
'sphinx-rtd-theme'
2015-06-22 22:47:27 +02:00
]
2015-07-21 01:13:42 +02:00
dev_requires = [
2016-11-21 23:29:20 +01:00
'flake8>=3.2,<4.0',
2016-10-31 19:00:15 +01:00
'pre-commit',
2015-12-16 17:57:32 +01:00
'invoke',
'twine'
2015-07-21 01:13:42 +02:00
]
2015-07-21 01:13:42 +02:00
class SmartInstall(install):
"""
Installs Lemur into the Python environment.
If the package indicator is missing, this will also force a run of
`build_static` which is required for JavaScript assets and other things.
"""
def _needs_static(self):
return not os.path.exists(os.path.join(ROOT, 'lemur/static/dist'))
2015-07-21 01:13:42 +02:00
def run(self):
if self._needs_static():
self.run_command('build_static')
install.run(self)
2015-06-22 22:47:27 +02:00
class DevelopWithBuildStatic(develop):
def install_for_development(self):
self.run_command('build_static')
return develop.install_for_development(self)
class SdistWithBuildStatic(sdist):
2015-09-19 00:50:59 +02:00
def make_release_tree(self, *a, **kw):
dist_path = self.distribution.get_fullname()
sdist.make_release_tree(self, *a, **kw)
self.reinitialize_command('build_static', work_path=dist_path)
2015-06-22 22:47:27 +02:00
self.run_command('build_static')
2015-09-19 00:50:59 +02:00
with open(os.path.join(dist_path, 'lemur-package.json'), 'w') as fp:
json.dump({
'createdAt': datetime.datetime.utcnow().isoformat() + 'Z',
}, fp)
2015-06-22 22:47:27 +02:00
class BuildStatic(Command):
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
2015-09-04 01:45:49 +02:00
log.info("running [npm install --quiet] in {0}".format(ROOT))
2015-09-19 19:12:12 +02:00
try:
check_output(['npm', 'install', '--quiet'], cwd=ROOT)
log.info("running [gulp build]")
check_output([os.path.join(ROOT, 'node_modules', '.bin', 'gulp'), 'build'], cwd=ROOT)
log.info("running [gulp package]")
check_output([os.path.join(ROOT, 'node_modules', '.bin', 'gulp'), 'package'], cwd=ROOT)
except Exception as e:
2015-09-19 19:24:56 +02:00
log.warn("Unable to build static content")
2015-06-22 22:47:27 +02:00
2015-06-22 22:47:27 +02:00
setup(
2015-12-01 18:15:53 +01:00
name=about["__title__"],
version=about["__version__"],
author=about["__author__"],
author_email=about["__email__"],
url=about["__uri__"],
description=about["__summary__"],
long_description=open(os.path.join(ROOT, 'README.rst')).read(),
2015-09-08 06:54:23 +02:00
packages=find_packages(),
2015-06-22 22:47:27 +02:00
include_package_data=True,
zip_safe=False,
install_requires=install_requires,
extras_require={
'tests': tests_require,
2015-07-21 01:13:42 +02:00
'docs': docs_require,
'dev': dev_requires,
2015-06-22 22:47:27 +02:00
},
cmdclass={
'build_static': BuildStatic,
2015-07-21 01:13:42 +02:00
'sdist': SdistWithBuildStatic,
'install': SmartInstall
2015-06-22 22:47:27 +02:00
},
entry_points={
'console_scripts': [
'lemur = lemur.manage:main',
],
'lemur.plugins': [
'verisign_issuer = lemur.plugins.lemur_verisign.plugin:VerisignIssuerPlugin',
2016-06-28 00:57:53 +02:00
'acme_issuer = lemur.plugins.lemur_acme.plugin:ACMEIssuerPlugin',
'aws_destination = lemur.plugins.lemur_aws.plugin:AWSDestinationPlugin',
'aws_source = lemur.plugins.lemur_aws.plugin:AWSSourcePlugin',
'aws_s3 = lemur.plugins.lemur_aws.plugin:S3DestinationPlugin',
'email_notification = lemur.plugins.lemur_email.plugin:EmailNotificationPlugin',
2016-05-08 18:07:16 +02:00
'slack_notification = lemur.plugins.lemur_slack.plugin:SlackNotificationPlugin',
'java_truststore_export = lemur.plugins.lemur_java.plugin:JavaTruststoreExportPlugin',
'java_keystore_export = lemur.plugins.lemur_java.plugin:JavaKeystoreExportPlugin',
2016-04-02 01:54:33 +02:00
'openssl_export = lemur.plugins.lemur_openssl.plugin:OpenSSLExportPlugin',
'atlas_metric = lemur.plugins.lemur_atlas.plugin:AtlasMetricPlugin',
'kubernetes_destination = lemur.plugins.lemur_kubernetes.plugin:KubernetesDestinationPlugin',
'cryptography_issuer = lemur.plugins.lemur_cryptography.plugin:CryptographyIssuerPlugin',
'cfssl_issuer = lemur.plugins.lemur_cfssl.plugin:CfsslIssuerPlugin',
'digicert_issuer = lemur.plugins.lemur_digicert.plugin:DigiCertIssuerPlugin',
'digicert_cis_issuer = lemur.plugins.lemur_digicert.plugin:DigiCertCISIssuerPlugin',
'digicert_cis_source = lemur.plugins.lemur_digicert.plugin:DigiCertCISSourcePlugin',
'csr_export = lemur.plugins.lemur_csr.plugin:CSRExportPlugin'
],
2015-06-22 22:47:27 +02:00
},
classifiers=[
'Framework :: Flask',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Operating System :: OS Independent',
2015-12-01 18:15:53 +01:00
'Topic :: Software Development',
"Programming Language :: Python :: 3.5",
2015-12-01 18:15:53 +01:00
"Natural Language :: English",
"License :: OSI Approved :: Apache Software License"
2015-06-22 22:47:27 +02:00
]
)