Skip to content

Commit 68eb096

Browse files
committed
inspect app_dir paths
1 parent 3a0f925 commit 68eb096

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

jupyterlab/commands.py

+27-13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# ruff: noqa
12
"""JupyterLab command handler"""
23

34
# Copyright (c) Jupyter Development Team.
@@ -157,14 +158,18 @@ def get_app_dir():
157158

158159
# Use the default locations for data_files.
159160
app_dir = pjoin(sys.prefix, "share", "jupyter", "lab")
161+
print(f" @@@@@ app_dir is: {app_dir} @@@@@ ")
162+
print(f' $$$$$$ sys.prefix is: {sys.prefix} $$$$$ ')
160163

161164
# Check for a user level install.
162165
# Ensure that USER_BASE is defined
163166
if hasattr(site, "getuserbase"):
164167
site.getuserbase()
165168
userbase = getattr(site, "USER_BASE", None)
169+
print(f"userbase in get_app_dir() is: {userbase}")
166170
if HERE.startswith(userbase) and not app_dir.startswith(userbase):
167171
app_dir = pjoin(userbase, "share", "jupyter", "lab")
172+
print(f'userbase app_dir is: {app_dir}')
168173

169174
# Check for a system install in '/usr/local/share'.
170175
elif (
@@ -173,6 +178,15 @@ def get_app_dir():
173178
and osp.exists("/usr/local/share/jupyter/lab")
174179
):
175180
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}")
176190

177191
# We must resolve the path to get the canonical case of the path for
178192
# case-sensitive systems
@@ -742,7 +756,7 @@ def watch(self):
742756
)
743757
return [proc]
744758

745-
def list_extensions(self): # noqa
759+
def list_extensions(self):
746760
"""Print an output of the extensions."""
747761
self._ensure_disabled_info()
748762
logger = self.logger
@@ -791,7 +805,7 @@ def list_extensions(self): # noqa
791805
for item in sorted(disabled):
792806
# Show that all plugins will be disabled if the whole extension matches
793807
if item in all_exts:
794-
item += " (all plugins)" # noqa PLW2901
808+
item += " (all plugins)" # PLW2901
795809
logger.info(" %s" % item)
796810

797811
# Here check if modules are improperly shadowed
@@ -813,7 +827,7 @@ def list_extensions(self): # noqa
813827
logger.info("\nBuild recommended, please run `jupyter lab build`:")
814828
[logger.info(" %s" % item) for item in messages]
815829

816-
def build_check(self, fast=None): # noqa
830+
def build_check(self, fast=None):
817831
"""Determine whether JupyterLab should be built.
818832
819833
Returns a list of messages.
@@ -944,7 +958,7 @@ def uninstall_extension(self, name):
944958
# Handle local extensions.
945959
if extname in local:
946960
config = self._read_build_config()
947-
data = config.setdefault("local_extensions", {}) # noqa PLW2901
961+
data = config.setdefault("local_extensions", {}) # PLW2901
948962
del data[extname]
949963
self._write_build_config(config)
950964
return True
@@ -1213,7 +1227,7 @@ def _ensure_disabled_info(self):
12131227

12141228
info["disabled_core"] = disabled_core
12151229

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):
12171231
"""Set up the assets in the staging directory."""
12181232
app_dir = self.app_dir
12191233
staging = pjoin(app_dir, "staging")
@@ -1354,7 +1368,7 @@ def _populate_staging(self, name=None, version=None, static_url=None, clean=Fals
13541368
shutil.copy(lock_template, lock_path)
13551369
os.chmod(lock_path, stat.S_IWRITE | stat.S_IREAD)
13561370

1357-
def _get_package_template(self, silent=False): # noqa
1371+
def _get_package_template(self, silent=False):
13581372
"""Get the template the for staging package.json file."""
13591373
logger = self.logger
13601374
# make a deep copy of the data so we don't influence the core data
@@ -1551,7 +1565,7 @@ def _get_linked_packages(self):
15511565
return info
15521566

15531567
for path in glob(pjoin(dname, "*.tgz")):
1554-
path = osp.abspath(path) # noqa PLW2901
1568+
path = osp.abspath(path) # PLW2901
15551569
data = read_package(path)
15561570
name = data["name"]
15571571
if name not in info:
@@ -1966,7 +1980,7 @@ def _node_check(logger):
19661980
"""Check for the existence of nodejs with the correct version."""
19671981
node = which("node")
19681982
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
19701984
logger.debug(output.decode("utf-8"))
19711985
except Exception:
19721986
data = CoreConfig()._data
@@ -1994,7 +2008,7 @@ def _yarn_config(logger):
19942008

19952009
try:
19962010
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
19982012
)
19992013
output = output_binary.decode("utf-8")
20002014
lines = iter(output.splitlines())
@@ -2061,7 +2075,7 @@ def _rmtree_star(path, logger):
20612075
_rmtree(file_path, logger)
20622076

20632077

2064-
def _validate_extension(data): # noqa
2078+
def _validate_extension(data):
20652079
"""Detect if a package is an extension using its metadata.
20662080
20672081
Returns any problems it finds.
@@ -2120,7 +2134,7 @@ def _tarsum(input_file):
21202134
"""
21212135
tar = tarfile.open(input_file, "r")
21222136
chunk_size = 100 * 1024
2123-
h = hashlib.new("sha1") # noqa: S324
2137+
h = hashlib.new("sha1")
21242138

21252139
for member in tar:
21262140
if not member.isfile():
@@ -2176,7 +2190,7 @@ def _test_overlap(spec1, spec2, drop_prerelease1=False, drop_prerelease2=False):
21762190
return cmp == 0
21772191

21782192

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):
21802194
"""Test whether two version specs overlap.
21812195
21822196
Returns `None` if we cannot determine compatibility,
@@ -2444,7 +2458,7 @@ def _fetch_package_metadata(registry, name, logger):
24442458
except AttributeError:
24452459
logger.debug("Fetching URL: %s" % (req.get_full_url()))
24462460
try:
2447-
with contextlib.closing(urlopen(req)) as response: # noqa S310
2461+
with contextlib.closing(urlopen(req)) as response: # S310
24482462
return json.loads(response.read().decode("utf-8"))
24492463
except URLError as exc:
24502464
logger.warning("Failed to fetch package metadata for %r: %r", name, exc)

0 commit comments

Comments
 (0)