Skip to content

Commit 390ef0d

Browse files
committed
Merge branch 'main' into improve_toml_error_handling
2 parents f7bc416 + a6de9d0 commit 390ef0d

File tree

17 files changed

+243
-141
lines changed

17 files changed

+243
-141
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ repos:
88
- id: trailing-whitespace
99
- id: mixed-line-ending
1010
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.7.4
11+
rev: v0.9.6
1212
hooks:
1313
- id: ruff-format
1414
- id: ruff
1515
args: [ --fix ]
1616
- repo: https://github.com/pre-commit/mirrors-mypy
17-
rev: v1.13.0
17+
rev: v1.15.0
1818
hooks:
1919
# note: mypy runs in an isolated environment and so has no access to third party packages
2020
- id: mypy
2121
entry: mypy src/maturin_import_hook/ tests/test_import_hook tests/runner.py
2222
pass_filenames: false
2323
additional_dependencies: ["pytest"]
2424
- repo: https://github.com/codespell-project/codespell
25-
rev: v2.3.0
25+
rev: v2.4.1
2626
hooks:
2727
- id: codespell
2828
- repo: https://github.com/igorshubovych/markdownlint-cli
29-
rev: v0.42.0
29+
rev: v0.44.0
3030
hooks:
3131
- id: markdownlint-fix

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
- improve handling of TOML parsing errors
11+
- update to maturin 1.8.2
12+
- remove `--detect-uv` argument to `maturin_import_hook site install` because maturin now automatically detects uv
13+
environments
1114

1215
## [0.2.0]
1316

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ select = ["ALL"]
4343

4444
# https://docs.astral.sh/ruff/rules/
4545
ignore = [
46-
"ANN101", # missing-type-self
4746
"ARG", # flake8-unused-arguments
4847
"C901", # complex-structure
4948
"COM", # flake8-commas

src/maturin_import_hook/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from maturin_import_hook._logging import logger, reset_logger
77
from maturin_import_hook.settings import MaturinSettings
88

9-
__all__ = ["install", "uninstall", "reset_logger"]
9+
__all__ = ["install", "reset_logger", "uninstall"]
1010

1111

1212
def install(

src/maturin_import_hook/__main__.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ def _action_site_install(
109109
args: Optional[str],
110110
enable_project_importer: bool,
111111
enable_rs_file_importer: bool,
112-
detect_uv: bool,
113112
) -> None:
114113
if user:
115114
module_path = get_usercustomize_path()
@@ -124,7 +123,6 @@ def _action_site_install(
124123
args,
125124
enable_project_importer,
126125
enable_rs_file_importer,
127-
detect_uv,
128126
)
129127

130128

@@ -219,12 +217,6 @@ def _main() -> None:
219217
help="Whether to enable the rs file importer",
220218
action=argparse.BooleanOptionalAction,
221219
)
222-
install.add_argument(
223-
"--detect-uv",
224-
default=True,
225-
help="Whether to automatically detect and use the --uv flag",
226-
action=argparse.BooleanOptionalAction,
227-
)
228220
install.add_argument(
229221
"--args",
230222
help="The arguments to pass to `maturin`. See `maturin develop --help` or `maturin build --help`",
@@ -273,7 +265,6 @@ def _main() -> None:
273265
args=args.args,
274266
enable_project_importer=args.project_importer,
275267
enable_rs_file_importer=args.rs_file_importer,
276-
detect_uv=args.detect_uv,
277268
)
278269
elif args.sub_action == "uninstall":
279270
_action_site_uninstall(user=args.user)

src/maturin_import_hook/_site.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import dataclasses
2-
import importlib
32
import shlex
4-
import shutil
53
import site
64
from pathlib import Path
75
from typing import Optional
@@ -83,45 +81,20 @@ def remove_automatic_installation(module_path: Path) -> None:
8381
module_path.unlink(missing_ok=True)
8482

8583

86-
def _should_use_uv() -> bool:
87-
"""Whether the `--uv` flag should be used when installing into this environment.
88-
89-
virtual environments managed with `uv` do not have `pip` installed so the `--uv` flag is required.
90-
"""
91-
try:
92-
importlib.import_module("pip")
93-
except ModuleNotFoundError:
94-
if shutil.which("uv") is not None:
95-
return True
96-
else:
97-
logger.warning("neither `pip` nor `uv` were found. `maturin develop` may not work...")
98-
return False
99-
else:
100-
# since pip is a more established program, use it even if uv may be installed
101-
return False
102-
103-
10484
def insert_automatic_installation(
10585
module_path: Path,
10686
uninstall_command: str,
10787
force: bool,
10888
args: Optional[str],
10989
enable_project_importer: bool,
11090
enable_rs_file_importer: bool,
111-
detect_uv: bool,
11291
) -> None:
11392
if args is None:
11493
parsed_args = MaturinSettings.default()
11594
else:
11695
parsed_args = MaturinSettings.from_args(shlex.split(args))
11796
if parsed_args.color is None:
11897
parsed_args.color = True
119-
if detect_uv and not parsed_args.uv and _should_use_uv():
120-
parsed_args.uv = True
121-
logger.info(
122-
"using `--uv` flag as it was detected to be necessary for this environment. "
123-
"Use `site install --no-detect-uv` to set manually."
124-
)
12598

12699
logger.info(f"installing automatic activation into '{module_path}'")
127100
if has_automatic_installation(module_path):

src/maturin_import_hook/project_importer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
from maturin_import_hook.settings import MaturinSettings
4242

4343
__all__ = [
44+
"IMPORTER",
45+
"DefaultProjectFileSearcher",
4446
"MaturinProjectImporter",
47+
"ProjectFileSearcher",
4548
"install",
4649
"uninstall",
47-
"IMPORTER",
48-
"ProjectFileSearcher",
49-
"DefaultProjectFileSearcher",
5050
]
5151

5252

src/maturin_import_hook/rust_file_importer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from maturin_import_hook.error import ImportHookError
3232
from maturin_import_hook.settings import MaturinSettings
3333

34-
__all__ = ["MaturinRustFileImporter", "install", "uninstall", "IMPORTER"]
34+
__all__ = ["IMPORTER", "MaturinRustFileImporter", "install", "uninstall"]
3535

3636

3737
class MaturinRustFileImporter(importlib.abc.MetaPathFinder):

src/maturin_import_hook/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def error(self, message: str) -> None: # type: ignore[override]
184184
def exit(self, status: int = 0, message: Optional[str] = None) -> None: # type: ignore[override]
185185
pass
186186

187-
def _print_message(self, message: str, file: Optional[IO[str]] = None) -> None:
187+
def _print_message(self, message: str, file: Optional[IO[str]] = None) -> None: # type: ignore[override]
188188
pass
189189

190190

tests/maturin

Submodule maturin updated 73 files

0 commit comments

Comments
 (0)