-
Notifications
You must be signed in to change notification settings - Fork 551
/
setup.py
100 lines (82 loc) · 2.69 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
# -----------------------------------------------------------------------------
# Copyright (C) 2013 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
# -----------------------------------------------------------------------------
import os
import pipes
from subprocess import check_call
from distutils import log
from setuptools import setup
from setuptools.command.develop import develop
import versioneer
def sh(cmd):
"""Run a command, echoing what command is to be run"""
log.info("Running command %s" % " ".join(map(pipes.quote, cmd)))
check_call(cmd)
def preflight():
log.info("Building LESS")
sh(["invoke", "git-info"])
sh(["npm", "install"])
sh(["invoke", "bower"])
sh(["invoke", "less"])
def invoke_first(cmd):
class InvokeFirst(cmd):
def run(self):
preflight()
return cmd.run(self)
return InvokeFirst
def walk_subpkg(name):
data_files = []
package_dir = "nbviewer"
for parent, dirs, files in os.walk(os.path.join(package_dir, name)):
sub_dir = os.sep.join(
parent.split(os.sep)[1:]
) # remove package_dir from the path
for f in files:
data_files.append(os.path.join(sub_dir, f))
return data_files
pkg_data = {
"nbviewer": (
["frontpage.json", "git_info.json"]
+ walk_subpkg("static")
+ walk_subpkg("templates")
+ walk_subpkg("providers")
)
}
cmdclass = versioneer.get_cmdclass()
# run invoke prior to develop/sdist
cmdclass["develop"] = invoke_first(develop)
cmdclass["build_py"] = invoke_first(cmdclass["build_py"])
cmdclass["sdist"] = invoke_first(cmdclass["sdist"])
setup_args = dict(
name="nbviewer",
version=versioneer.get_version(),
packages=["nbviewer"],
package_data=pkg_data,
setup_requires=["invoke"],
author="The Jupyter Development Team",
author_email="jupyter@googlegroups.com",
url="https://nbviewer.org",
project_urls={
"Source": "https://github.com/jupyter/nbviewer",
"Tracker": "https://github.com/jupyter/nbviewer/issues",
},
description="Jupyter Notebook Viewer",
long_description="Jupyter nbconvert as a web service",
license="BSD",
classifiers=[
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
],
python_requires=">=3.8",
cmdclass=cmdclass,
)
install_requires = setup_args["install_requires"] = []
with open("requirements.in") as f:
for line in f:
req = line.strip()
if not req.startswith("#"):
install_requires.append(req)
setup(**setup_args)