Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit ecdd1fc

Browse files
samaidPokhodenkoSA
andcommitted
Extends setup.py with build_doc command (#410)
* Extends setup.py with build_doc command * Update setup.py Synced with master * Improvements for #410 (#427) * Simplify _remove_cwd_from_syspath() * Remove `import sys` in setup.py * Update setup.py Co-authored-by: Sergey Pokhodenko <pokhodenko.s.a@gmail.com>
1 parent 404500e commit ecdd1fc

File tree

3 files changed

+104
-45
lines changed

3 files changed

+104
-45
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# -*- coding: utf-8 -*-
2+
# *****************************************************************************
3+
# Copyright (c) 2019, Intel Corporation All rights reserved.
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are met:
7+
#
8+
# Redistributions of source code must retain the above copyright notice,
9+
# this list of conditions and the following disclaimer.
10+
#
11+
# Redistributions in binary form must reproduce the above copyright notice,
12+
# this list of conditions and the following disclaimer in the documentation
13+
# and/or other materials provided with the distribution.
14+
#
15+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
19+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22+
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24+
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
25+
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
# *****************************************************************************
27+
28+
import os
29+
import sys
30+
from setuptools import Command
31+
32+
33+
# Sphinx User's Documentation Build
34+
35+
class SDCBuildDoc(Command):
36+
description = 'Builds Intel SDC documentation'
37+
user_options = [
38+
('format', 'f', 'Documentation output format (html, pdf)'),
39+
('doctype', 't', 'Documentation type (user, dev)'),
40+
]
41+
42+
@staticmethod
43+
def _remove_cwd_from_syspath():
44+
# Remove current working directory from PYTHONPATH to avoid importing SDC from sources vs.
45+
# from installed SDC package
46+
cwd = ['', '.', './', os.getcwd()]
47+
sys.path = [p for p in sys.path if p not in cwd]
48+
49+
def initialize_options(self):
50+
self.format = 'html'
51+
self.doctype = 'user'
52+
53+
def finalize_options(self):
54+
pass
55+
56+
def run(self):
57+
self.sdc_build_doc_command.finalize_options()
58+
self.sdc_build_doc_command.run()
59+
60+
def __init__(self, dist):
61+
super(SDCBuildDoc, self).__init__(dist)
62+
self.format = 'html'
63+
self.doctype = 'user'
64+
try:
65+
from sphinx.setup_command import BuildDoc
66+
except ImportError:
67+
raise ImportError('Cannot import Sphinx. '
68+
'Sphinx is the expected dependency for Intel SDC documentation build')
69+
70+
self._remove_cwd_from_syspath()
71+
self.sdc_build_doc_command = BuildDoc(dist)
72+
self.sdc_build_doc_command.initialize_options()
73+
74+
75+
# Sphinx Developer's Documentation Build
76+
77+
#class build_devdoc(build.build):
78+
# description = "Build developer's documentation"
79+
#
80+
# def run(self):
81+
# spawn(['rm', '-rf', 'docs/_builddev'])
82+
# spawn(['sphinx-build', '-b', 'html', '-d', 'docs/_builddev/docstrees',
83+
# '-j1', 'docs/devsource', '-t', 'developer', 'docs/_builddev/html'])

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
# Add any paths that contain custom static files (such as style sheets) here,
122122
# relative to this directory. They are copied after the builtin static files,
123123
# so a file named "default.css" will overwrite the builtin "default.css".
124-
html_static_path = ['_static']
124+
html_static_path = []
125125

126126
html_sidebars = {
127127
'**': ['globaltoc.html', 'sourcelink.html', 'searchbox.html', 'relations.html'],

setup.py

Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
# *****************************************************************************
23
# Copyright (c) 2019, Intel Corporation All rights reserved.
34
#
@@ -27,8 +28,7 @@
2728
from setuptools import setup, Extension, find_packages, Command
2829
import platform
2930
import os
30-
from distutils.command import build
31-
from distutils.spawn import spawn
31+
from docs.source.buildscripts.sdc_build_doc import SDCBuildDoc
3232

3333

3434
# Note we don't import Numpy at the toplevel, since setup.py
@@ -38,38 +38,15 @@
3838
#import copy
3939
import versioneer
4040

41+
# String constants for Intel SDC project configuration
42+
SDC_NAME_STR = 'Intel® Scalable Dataframe Compiler'
43+
4144
# Inject required options for extensions compiled against the Numpy
4245
# C API (include dirs, library dirs etc.)
4346
np_compile_args = np_misc.get_info('npymath')
4447

4548
is_win = platform.system() == 'Windows'
4649

47-
# Sphinx User's Documentation Build
48-
49-
50-
class build_doc(build.build):
51-
description = "Build user's documentation"
52-
53-
def run(self):
54-
spawn(['rm', '-rf', 'docs/_build', 'API_doc', 'docs/usersource/api/'])
55-
spawn(['python', 'docs/rename_function.py'])
56-
spawn(['sphinx-build', '-b', 'html', '-d', 'docs/_build/docstrees',
57-
'-j1', 'docs/usersource', '-t', 'user', 'docs/_build/html'])
58-
spawn(['python', 'docs/CleanRSTfiles.py'])
59-
spawn(['sphinx-build', '-b', 'html', '-d', 'docs/_build/docstrees',
60-
'-j1', 'docs/usersource', '-t', 'user', 'docs/_build/html'])
61-
62-
# Sphinx Developer's Documentation Build
63-
64-
65-
class build_devdoc(build.build):
66-
description = "Build developer's documentation"
67-
68-
def run(self):
69-
spawn(['rm', '-rf', 'docs/_builddev'])
70-
spawn(['sphinx-build', '-b', 'html', '-d', 'docs/_builddev/docstrees',
71-
'-j1', 'docs/devsource', '-t', 'developer', 'docs/_builddev/html'])
72-
7350

7451
def readme():
7552
with open('README.rst', encoding='utf-8') as f:
@@ -268,14 +245,6 @@ def readme():
268245
if _has_opencv:
269246
_ext_mods.append(ext_cv_wrapper)
270247

271-
# Custom build commands
272-
#
273-
# These commands extends standart setuptools build procedure
274-
#
275-
sdc_build_commands = versioneer.get_cmdclass()
276-
sdc_build_commands['build_doc'] = build_doc
277-
sdc_build_commands['build_devdoc'] = build_devdoc
278-
279248

280249
class style(Command):
281250
""" Command to check and adjust code style
@@ -394,11 +363,19 @@ def run(self):
394363
print("%s Style check passed" % self._result_marker)
395364

396365

366+
# Custom build commands
367+
#
368+
# These commands extend standard setuptools build procedure
369+
#
370+
sdc_build_commands = versioneer.get_cmdclass()
371+
sdc_build_commands['build_doc'] = SDCBuildDoc
397372
sdc_build_commands.update({'style': style})
373+
sdc_version = versioneer.get_version()
374+
sdc_release = 'Alpha ({})'.format(versioneer.get_version())
398375

399-
setup(name='sdc',
400-
version=versioneer.get_version(),
401-
description='compiling Python code for clusters',
376+
setup(name=SDC_NAME_STR,
377+
version=sdc_version,
378+
description='Numba* extension for compiling Pandas* operations',
402379
long_description=readme(),
403380
classifiers=[
404381
"Development Status :: 2 - Pre-Alpha",
@@ -409,9 +386,9 @@ def run(self):
409386
"Topic :: Software Development :: Compilers",
410387
"Topic :: System :: Distributed Computing",
411388
],
412-
keywords='data analytics cluster',
389+
keywords='data analytics distributed Pandas Numba',
413390
url='https://github.com/IntelPython/sdc',
414-
author='Intel',
391+
author='Intel Corporation',
415392
packages=find_packages(),
416393
package_data={'sdc.tests': ['*.bz2'], },
417394
install_requires=['numba'],
@@ -421,6 +398,5 @@ def run(self):
421398
entry_points={
422399
"numba_extensions": [
423400
"init = sdc:_init_extension",
424-
],
425-
},
426-
)
401+
]},
402+
)

0 commit comments

Comments
 (0)