This repository was archived by the owner on Jan 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.py
More file actions
162 lines (138 loc) · 5.08 KB
/
Copy pathsetup.py
File metadata and controls
162 lines (138 loc) · 5.08 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env python
# setup
# Installs and maintains the Python package
#
# Author: PingThings
# Created: Tue Nov 26 11:52:24 2019 -0500
#
# For license information, see LICENSE.txt
# ID: setup.py [] benjamin@pingthings.io $
"""
Installs and maintains the Python package
"""
##########################################################################
## Imports
##########################################################################
import os
import codecs
from setuptools import setup
from setuptools import find_packages
##########################################################################
## Configuration
##########################################################################
NAME = "jupyteranalytics"
DESCRIPTION = "Adds Google Analytics to Jupyter notebooks"
AUTHOR = "PingThings, Inc."
EMAIL = "support@pingthings.io"
LICENSE = "BSD-3-Clause"
REPOSITORY = "https://github.com/PingThingsIO/jupyter-analytics"
PACKAGE = "jupyteranalytics"
KEYWORDS = ("Google Analytics", "notebooks", "Jupyter", "JupyterHub")
## Define the classifiers
## See https://pypi.python.org/pypi?%3Aaction=list_classifiers
CLASSIFIERS = (
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
'Framework :: Jupyter',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python'
)
PROJECT = os.path.abspath(os.path.dirname(__file__))
REQUIRE_PATH = "requirements.txt"
VERSION_PATH = os.path.join(PACKAGE, "version.py")
PKG_DESCRIBE = "README.md"
EXCLUDES = ("tests", "docs", "fixtures")
##########################################################################
## Helper Functions
##########################################################################
def read(*parts):
"""
Assume UTF-8 encoding and return the contents of the file located at the
absolute path from the REPOSITORY joined with *parts.
"""
with codecs.open(os.path.join(PROJECT, *parts), 'rb', 'utf-8') as f:
return f.read()
def get_version(path=VERSION_PATH):
"""
Reads the python file defined in the VERSION_PATH to find the get_version
function, and executes it to ensure that it is loaded correctly. Separating
the version in this way ensures no additional code is executed.
"""
namespace = {}
exec(read(path), namespace)
return namespace['get_version'](short=True)
def get_requires(path=REQUIRE_PATH):
"""
Yields a generator of requirements as defined by the REQUIRE_PATH which
should point to a requirements.txt output by `pip freeze`.
"""
for line in read(path).splitlines():
line = line.strip()
if line and not line.startswith('#'):
yield line
def get_description_type(path=PKG_DESCRIBE):
"""
Returns the long_description_content_type based on the extension of the
package describe path (e.g. .txt, .rst, or .md).
"""
_, ext = os.path.splitext(path)
return {
".rst": "text/x-rst",
".txt": "text/plain",
".md": "text/markdown",
}[ext]
##########################################################################
## Define the configuration
##########################################################################
config = {
"name": NAME,
"version": get_version(),
"description": DESCRIPTION,
"long_description": read(PKG_DESCRIBE),
"long_description_content_type": get_description_type(PKG_DESCRIBE),
"classifiers": list(CLASSIFIERS),
"keywords": list(KEYWORDS),
"license": LICENSE,
"author": AUTHOR,
"author_email": EMAIL,
"maintainer": AUTHOR,
"maintainer_email": EMAIL,
"project_urls": {
"Download": "{}/tarball/v{}".format(REPOSITORY, get_version()),
"Source": REPOSITORY,
"Tracker": "{}/issues".format(REPOSITORY),
},
"download_url": "{}/tarball/v{}".format(REPOSITORY, get_version()),
"packages": find_packages(where=PROJECT, exclude=EXCLUDES),
"include_package_data": True,
"package_data": {
"jupyteranalytics": ["static/*"],
},
"data_files": [
# Automatic `jupyter nbextension install --sys-prefix`
("share/jupyter/nbextensions/jupyteranalytics", [
"jupyteranalytics/static/main.js",
]),
# Automatic `jupyter nbextension enable --sys-prefix`
("etc/jupyter/nbconfig/", [
"jupyter-config/nbconfig/common.json"
]),
# Automatic `jupyter serverextension enable --sys-prefix`
("etc/jupyter/jupyter_notebook_config.d", [
"jupyter-config/jupyter_notebook_config.d/jupyteranalytics.json"
])
],
"zip_safe": False,
"install_requires": list(get_requires()),
"python_requires": ">=3.4, <4",
}
##########################################################################
## Run setup script
##########################################################################
if __name__ == '__main__':
setup(**config)