-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
79 lines (68 loc) · 2.87 KB
/
setup.py
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
# (C) Copyright IBM Corp. 2022.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from setuptools import setup, find_packages
from setuptools.command.install import install
import os
import shutil
from pathlib import Path
PACKAGE_NAME = 'vpc-img-inst'
INSTALLATION_DIR_NAME = 'installation_scripts'
USER_SCRIPTS_FOLDER = str(Path.home())+os.sep+f".{PACKAGE_NAME}"
PROJECT_ROOT = os.path.join(os.path.dirname(os.path.realpath(__file__)),'src','vpc_img_inst')
class CustomInstallCommand(install):
"""
This class inherits from setuptools' install class to create the users scripts folder
post installation ((pip) install) and copy the project's scripts to said folder.
"""
def run(self):
install.run(self)
if not os.path.exists(USER_SCRIPTS_FOLDER):
print(f'Copying project scripts to {USER_SCRIPTS_FOLDER}')
src = os.path.join(PROJECT_ROOT,INSTALLATION_DIR_NAME)
dest = USER_SCRIPTS_FOLDER
shutil.copytree(src, dest)
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
find_packages(where='src',exclude=['logs'])
setup(
name='vpc-img-inst',
version='1.0.0b12',
author ='Omer-J-Cohen',
author_email = '[email protected]',
description = 'vpc-img-inst is a lightweight script for quick-and-dirty generation of custom VSI images by installing features (software bundles) on base images.',
long_description=read('README.md'),
long_description_content_type = "text/markdown",
url = 'https://github.com/IBM/vpc-img-inst',
install_requires=[
'click==8.0.4',
'ibm_cloud_sdk_core==3.16.0',
'ibm_platform_services==0.27.0',
'ibm_vpc==0.12.0',
'ibm_watson==6.1.0',
'inquirer==2.10.1',
'paramiko==2.11.0',
'PyYAML==6.0',
'setuptools==63.2.0'
],
# Creates script named vpc-img-inst under ~/<python_folder>/bin/vpc-img-inst.
# it is asked to pass parameters to builder() of vpc_img_inst.main.
entry_points={
'console_scripts': ['vpc-img-inst=vpc_img_inst:main.builder']
},
# include otherwise undetected installation scripts and defaults.yaml
package_data={'': ['*.sh','*.yaml']},
# inform setuptools to modify standard installation class. in this instance: setuptools.command.install
cmdclass={'install': CustomInstallCommand},
python_requires = ">=3.6",
)