Reconfigure setup.py; External deps, code cleanup, post install hook, installation options.

pull/1931/head
Kieran R. Prasch 2020-04-24 10:52:27 -07:00
parent 1bcd98b898
commit 736ad96294
3 changed files with 65 additions and 92 deletions

View File

@ -7,6 +7,7 @@ SPHINXBUILD = python3 -m sphinx
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

View File

@ -1,3 +1,8 @@
[metadata]
# This includes the license file(s) in the wheel.
# https://wheel.readthedocs.io/en/stable/user_guide.html#including-license-files-in-the-generated-wheel-file
license_files = LICENSE
[aliases]
test=pytest

151
setup.py
View File

@ -20,26 +20,39 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
import os
import sys
import sys
from setuptools import setup, find_packages
from setuptools.command.develop import develop
from setuptools.command.install import install
from .scripts.installation.install_solc import download_solc_binary
#
# Metadata
#
PACKAGE_NAME = 'nucypher'
BASE_DIR = os.path.dirname(__file__)
PYPI_CLASSIFIERS = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Security"
]
ABOUT = dict()
with open(os.path.join(BASE_DIR, PACKAGE_NAME, "__about__.py")) as f:
exec(f.read(), ABOUT)
with open(os.path.join(BASE_DIR, "README.md")) as f:
long_description = f.read()
#
# Utilities
@ -65,6 +78,18 @@ class VerifyVersionCommand(install):
sys.exit(info)
class PostDevelopCommand(develop):
"""
Post-installation for development mode.
Execute manually with python setup.py develop or automatically included with
`pip install -e . -r dev-requirements.txt`
"""
def run(self):
develop.run(self)
print("Downloading solidity compiler binary")
download_solc_binary()
#
# Dependencies
#
@ -72,96 +97,38 @@ class VerifyVersionCommand(install):
with open(os.path.join(BASE_DIR, "requirements.txt")) as f:
_PIP_FLAGS, *INSTALL_REQUIRES = f.read().split('\n')
setup(
TESTS_REQUIRE = [
'pytest',
'pytest-xdist',
'pytest-mypy',
'pytest-twisted',
'pytest-cov',
'mypy',
'codecov',
'coverage',
]
# Requirements
python_requires='>=3',
setup_requires=['pytest-runner'], # required for `setup.py test`
install_requires=INSTALL_REQUIRES,
DEPLOY_REQUIRES = [
'bumpversion',
'ansible',
]
# Package Data
packages=find_packages(exclude=["tests"]),
include_package_data=True,
zip_safe=False,
DOCS_REQUIRE = [
'sphinx',
'sphinx-autobuild',
'sphinx_rtd_theme'
]
# Entry Points
entry_points={'console_scripts': [
f'{PACKAGE_NAME} = {PACKAGE_NAME}.cli.main:nucypher_cli',
f'{PACKAGE_NAME}-deploy = {PACKAGE_NAME}.cli.commands.deploy:deploy',
]},
BENCHMARKS_REQUIRE = [
'pytest-benchmark'
]
# Utilities
cmdclass={'verify': VerifyVersionCommand,
'develop': PostDevelopCommand},
EXTRAS_REQUIRE = {'development': TESTS_REQUIRE,
'deployment': DEPLOY_REQUIRES,
'docs': DOCS_REQUIRE,
'benchmark': BENCHMARKS_REQUIRE}
PACKAGE_DATA = ['network/templates/basic_status.j2',
'network/nicknames/web_colors.json',
'blockchain/eth/contract_registry/mainnet/*',
'blockchain/eth/contract_registry/cassandra/*',
'blockchain/eth/contract_registry/gemini/*',
'blockchain/eth/contract_registry/frances/*',
'blockchain/eth/contract_registry/miranda/*',
'blockchain/eth/sol/source/contracts/*',
'blockchain/eth/sol/source/contracts/lib/*',
'blockchain/eth/sol/source/contracts/proxy/*',
'blockchain/eth/sol/source/zeppelin/math/*',
'blockchain/eth/sol/source/zeppelin/utils/*',
'blockchain/eth/sol/source/zeppelin/ownership/*',
'blockchain/eth/sol/source/zeppelin/token/ERC20/*',
'blockchain/eth/sol/source/aragon/contracts/*',
'blockchain/eth/sol/source/aragon/interfaces/*',
]
setup(name=ABOUT['__title__'],
url=ABOUT['__url__'],
version=ABOUT['__version__'],
author=ABOUT['__author__'],
author_email=ABOUT['__email__'],
description=ABOUT['__summary__'],
license=ABOUT['__license__'],
long_description=long_description,
long_description_content_type="text/markdown",
# Setup
python_requires='>=3',
setup_requires=['pytest-runner'], # required for `setup.py test`
tests_require=TESTS_REQUIRE,
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRE,
# Package Data
packages=find_packages(exclude=["tests"]),
package_data={PACKAGE_NAME: PACKAGE_DATA},
include_package_data=True,
# Entry Points
entry_points={'console_scripts': [
f'{PACKAGE_NAME} = {PACKAGE_NAME}.cli.main:nucypher_cli',
f'{PACKAGE_NAME}-deploy = {PACKAGE_NAME}.cli.commands.deploy:deploy',
]},
cmdclass={'verify': VerifyVersionCommand},
# Metadata
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Security"
])
# Metadata
name=ABOUT['__title__'],
url=ABOUT['__url__'],
version=ABOUT['__version__'],
author=ABOUT['__author__'],
author_email=ABOUT['__email__'],
description=ABOUT['__summary__'],
license=ABOUT['__license__'],
long_description_content_type="text/markdown",
long_description_markdown_filename='README.md',
keywords="nucypher, proxy re-encryption",
classifiers=PYPI_CLASSIFIERS
)