|
27 | 27 | # get on with it
|
28 | 28 | #-----------------------------------------------------------------------------
|
29 | 29 |
|
30 |
| -import errno |
31 | 30 | import os
|
32 |
| -import shutil |
33 | 31 | from distutils import log
|
34 | 32 | from distutils.core import setup, Command
|
35 | 33 | from distutils.command.build_py import build_py
|
36 | 34 | from distutils.command.sdist import sdist
|
37 | 35 | from glob import glob
|
38 | 36 | from os.path import join as pjoin
|
39 | 37 | from subprocess import check_call
|
40 |
| -from zipfile import ZipFile |
41 |
| - |
42 |
| -try: |
43 |
| - from urllib.request import urlopen |
44 |
| -except ImportError: |
45 |
| - from urllib2 import urlopen |
46 | 38 |
|
47 | 39 |
|
48 | 40 | repo_root = os.path.dirname(os.path.abspath(__file__))
|
@@ -149,52 +141,14 @@ def run(self):
|
149 | 141 | update_package_data(self.distribution)
|
150 | 142 | return DecoratedCommand
|
151 | 143 |
|
| 144 | + |
152 | 145 | def update_package_data(distribution):
|
153 | 146 | """update package_data to catch changes during setup"""
|
154 | 147 | build_py = distribution.get_command_obj('build_py')
|
155 | 148 | # distribution.package_data = find_package_data()
|
156 | 149 | # re-init build_py options which load package_data
|
157 | 150 | build_py.finalize_options()
|
158 | 151 |
|
159 |
| -class FetchNotebook(Command): |
160 |
| - description = "Fetch Notebook source, needed for LESS sources" |
161 |
| - |
162 |
| - user_options = [] |
163 |
| - |
164 |
| - def initialize_options(self): |
165 |
| - pass |
166 |
| - |
167 |
| - def finalize_options(self): |
168 |
| - pass |
169 |
| - |
170 |
| - # FIXME: update url to 4.0 when notebook is released |
171 |
| - url = "https://github.com/jupyter/notebook/archive/master.zip" |
172 |
| - |
173 |
| - def run(self): |
174 |
| - nb_dir = pjoin('less_include', 'notebook') |
175 |
| - nb_zip = pjoin('less_include', 'notebook.zip') |
176 |
| - if os.path.exists(nb_dir): |
177 |
| - return |
178 |
| - try: |
179 |
| - os.mkdir('less_include') |
180 |
| - except OSError as e: |
181 |
| - if e.errno != errno.EEXIST: |
182 |
| - raise |
183 |
| - if not os.path.exists(nb_zip): |
184 |
| - log.info("downloading %s" % self.url) |
185 |
| - r = urlopen(self.url) |
186 |
| - with open(nb_zip, 'wb') as f: |
187 |
| - for chunk in r: |
188 |
| - f.write(chunk) |
189 |
| - log.info("unzipping notebook") |
190 |
| - zf = ZipFile(nb_zip) |
191 |
| - if os.path.exists('notebook-tmp'): |
192 |
| - shutil.rmtree('notebook-tmp') |
193 |
| - zf.extractall('notebook-tmp') |
194 |
| - d = glob(pjoin('notebook-tmp', '*'))[0] |
195 |
| - shutil.move(d, nb_dir) |
196 |
| - os.rmdir('notebook-tmp') |
197 |
| - |
198 | 152 |
|
199 | 153 | class NPM(Command):
|
200 | 154 | description = "install package,json dependencies using npm"
|
@@ -223,7 +177,6 @@ def should_run_npm(self):
|
223 | 177 | return mtime(self.node_modules) < mtime(pjoin(repo_root, 'package.json'))
|
224 | 178 |
|
225 | 179 | def run(self):
|
226 |
| - self.distribution.run_command('fetch_notebook') |
227 | 180 | if self.should_run_npm():
|
228 | 181 | print("installing build dependencies with npm")
|
229 | 182 | check_call(['npm', 'install'], cwd=repo_root)
|
@@ -286,7 +239,6 @@ def run(self):
|
286 | 239 | 'build_py': js_prerelease(build_py),
|
287 | 240 | 'sdist': js_prerelease(sdist, strict=True),
|
288 | 241 | 'jsdeps': NPM,
|
289 |
| - 'fetch_notebook': FetchNotebook, |
290 | 242 | },
|
291 | 243 | )
|
292 | 244 |
|
|
0 commit comments