-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsetup.py
More file actions
137 lines (109 loc) · 3.33 KB
/
setup.py
File metadata and controls
137 lines (109 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
from pathlib import Path
from typing import Dict
from setuptools import find_packages, setup
from setuptools.command.develop import develop
from setuptools.command.install import install
#
# Metadata
#
PACKAGE_NAME = 'porter'
BASE_DIR = Path(__file__).parent
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.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Security",
]
ABOUT: Dict[str, str] = dict()
SOURCE_METADATA_PATH = BASE_DIR / PACKAGE_NAME / "__about__.py"
with open(str(SOURCE_METADATA_PATH.resolve())) as f:
exec(f.read(), ABOUT)
#
# Utilities
#
class VerifyVersionCommand(install):
"""Custom command to verify that the git tag matches our version"""
description = 'verify that the git tag matches our version'
def run(self):
tag = os.getenv('CIRCLE_TAG')
if tag.startswith('v'):
tag = tag[1:]
version = ABOUT['__version__']
if version.startswith('v'):
version = version[1:]
if tag != version:
info = "Git tag: {0} does not match the version of this app: {1}".format(
os.getenv('CIRCLE_TAG'), ABOUT['__version__']
)
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):
"""development setup scripts (pre-requirements)"""
develop.run(self)
#
# Requirements
#
def read_requirements(path):
with open(BASE_DIR / path) as f:
return f.read().split("\n")
INSTALL_REQUIRES = read_requirements('requirements.txt')
DEV_REQUIRES = read_requirements('dev-requirements.txt')
DEPLOY_REQUIRES = [
'bumpversion',
'twine',
'wheel'
]
EXTRAS = {
'dev': DEV_REQUIRES,
'deploy': DEPLOY_REQUIRES
}
# read the contents of the README file
long_description = (BASE_DIR / "README.rst").read_text()
setup(
# Requirements
python_requires=">=3.10,<4",
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS,
# Package Data
packages=find_packages(exclude=["tests", "scripts"]),
include_package_data=True,
zip_safe=False,
# Entry Points
entry_points={'console_scripts': [
'nucypher-porter = porter.cli.main:porter_cli',
]},
# setup.py commands
cmdclass={
'verify': VerifyVersionCommand,
'develop': PostDevelopCommand
},
# 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/x-rst",
long_description=long_description,
keywords="porter",
classifiers=PYPI_CLASSIFIERS,
)