-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
78 lines (68 loc) · 2.59 KB
/
Copy pathsetup.py
File metadata and controls
78 lines (68 loc) · 2.59 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
import os
import re
import sys
from setuptools import setup, find_packages
from setuptools.command.build_py import build_py
class BuildPyWithRegions(build_py):
"""Fetch latest regions.json from Contentstack CDN before packaging."""
def run(self):
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
try:
from contentstack_management.region_refresh import refresh_regions
refresh_regions()
except Exception as exc:
print(f"WARNING: Could not refresh regions.json: {exc}", file=sys.stderr)
super().run()
with open("README.md", "r") as f:
long_description = f.read()
package = 'contentstack_management'
def get_version(package):
"""
Return package version as listed in `__version__` in `init.py`.
"""
init_py = open(os.path.join(package, '__init__.py')).read()
return re.search("^__version__ = ['\"]([^'\"]+)['\"]",
init_py, re.MULTILINE).group(1)
def get_author_name(package):
"""
Return package author as listed in `__author__` in `init.py`.
"""
init_py = open(os.path.join(package, '__init__.py')).read()
return re.search("^__author__ = ['\"]([^'\"]+)['\"]",
init_py, re.MULTILINE).group(1)
def get_author_email(package):
"""
Return package email as listed in `__email__` in `init.py`.
"""
init_py = open(os.path.join(package, '__init__.py')).read()
return re.search("^__email__ = ['\"]([^'\"]+)['\"]",
init_py, re.MULTILINE).group(1)
setup(
cmdclass={"build_py": BuildPyWithRegions},
name="contentstack-management",
version=get_version(package),
packages=find_packages(exclude=['tests']),
package_data={'contentstack_management': ['data/regions.json']},
py_modules=['_api_client', 'contentstack','common','_errors','_constant'],
description="Contentstack API Client Library for Python",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/contentstack/contentstack-management-python",
author=get_author_name(package),
author_email=get_author_email(package),
license="MIT",
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.10",
"Operating System :: OS Independent",
],
install_requires=[
"requests >= 2.5.4",
"requests-toolbelt >= 0.3.1",
"urllib3 >= 2.7.0,<3.0.0",
],
extras_require={
"dev": ["pytest>=7.0", "twine>=4.0.2", "packaging>=24.0", "dotenv>=0.0.5"],
},
python_requires=">=3.9",
)