1
+ # ruff: noqa
1
2
"""JupyterLab command handler"""
2
3
3
4
# Copyright (c) Jupyter Development Team.
@@ -157,14 +158,18 @@ def get_app_dir():
157
158
158
159
# Use the default locations for data_files.
159
160
app_dir = pjoin (sys .prefix , "share" , "jupyter" , "lab" )
161
+ print (f" @@@@@ app_dir is: { app_dir } @@@@@ " )
162
+ print (f' $$$$$$ sys.prefix is: { sys .prefix } $$$$$ ' )
160
163
161
164
# Check for a user level install.
162
165
# Ensure that USER_BASE is defined
163
166
if hasattr (site , "getuserbase" ):
164
167
site .getuserbase ()
165
168
userbase = getattr (site , "USER_BASE" , None )
169
+ print (f"userbase in get_app_dir() is: { userbase } " )
166
170
if HERE .startswith (userbase ) and not app_dir .startswith (userbase ):
167
171
app_dir = pjoin (userbase , "share" , "jupyter" , "lab" )
172
+ print (f'userbase app_dir is: { app_dir } ' )
168
173
169
174
# Check for a system install in '/usr/local/share'.
170
175
elif (
@@ -173,6 +178,15 @@ def get_app_dir():
173
178
and osp .exists ("/usr/local/share/jupyter/lab" )
174
179
):
175
180
app_dir = "/usr/local/share/jupyter/lab"
181
+ # Check for a system install in '/opt/homebrew/share'.
182
+ elif (
183
+ sys .prefix .startswith ("/opt" )
184
+ and not osp .exists (app_dir )
185
+ and osp .exists ("/opt/homebrew/share/jupyter/lab" )
186
+ ):
187
+ print (f'sys.prefix is from the Check for system install on M1: { sys .prefix } ' )
188
+ app_dir = '/opt/homebrew/share/jupyter/lab'
189
+ print (f"set app_dir to: { app_dir } " )
176
190
177
191
# We must resolve the path to get the canonical case of the path for
178
192
# case-sensitive systems
@@ -742,7 +756,7 @@ def watch(self):
742
756
)
743
757
return [proc ]
744
758
745
- def list_extensions (self ): # noqa
759
+ def list_extensions (self ):
746
760
"""Print an output of the extensions."""
747
761
self ._ensure_disabled_info ()
748
762
logger = self .logger
@@ -791,7 +805,7 @@ def list_extensions(self): # noqa
791
805
for item in sorted (disabled ):
792
806
# Show that all plugins will be disabled if the whole extension matches
793
807
if item in all_exts :
794
- item += " (all plugins)" # noqa PLW2901
808
+ item += " (all plugins)" # PLW2901
795
809
logger .info (" %s" % item )
796
810
797
811
# Here check if modules are improperly shadowed
@@ -813,7 +827,7 @@ def list_extensions(self): # noqa
813
827
logger .info ("\n Build recommended, please run `jupyter lab build`:" )
814
828
[logger .info (" %s" % item ) for item in messages ]
815
829
816
- def build_check (self , fast = None ): # noqa
830
+ def build_check (self , fast = None ):
817
831
"""Determine whether JupyterLab should be built.
818
832
819
833
Returns a list of messages.
@@ -944,7 +958,7 @@ def uninstall_extension(self, name):
944
958
# Handle local extensions.
945
959
if extname in local :
946
960
config = self ._read_build_config ()
947
- data = config .setdefault ("local_extensions" , {}) # noqa PLW2901
961
+ data = config .setdefault ("local_extensions" , {}) # PLW2901
948
962
del data [extname ]
949
963
self ._write_build_config (config )
950
964
return True
@@ -1213,7 +1227,7 @@ def _ensure_disabled_info(self):
1213
1227
1214
1228
info ["disabled_core" ] = disabled_core
1215
1229
1216
- def _populate_staging (self , name = None , version = None , static_url = None , clean = False ): # noqa
1230
+ def _populate_staging (self , name = None , version = None , static_url = None , clean = False ):
1217
1231
"""Set up the assets in the staging directory."""
1218
1232
app_dir = self .app_dir
1219
1233
staging = pjoin (app_dir , "staging" )
@@ -1354,7 +1368,7 @@ def _populate_staging(self, name=None, version=None, static_url=None, clean=Fals
1354
1368
shutil .copy (lock_template , lock_path )
1355
1369
os .chmod (lock_path , stat .S_IWRITE | stat .S_IREAD )
1356
1370
1357
- def _get_package_template (self , silent = False ): # noqa
1371
+ def _get_package_template (self , silent = False ):
1358
1372
"""Get the template the for staging package.json file."""
1359
1373
logger = self .logger
1360
1374
# make a deep copy of the data so we don't influence the core data
@@ -1551,7 +1565,7 @@ def _get_linked_packages(self):
1551
1565
return info
1552
1566
1553
1567
for path in glob (pjoin (dname , "*.tgz" )):
1554
- path = osp .abspath (path ) # noqa PLW2901
1568
+ path = osp .abspath (path ) # PLW2901
1555
1569
data = read_package (path )
1556
1570
name = data ["name" ]
1557
1571
if name not in info :
@@ -1966,7 +1980,7 @@ def _node_check(logger):
1966
1980
"""Check for the existence of nodejs with the correct version."""
1967
1981
node = which ("node" )
1968
1982
try :
1969
- output = subprocess .check_output ([node , "node-version-check.js" ], cwd = HERE ) # noqa S603
1983
+ output = subprocess .check_output ([node , "node-version-check.js" ], cwd = HERE ) # S603
1970
1984
logger .debug (output .decode ("utf-8" ))
1971
1985
except Exception :
1972
1986
data = CoreConfig ()._data
@@ -1994,7 +2008,7 @@ def _yarn_config(logger):
1994
2008
1995
2009
try :
1996
2010
output_binary = subprocess .check_output (
1997
- [node , YARN_PATH , "config" , "--json" ], stderr = subprocess .PIPE , cwd = HERE # noqa S603
2011
+ [node , YARN_PATH , "config" , "--json" ], stderr = subprocess .PIPE , cwd = HERE # S603
1998
2012
)
1999
2013
output = output_binary .decode ("utf-8" )
2000
2014
lines = iter (output .splitlines ())
@@ -2061,7 +2075,7 @@ def _rmtree_star(path, logger):
2061
2075
_rmtree (file_path , logger )
2062
2076
2063
2077
2064
- def _validate_extension (data ): # noqa
2078
+ def _validate_extension (data ):
2065
2079
"""Detect if a package is an extension using its metadata.
2066
2080
2067
2081
Returns any problems it finds.
@@ -2120,7 +2134,7 @@ def _tarsum(input_file):
2120
2134
"""
2121
2135
tar = tarfile .open (input_file , "r" )
2122
2136
chunk_size = 100 * 1024
2123
- h = hashlib .new ("sha1" ) # noqa: S324
2137
+ h = hashlib .new ("sha1" )
2124
2138
2125
2139
for member in tar :
2126
2140
if not member .isfile ():
@@ -2176,7 +2190,7 @@ def _test_overlap(spec1, spec2, drop_prerelease1=False, drop_prerelease2=False):
2176
2190
return cmp == 0
2177
2191
2178
2192
2179
- def _compare_ranges (spec1 , spec2 , drop_prerelease1 = False , drop_prerelease2 = False ): # noqa
2193
+ def _compare_ranges (spec1 , spec2 , drop_prerelease1 = False , drop_prerelease2 = False ):
2180
2194
"""Test whether two version specs overlap.
2181
2195
2182
2196
Returns `None` if we cannot determine compatibility,
@@ -2444,7 +2458,7 @@ def _fetch_package_metadata(registry, name, logger):
2444
2458
except AttributeError :
2445
2459
logger .debug ("Fetching URL: %s" % (req .get_full_url ()))
2446
2460
try :
2447
- with contextlib .closing (urlopen (req )) as response : # noqa S310
2461
+ with contextlib .closing (urlopen (req )) as response : # S310
2448
2462
return json .loads (response .read ().decode ("utf-8" ))
2449
2463
except URLError as exc :
2450
2464
logger .warning ("Failed to fetch package metadata for %r: %r" , name , exc )
0 commit comments