-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
120 lines (97 loc) · 3.95 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
from distutils.core import Command
from distutils.errors import DistutilsOptionError
from os import path
from setuptools import setup
from setuptools.command.develop import develop
from setuptools.command.sdist import sdist
from shutil import which
import subprocess
class BuildWebpackBundle(Command):
description = 'Install dependencies with Yarn and run Webpack'
user_options = [
('webpack-environment=', None, 'Webpack environment ("development" or "production")')
]
def initialize_options(self):
self.webpack_environment = None
def finalize_options(self):
if self.webpack_environment not in ('development', 'production'):
raise DistutilsOptionError('Must set the Webpack environment to either "development" or "production"; was {}'.format(
self.webpack_environment))
def run(self):
yarn = which('yarn') or which('yarn.cmd')
if yarn is None:
print('Failed to find yarn or yarn.cmd on PATH; aborting')
return False
subprocess.check_call([yarn, 'install'], cwd=root_dir)
subprocess.check_call([yarn, 'run', 'webpack', '--mode', self.webpack_environment], cwd=root_dir)
class WithBuildWebpackBundle:
user_options = [
('webpack-environment=', None, 'Webpack environment ("development" or "production")'),
]
webpack_environment = None
def initialize_options(self, default_webpack_environment):
self.webpack_environment = default_webpack_environment
def build_webpack_bundle(self, command_name):
cmd = self.distribution.get_command_obj('build_webpack_bundle')
cmd.set_undefined_options(command_name, ('webpack_environment', 'webpack_environment'))
self.run_command('build_webpack_bundle')
class DevelopWithBuildWebpackBundle(develop, WithBuildWebpackBundle):
user_options = develop.user_options + WithBuildWebpackBundle.user_options
def initialize_options(self):
super().initialize_options()
WithBuildWebpackBundle.initialize_options(self, 'development')
def install_for_development(self):
super().install_for_development()
WithBuildWebpackBundle.build_webpack_bundle(self, 'develop')
class SdistWithBuildWebpackBundle(sdist, WithBuildWebpackBundle):
user_options = sdist.user_options + WithBuildWebpackBundle.user_options
def initialize_options(self):
super().initialize_options()
WithBuildWebpackBundle.initialize_options(self, 'production')
def make_distribution(self):
WithBuildWebpackBundle.build_webpack_bundle(self, 'sdist')
super().make_distribution()
root_dir = path.abspath(path.dirname(__file__))
with open(path.join(root_dir, 'README.md')) as f:
long_description = f.read()
setup(
name='mkdocs-theme-bootstrap4',
long_description=long_description,
long_description_content_type='text/markdown',
version='0.4.0',
cmdclass={
'build_webpack_bundle': BuildWebpackBundle,
'develop': DevelopWithBuildWebpackBundle,
'sdist': SdistWithBuildWebpackBundle,
},
packages=['mkdocsthemebootstrap4'],
package_data={
'mkdocsthemebootstrap4': [
'dist/bundle.js',
'404.html',
'base.html',
'content.html',
'main.html',
'mkdocs_theme.yml',
'nav-sub.html',
'search-modal.html',
'toc.html',
],
},
url='https://github.com/LukeCarrier/mkdocs-theme-bootstrap4',
license='MIT',
author='Luke Carrier',
author_email='[email protected]',
description='A vanilla Bootstrap 4 theme',
install_requires=['mkdocs>=1.0'],
entry_points={
'mkdocs.plugins': [
'bootstrap4-blockquotes = mkdocsthemebootstrap4:Bootstrap4Blockquotes',
'bootstrap4-tables = mkdocsthemebootstrap4:Bootstrap4Tables',
],
'mkdocs.themes': [
'bootstrap4 = mkdocsthemebootstrap4',
],
},
zip_safe=False,
)