-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
103 lines (83 loc) · 3.36 KB
/
setup.py
File metadata and controls
103 lines (83 loc) · 3.36 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
# coding: utf-8
"""
CodeGen automater for Digikey V3 API's and provides a simple interface to the API's
Automates and customizes the Swagger Codgen to take swagger API specification from Digikey and produce and install the Python Clients to the Digikey API, also integrates and installs community-digikey-simple-v3-api that is a simplified interface handling Authentication under Oauth2 protocol.
See README.md for installation and use
Digikey API's use OpenAPI spec version: v3
Contact: api.support@digikey.com
CodeGen Automater and community produced Digikey interface by: https://github.com/auphofBSF with Oauth2 token management from the Digikey V2 api https://github.com/peeter123/digikey-api
"""
from setuptools import setup, find_packages # noqa: H301
from setuptools.command.develop import develop
from setuptools.command.install import install
NAME = "community-digikey-api-codegen-python-clients"
VERSION = "0.1.0"
# To install the library, run the following
#
# pip install -e .
#
# prerequisite: pip, gitpython
#
REQUIRES = [
"gitpython",
"requests",
]
class PostDevelopCommand(develop):
"""Post-installation for development mode."""
def run(self):
# check_call("apt-get install this-package".split())
print("----Custom Develop - pre develop.run")
develop.run(self)
print("----Custom Develop - post develop.run")
digikeyAPIclientGenerate()
class PostInstallCommand(install):
"""Post-installation for installation mode."""
def run(self):
# check_call("apt-get install this-package".split())
print("----Custom Install - pre install.run")
install.run(self)
print("----Custom Install - post install.run")
digikeyAPIclientGenerate()
def digikeyAPIclientGenerate():
from community_digikey_api_codegen import tools
# Currently supported API's
apiGenerateList = ['product-information','order-support']
# apiGenerateList = ['order-support']
#Generate Digikey API python clients
generated= [
tools.codeGen_api(tools.digikeyAPIdef_all[api],
tools.swaggerCodeGen_config_all[api])
for api in apiGenerateList
]
# Install the generated generated
import os, subprocess
rememberDir = os.getcwd()
for api in generated:
os.chdir(api['locationPath'])
subprocessCMD = [
'pip'
, 'install'
# , '--editable'
, '.'
]
tools.subprocess_run(subprocessCMD)
os.chdir(rememberDir)
setup(
name=NAME,
version=VERSION,
description="CodeGen Automater for Digikey V3 API's ",
author_email="auphofBSF_GH1@blacksheepfarm.co.nz",
url="https://github.com/auphofBSF/community-digikey-api-codegen-python-clients",
keywords=["Swagger", "CodeGen","Digikey Api"],
cmdclass={
'develop': PostDevelopCommand,
'install': PostInstallCommand,
},
setup_requires = ['requests'],
install_requires=REQUIRES,
packages=find_packages(),
include_package_data=True,
long_description="""\
Automates and customizes the Swagger CodGen to take swagger API specification from Digikey then generate and install the Python Clients to the Digikey API, also integrates and installs community-digikey-simple-v3-api that is a simplified interface handling Authentication under Oauth2 protocol. # noqa: E501
"""
)