This repository has been archived by the owner on May 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
160 lines (121 loc) · 3.67 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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# :coding: utf-8
# :copyright: Copyright (c) 2015 ftrack
import os
import re
import shutil
from setuptools.command.test import test as TestCommand
from setuptools import setup, find_packages, Command
from pkg_resources import parse_version
import pip
if parse_version(pip.__version__) < parse_version('19.3.0'):
raise ValueError('Pip should be version 19.3.0 or higher')
from pip._internal import main as pip_main
# Define paths
PLUGIN_NAME = 'ftrack-connect-hieroplayer-{0}'
ROOT_PATH = os.path.dirname(
os.path.realpath(__file__)
)
ROOT_PATH = os.path.dirname(os.path.realpath(__file__))
RESOURCE_PATH = os.path.join(ROOT_PATH, 'resource')
SOURCE_PATH = os.path.join(ROOT_PATH, 'source')
README_PATH = os.path.join(ROOT_PATH, 'README.rst')
BUILD_PATH = os.path.join(ROOT_PATH, 'build')
STAGING_PATH = os.path.join(BUILD_PATH, PLUGIN_NAME)
HIERO_WORKSPACES_PATH = os.path.join(RESOURCE_PATH, 'Workspaces')
FTRACK_CONNECT_HIEROPLAYER_PLUGIN_PATH = os.path.join(
RESOURCE_PATH, 'Python'
)
HOOK_PATH = os.path.join(RESOURCE_PATH, 'hook')
with open(os.path.join(
SOURCE_PATH, 'ftrack_connect_hieroplayer', '_version.py')
) as _version_file:
VERSION = re.match(
r'.*__version__ = \'(.*?)\'', _version_file.read(), re.DOTALL
).group(1)
STAGING_PATH = STAGING_PATH.format(VERSION)
# Custom commands.
class PyTest(TestCommand):
'''Pytest command.'''
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
'''Import pytest and run.'''
import pytest
errno = pytest.main(self.test_args)
raise SystemExit(errno)
class BuildPlugin(Command):
'''Build plugin.'''
description = 'Download dependencies and build plugin .'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
'''Run the build step.'''
# Clean staging path
shutil.rmtree(STAGING_PATH, ignore_errors=True)
# Copy plugin files
shutil.copytree(
FTRACK_CONNECT_HIEROPLAYER_PLUGIN_PATH,
os.path.join(STAGING_PATH, 'resource', 'Python')
)
# Copy plugin files
shutil.copytree(
HIERO_WORKSPACES_PATH,
os.path.join(STAGING_PATH, 'resource', 'Workspaces')
)
# Copy hook files
shutil.copytree(
HOOK_PATH,
os.path.join(STAGING_PATH, 'hook')
)
# Install local dependencies
pip_main.main(
[
'install',
'.',
'--target',
os.path.join(STAGING_PATH, 'dependencies')
]
)
# Generate plugin zip
shutil.make_archive(
os.path.join(
BUILD_PATH,
PLUGIN_NAME.format(VERSION)
),
'zip',
STAGING_PATH
)
# Configuration.
setup(
name='ftrack-connect-hieroplayer',
version=VERSION,
description='''ftrack connect review plugin for The Foundry's HIEROPLAYER.''',
long_description=open(README_PATH).read(),
keywords='',
url='https://bitbucket.org/ftrack/ftrack-connect-hieroplayer',
author='ftrack',
author_email='support@ftrack.com',
license='Apache License (2.0)',
packages=find_packages(SOURCE_PATH),
package_dir={
'': 'source'
},
setup_requires=[
'sphinx >= 1.2.2, < 2',
'sphinx_rtd_theme >= 0.1.6, < 2'
],
install_requires=[
],
tests_require=[
'pytest >= 2.3.5, < 3'
],
cmdclass={
'test': PyTest,
'build_plugin': BuildPlugin
},
)