2011-10-10 02:28:13 +08:00
|
|
|
#!/usr/bin/env python
|
2015-04-11 04:20:40 +08:00
|
|
|
"""Setup script for Jupyter Notebook"""
|
2011-12-09 06:34:22 +08:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
2015-04-11 04:20:40 +08:00
|
|
|
# Copyright (c) 2015-, Jupyter Development Team.
|
|
|
|
# Copyright (c) 2008-2015, IPython Development Team.
|
2011-12-09 06:34:22 +08:00
|
|
|
#
|
|
|
|
# Distributed under the terms of the Modified BSD License.
|
|
|
|
#
|
2019-11-05 04:29:01 +08:00
|
|
|
# The full license is in the file LICENSE, distributed with this software.
|
2011-12-09 06:34:22 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
2018-01-13 00:09:17 +08:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2015-05-14 01:56:32 +08:00
|
|
|
name = "notebook"
|
2015-04-11 04:20:40 +08:00
|
|
|
|
2019-09-12 00:41:07 +08:00
|
|
|
if sys.version_info < (3, 5):
|
2018-09-16 18:16:59 +08:00
|
|
|
pip_message = 'This may be due to an out of date pip. Make sure you have pip >= 9.0.1.'
|
|
|
|
try:
|
|
|
|
import pip
|
|
|
|
pip_version = tuple([int(x) for x in pip.__version__.split('.')[:3]])
|
|
|
|
if pip_version < (9, 0, 1) :
|
|
|
|
pip_message = 'Your pip version is out of date, please install pip >= 9.0.1. '\
|
|
|
|
'pip {} detected.'.format(pip.__version__)
|
|
|
|
else:
|
|
|
|
# pip is new enough - it must be something else
|
|
|
|
pip_message = ''
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
error = """
|
2019-09-12 00:41:07 +08:00
|
|
|
Notebook 6.0+ supports Python 3.5 and above.
|
|
|
|
When using Python 3.4 or earlier (including 2.7), please install Notebook 5.x.
|
2018-09-16 18:16:59 +08:00
|
|
|
|
|
|
|
Python {py} detected.
|
|
|
|
{pip}
|
|
|
|
""".format(py=sys.version_info, pip=pip_message )
|
|
|
|
|
2013-09-10 02:13:28 +08:00
|
|
|
print(error, file=sys.stderr)
|
|
|
|
sys.exit(1)
|
2011-12-09 06:34:22 +08:00
|
|
|
|
|
|
|
# At least we're on the python version we need, move on.
|
|
|
|
|
|
|
|
# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
|
|
|
|
# update it when the contents of directories change.
|
|
|
|
if os.path.exists('MANIFEST'): os.remove('MANIFEST')
|
|
|
|
|
2018-01-13 00:09:17 +08:00
|
|
|
from setuptools import setup
|
2011-12-09 06:34:22 +08:00
|
|
|
|
|
|
|
from setupbase import (
|
2015-04-11 04:20:40 +08:00
|
|
|
version,
|
2011-12-09 06:34:22 +08:00
|
|
|
find_packages,
|
|
|
|
find_package_data,
|
2014-02-08 06:12:53 +08:00
|
|
|
check_package_data_first,
|
2013-09-15 03:21:05 +08:00
|
|
|
CompileCSS,
|
2015-05-05 06:51:56 +08:00
|
|
|
CompileJS,
|
2018-09-16 04:01:20 +08:00
|
|
|
CompileBackendTranslation,
|
2016-12-23 01:44:46 +08:00
|
|
|
Bower,
|
2013-10-26 05:01:31 +08:00
|
|
|
JavascriptVersion,
|
2014-07-24 05:19:27 +08:00
|
|
|
css_js_prerelease,
|
2011-12-09 06:34:22 +08:00
|
|
|
)
|
|
|
|
|
2015-04-11 04:20:40 +08:00
|
|
|
setup_args = dict(
|
|
|
|
name = name,
|
2015-09-09 06:41:33 +08:00
|
|
|
description = "A web-based notebook environment for interactive computing",
|
2015-09-10 07:49:29 +08:00
|
|
|
long_description = """
|
2015-09-23 02:16:06 +08:00
|
|
|
The Jupyter Notebook is a web application that allows you to create and
|
|
|
|
share documents that contain live code, equations, visualizations, and
|
|
|
|
explanatory text. The Notebook has support for multiple programming
|
|
|
|
languages, sharing, and interactive widgets.
|
2015-09-10 07:49:29 +08:00
|
|
|
|
2016-10-10 04:56:18 +08:00
|
|
|
Read `the documentation <https://jupyter-notebook.readthedocs.io>`_
|
2015-09-23 02:16:06 +08:00
|
|
|
for more information.
|
2015-09-10 07:49:29 +08:00
|
|
|
""",
|
2015-04-11 04:20:40 +08:00
|
|
|
version = version,
|
|
|
|
packages = find_packages(),
|
2016-06-11 04:57:55 +08:00
|
|
|
package_data = find_package_data(),
|
2015-04-11 04:20:40 +08:00
|
|
|
author = 'Jupyter Development Team',
|
|
|
|
author_email = 'jupyter@googlegroups.com',
|
|
|
|
url = 'http://jupyter.org',
|
|
|
|
license = 'BSD',
|
|
|
|
platforms = "Linux, Mac OS X, Windows",
|
|
|
|
keywords = ['Interactive', 'Interpreter', 'Shell', 'Web'],
|
|
|
|
classifiers = [
|
|
|
|
'Intended Audience :: Developers',
|
|
|
|
'Intended Audience :: System Administrators',
|
|
|
|
'Intended Audience :: Science/Research',
|
|
|
|
'License :: OSI Approved :: BSD License',
|
|
|
|
'Programming Language :: Python',
|
|
|
|
'Programming Language :: Python :: 3',
|
2019-09-12 00:41:07 +08:00
|
|
|
'Programming Language :: Python :: 3.5',
|
|
|
|
'Programming Language :: Python :: 3.6',
|
2020-08-01 01:50:49 +08:00
|
|
|
'Programming Language :: Python :: 3.7',
|
2020-06-18 01:50:47 +08:00
|
|
|
'Programming Language :: Python :: 3.8'
|
2015-04-11 04:20:40 +08:00
|
|
|
],
|
2018-01-13 00:09:17 +08:00
|
|
|
zip_safe = False,
|
|
|
|
install_requires = [
|
|
|
|
'jinja2',
|
2021-01-11 14:33:10 +08:00
|
|
|
'tornado>=6.1',
|
2018-04-30 23:03:21 +08:00
|
|
|
# pyzmq>=17 is not technically necessary,
|
|
|
|
# but hopefully avoids incompatibilities with Tornado 5. April 2018
|
|
|
|
'pyzmq>=17',
|
2020-07-10 18:33:19 +08:00
|
|
|
'argon2-cffi',
|
2018-01-13 00:09:17 +08:00
|
|
|
'ipython_genutils',
|
|
|
|
'traitlets>=4.2.1',
|
2020-01-22 01:50:30 +08:00
|
|
|
'jupyter_core>=4.6.1',
|
2019-10-21 23:35:57 +08:00
|
|
|
'jupyter_client>=5.3.4',
|
2018-01-13 00:09:17 +08:00
|
|
|
'nbformat',
|
2019-12-10 00:48:36 +08:00
|
|
|
'nbconvert',
|
2018-01-13 00:09:17 +08:00
|
|
|
'ipykernel', # bless IPython kernel for now
|
2020-12-02 05:04:52 +08:00
|
|
|
'Send2Trash>=1.5.0',
|
2020-05-19 02:11:09 +08:00
|
|
|
'terminado>=0.8.3',
|
2018-04-03 02:27:20 +08:00
|
|
|
'prometheus_client'
|
2018-01-13 00:09:17 +08:00
|
|
|
],
|
|
|
|
extras_require = {
|
2020-10-23 17:45:28 +08:00
|
|
|
'test': ['pytest', 'coverage', 'requests',
|
|
|
|
'nbval', 'selenium', 'pytest', 'pytest-cov'],
|
2020-09-30 19:00:39 +08:00
|
|
|
'docs': ['sphinx', 'nbsphinx', 'sphinxcontrib_github_alt', 'sphinx_rtd_theme'],
|
2020-08-04 02:47:09 +08:00
|
|
|
'test:sys_platform != "win32"': ['requests-unixsocket'],
|
Add support for JSON formatted logs
This adds a new extra package dependency on `json-logging`
and an environment variable, which when set to "true" regardless
of case, will try to use the json-logging non-web app log formatter.
If the `json-logging` package is not installed but the environment
variable is True, something like this will be logged but it will not
crash the application:
```
$ ENABLE_JSON_LOGGING=true jupyter notebook
Unable to use json logging due to missing packages. Run "pip install notebook[json-logging]" to fix.
Traceback (most recent call last):
File "/home/osboxes/jupyter/notebook/notebook/notebookapp.py", line 144, in <module>
import json_logging
ModuleNotFoundError: No module named 'json_logging'
```
Initially I tried to add a new Bool config option to toggle this but
the problem is (from my limited understanding of traitlets and tornado)
is that `_log_formatter_cls` needs to be set early and trying to se the
log formatter later in `init_logging` is too late - or at least I couldn't
figure out a way to reset the log formatter dynamically (I tried calling
`_log_format_changed` [1] but that didn't work).
With this working you get logs like this:
```
{"written_at": "2020-10-07T21:10:51.606Z", "written_ts": 1602105051606265000, "msg": "404 GET /nbextensions/widgets/notebook/js/extension.js (127.0.0.1) 9.26ms referer=http://localhost:8888/notebooks/Untitled.ipynb", "type": "log", "logger": "NotebookApp", "thread": "MainThread", "level": "WARNING", "module": "log", "line_no": 49}
{"written_at": "2020-10-07T21:10:54.443Z", "written_ts": 1602105054443309000, "msg": "Starting buffering for f260ddd7-938c-42d0-ac3b-455bea76694f:49f30b53fc4b4ec6a8f2fb748a171613", "type": "log", "logger": "NotebookApp", "thread": "MainThread", "level": "INFO", "module": "kernelmanager", "line_no": 222}
{"written_at": "2020-10-07T21:10:54.446Z", "written_ts": 1602105054446264000, "msg": "Kernel shutdown: f260ddd7-938c-42d0-ac3b-455bea76694f", "type": "log", "logger": "NotebookApp", "thread": "MainThread", "level": "INFO", "module": "multikernelmanager", "line_no": 201}
```
An obvious improvement here would to be able to split the `msg` fields apart
so that we can log things like response status code, request method, request
URL, response_time_ms etc. That should be possible with the `JSONLogWebFormatter`
from `json-logging` but when I tried using that I was getting errors from
the library about a correlation id (which is based on a request header we
don't use). The `json-logging` library supports several web frameworks like
Flask but unfortunately does not have built in support for Tornado, but it does
support custom formatters so that might be a follow up option to improve on this.
[1] https://github.com/ipython/traitlets/blob/4.3.3/traitlets/config/application.py#L195
Closes #5798
2020-10-08 04:17:22 +08:00
|
|
|
'json-logging': ['json-logging']
|
2018-01-13 00:09:17 +08:00
|
|
|
},
|
2019-03-06 20:09:21 +08:00
|
|
|
python_requires = '>=3.5',
|
2018-01-13 00:09:17 +08:00
|
|
|
entry_points = {
|
|
|
|
'console_scripts': [
|
|
|
|
'jupyter-notebook = notebook.notebookapp:main',
|
|
|
|
'jupyter-nbextension = notebook.nbextensions:main',
|
|
|
|
'jupyter-serverextension = notebook.serverextensions:main',
|
|
|
|
'jupyter-bundlerextension = notebook.bundler.bundlerextensions:main',
|
|
|
|
]
|
|
|
|
},
|
2015-04-11 04:20:40 +08:00
|
|
|
)
|
2011-12-09 06:34:22 +08:00
|
|
|
|
2018-01-13 00:09:17 +08:00
|
|
|
# Custom distutils/setuptools commands ----------
|
2015-04-11 04:20:40 +08:00
|
|
|
from distutils.command.build_py import build_py
|
2012-07-01 06:17:46 +08:00
|
|
|
from distutils.command.sdist import sdist
|
2018-01-13 00:09:17 +08:00
|
|
|
from setuptools.command.bdist_egg import bdist_egg
|
|
|
|
from setuptools.command.develop import develop
|
|
|
|
|
|
|
|
class bdist_egg_disabled(bdist_egg):
|
|
|
|
"""Disabled version of bdist_egg
|
2015-04-11 04:20:40 +08:00
|
|
|
|
2018-01-13 00:09:17 +08:00
|
|
|
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.")
|
2012-07-01 04:41:30 +08:00
|
|
|
|
2012-07-01 06:17:46 +08:00
|
|
|
setup_args['cmdclass'] = {
|
2014-07-24 06:33:08 +08:00
|
|
|
'build_py': css_js_prerelease(
|
2015-04-11 04:20:40 +08:00
|
|
|
check_package_data_first(build_py)),
|
2015-05-05 06:51:56 +08:00
|
|
|
'sdist' : css_js_prerelease(sdist, strict=True),
|
2018-01-13 00:09:17 +08:00
|
|
|
'develop': css_js_prerelease(develop),
|
2013-09-15 03:21:05 +08:00
|
|
|
'css' : CompileCSS,
|
2018-09-16 04:01:20 +08:00
|
|
|
'backendtranslations': CompileBackendTranslation,
|
2015-05-05 06:51:56 +08:00
|
|
|
'js' : CompileJS,
|
2016-12-23 01:44:46 +08:00
|
|
|
'jsdeps' : Bower,
|
2013-10-26 05:01:31 +08:00
|
|
|
'jsversion' : JavascriptVersion,
|
2018-01-13 00:09:17 +08:00
|
|
|
'bdist_egg': bdist_egg if 'bdist_egg' in sys.argv else bdist_egg_disabled,
|
2012-07-01 06:17:46 +08:00
|
|
|
}
|
2012-07-01 04:41:30 +08:00
|
|
|
|
2018-01-13 00:09:17 +08:00
|
|
|
try:
|
|
|
|
from wheel.bdist_wheel import bdist_wheel
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
setup_args['cmdclass']['bdist_wheel'] = css_js_prerelease(bdist_wheel)
|
2015-04-01 03:00:56 +08:00
|
|
|
|
2018-01-13 00:09:17 +08:00
|
|
|
# Run setup --------------------
|
2011-12-09 06:34:22 +08:00
|
|
|
def main():
|
|
|
|
setup(**setup_args)
|
2010-01-13 13:03:16 +08:00
|
|
|
|
2011-12-09 06:34:22 +08:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|