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
145 lines (111 loc) · 3.52 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
# :coding: utf-8
# :copyright: Copyright (c) 2015 ftrack
import os
import re
import shutil
import sys
from setuptools.command.test import test as TestCommand
from setuptools import setup, find_packages, Command
from pkg_resources import parse_version
import subprocess
# Define paths
PLUGIN_NAME = 'ftrack-connect-houdini-{0}'
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)
HOUDINI_SCRIPTS_PATH = os.path.join(RESOURCE_PATH, 'houdini_path')
HOOK_PATH = os.path.join(RESOURCE_PATH, 'hook')
# Parse package version
with open(os.path.join(
SOURCE_PATH, 'ftrack_connect_houdini', '_version.py')
) as _version_file:
VERSION = re.match(
r'.*__version__ = \'(.*?)\'', _version_file.read(), re.DOTALL
).group(1)
# Update staging path with the plugin version
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(
HOUDINI_SCRIPTS_PATH,
os.path.join(STAGING_PATH, 'resource', 'houdini_path')
)
# Copy hook files
shutil.copytree(
HOOK_PATH,
os.path.join(STAGING_PATH, 'hook')
)
# Install local dependencies
subprocess.check_call(
[sys.executable, '-m', 'pip', '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 houdini',
version=VERSION,
description='Houdini integration with ftrack.',
long_description=open(README_PATH).read(),
keywords='',
url='https://bitbucket.org/ftrack/ftrack-connect-houdini',
author='postmodern',
author_email='[email protected]',
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',
'lowdown >= 0.1.0, < 1'
],
tests_require=[
'pytest >= 2.3.5, < 3'
],
cmdclass={
'test': PyTest,
'build_plugin': BuildPlugin,
},
install_requires=[
'appdirs',
'qtext @ git+https://bitbucket.org/ftrack/qtext/get/0.2.2.zip#egg=QtExt-0.2.2',
'ftrack-connector-legacy @ git+https://bitbucket.org/ftrack/ftrack-connector-legacy/get/1.0.0.zip#egg=ftrack-connector-legacy-1.0.0',
],
python_requires=">=2.7.9, <3"
)