Skip to content

Commit 0d90393

Browse files
committed
Use distribution name, not package name, to check installed metadata
1 parent fad8e2e commit 0d90393

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

spin/cmds/meson.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ def _meson_cli():
2626
return [meson_cli]
2727

2828

29-
def _editable_install_path(package):
29+
def _editable_install_path(distname):
3030
import importlib_metadata
3131

3232
try:
33-
dist = importlib_metadata.Distribution.from_name(package)
33+
dist = importlib_metadata.Distribution.from_name(distname)
3434
except importlib_metadata.PackageNotFoundError:
3535
return None
3636

@@ -43,13 +43,13 @@ def _editable_install_path(package):
4343
return None
4444

4545

46-
def _is_editable_install(package):
47-
return _editable_install_path(package) is not None
46+
def _is_editable_install(distname):
47+
return _editable_install_path(distname) is not None
4848

4949

50-
def _is_editable_install_of_same_source(package):
51-
editable_path = _editable_install_path(package)
52-
return editable_path and os.path.samefile(_editable_install_path(package), ".")
50+
def _is_editable_install_of_same_source(distname):
51+
editable_path = _editable_install_path(distname)
52+
return editable_path and os.path.samefile(_editable_install_path(distname), ".")
5353

5454

5555
def _set_pythonpath(quiet=False):
@@ -63,10 +63,10 @@ def _set_pythonpath(quiet=False):
6363
env = os.environ
6464

6565
cfg = get_config()
66-
package = cfg.get("tool.spin.package", None)
67-
if package:
68-
if _is_editable_install(package):
69-
if _is_editable_install_of_same_source(package):
66+
distname = cfg.get("project.name", None)
67+
if distname:
68+
if _is_editable_install(distname):
69+
if _is_editable_install_of_same_source(distname):
7070
if not (quiet):
7171
click.secho(
7272
"Editable install of same source directory detected; not setting PYTHONPATH",
@@ -76,12 +76,12 @@ def _set_pythonpath(quiet=False):
7676
else:
7777
# Ignoring the quiet flag, because picking up the wrong package is problematic
7878
click.secho(
79-
f"Warning! Editable install of `{package}`, from a different source location, detected.",
79+
f"Warning! Editable install of `{distname}`, from a different source location, detected.",
8080
fg="bright_red",
8181
)
8282
click.secho("Spin commands will pick up that version.", fg="bright_red")
8383
click.secho(
84-
f"Try removing the other installation by switching to its source and running `pip uninstall {package}`.",
84+
f"Try removing the other installation by switching to its source and running `pip uninstall {distname}`.",
8585
fg="bright_red",
8686
)
8787

@@ -101,8 +101,8 @@ def _set_pythonpath(quiet=False):
101101
def _get_site_packages():
102102
try:
103103
cfg = get_config()
104-
package = cfg.get("tool.spin.package", None)
105-
if _is_editable_install_of_same_source(package):
104+
distname = cfg.get("project.name", None)
105+
if _is_editable_install_of_same_source(distname):
106106
return ""
107107
except RuntimeError:
108108
# Probably not running in click
@@ -188,8 +188,8 @@ def build(meson_args, jobs=None, clean=False, verbose=False, quiet=False):
188188
CFLAGS="-O0 -g" spin build
189189
"""
190190
cfg = get_config()
191-
package = cfg.get("tool.spin.package", None)
192-
if package and _is_editable_install_of_same_source(package):
191+
distname = cfg.get("project.name", None)
192+
if distname and _is_editable_install_of_same_source(distname):
193193
if not quiet:
194194
click.secho(
195195
"Editable install of same source detected; skipping build",

0 commit comments

Comments
 (0)