-
-
Notifications
You must be signed in to change notification settings - Fork 367
/
setup.py
137 lines (110 loc) · 4.08 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
#!/usr/bin/env python
# coding: utf-8
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
from __future__ import print_function
# the name of the package
name = 'ipykernel'
#-----------------------------------------------------------------------------
# Minimal Python version sanity check
#-----------------------------------------------------------------------------
import sys
import re
v = sys.version_info
if v[:2] < (3, 4):
error = "ERROR: %s requires Python version 3.4 or above." % name
print(error, file=sys.stderr)
sys.exit(1)
#-----------------------------------------------------------------------------
# get on with it
#-----------------------------------------------------------------------------
from glob import glob
import os
import shutil
from setuptools import setup
from setuptools.command.bdist_egg import bdist_egg
class bdist_egg_disabled(bdist_egg):
"""Disabled version of bdist_egg
Prevents setup.py install from performing setuptools' default easy_install,
which it should never ever do.
"""
def run(self):
sys.exit("Aborting implicit building of eggs. Use `pip install .` to install from source.")
pjoin = os.path.join
here = os.path.abspath(os.path.dirname(__file__))
pkg_root = pjoin(here, name)
packages = []
for d, _, _ in os.walk(pjoin(here, name)):
if os.path.exists(pjoin(d, '__init__.py')):
packages.append(d[len(here)+1:].replace(os.path.sep, '.'))
package_data = {
'ipykernel': ['resources/*.*'],
}
version_ns = {}
with open(pjoin(here, name, '_version.py')) as f:
exec(f.read(), {}, version_ns)
current_version = version_ns['__version__']
loose_pep440re = re.compile(r'^(\d+)\.(\d+)\.(\d+((a|b|rc)\d+)?)(\.post\d+)?(\.dev\d*)?$')
if not loose_pep440re.match(current_version):
raise ValueError("Version number '%s' is not valid (should match [N!]N(.N)*[{a|b|rc}N][.postN][.devN])" % current_version)
setup_args = dict(
name=name,
version=current_version,
cmdclass={
'bdist_egg': bdist_egg if 'bdist_egg' in sys.argv else bdist_egg_disabled,
},
scripts=glob(pjoin('scripts', '*')),
packages=packages,
py_modules=['ipykernel_launcher'],
package_data=package_data,
description="IPython Kernel for Jupyter",
author='IPython Development Team',
author_email='ipython-dev@scipy.org',
url='https://ipython.org',
license='BSD',
long_description="The IPython kernel for Jupyter",
platforms="Linux, Mac OS X, Windows",
keywords=['Interactive', 'Interpreter', 'Shell', 'Web'],
python_requires='>=3.4',
install_requires=[
'ipython>=5.0.0',
'traitlets>=4.1.0',
'jupyter_client',
'tornado>=4.2',
],
extras_require={
'test': [
'pytest',
'pytest-cov',
'nose', # nose because there are still a few nose.tools imports hanging around
],
},
classifiers=[
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
],
)
if any(a.startswith(('bdist', 'install')) for a in sys.argv):
from ipykernel.kernelspec import write_kernel_spec, make_ipkernel_cmd, KERNEL_NAME
# When building a wheel, the executable specified in the kernelspec is simply 'python'.
if any(a.startswith('bdist') for a in sys.argv):
argv = make_ipkernel_cmd(executable='python')
# When installing from source, the full `sys.executable` can be used.
if any(a.startswith('install') for a in sys.argv):
argv = make_ipkernel_cmd()
dest = os.path.join(here, 'data_kernelspec')
if os.path.exists(dest):
shutil.rmtree(dest)
write_kernel_spec(dest, overrides={'argv': argv})
setup_args['data_files'] = [
(
pjoin('share', 'jupyter', 'kernels', KERNEL_NAME),
glob(pjoin('data_kernelspec', '*')),
)
]
if __name__ == '__main__':
setup(**setup_args)