Skip to content

Commit c7cf30a

Browse files
committed
fix cli root dir check, delete cargo builder
1 parent 9c94f4d commit c7cf30a

4 files changed

Lines changed: 16 additions & 63 deletions

File tree

src/pyproj/builder/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
from .process import process
44
from .download import download
55
from .meson import meson
6-
from .cmake import cmake
7-
from .cargo import cargo
6+
from .cmake import cmake

src/pyproj/builder/cargo.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/pyproj/cli/init_pyproj.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ def _init_pyproj(
2121
license_file: str = None
2222
copy_sources: list[str] = []
2323

24-
root.mkdir(exist_ok = True)
24+
if not root.exists():
25+
root.mkdir()
2526

26-
if not root.is_dir():
27-
raise ValueError(f"Project is not a directory: {root}")
27+
elif not root.is_dir():
28+
raise FileExistsError(f"Project is not a directory: {root}")
2829

2930
if pptoml_file.exists():
30-
raise ValueError(f"Project already exists: {pptoml_file}")
31+
raise FileExistsError(f"Project already exists: {pptoml_file}")
3132

3233
if project is None:
3334
project = root.name

tests/test_14_cli_init.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,16 @@ def test_init_pyproj_abort(tmp_path, monkeypatch):
4949
assert not (project_dir / "LICENSE.txt").exists()
5050

5151
#==============================================================================
52+
def test_cli_main_help(tmp_path, monkeypatch):
53+
def _input(*args, **kwargs):
54+
assert False
5255

56+
monkeypatch.setattr("builtins.input", _input)
57+
monkeypatch.setattr(sys, "argv", ["partis-pyproj"])
58+
59+
cli.main()
60+
61+
#==============================================================================
5362
def test_cli_main_creates_project(tmp_path, monkeypatch):
5463
project_dir = tmp_path / "cli_proj"
5564
monkeypatch.setattr("partis.pyproj.cli.init_pyproj.metadata", _stub_metadata)
@@ -109,7 +118,7 @@ def test_init_pyproj_existing_pyproject(tmp_path, monkeypatch):
109118
(project_dir / "pyproject.toml").write_text("[project]\nname='exists'\n")
110119
monkeypatch.setattr("partis.pyproj.cli.init_pyproj.metadata", _stub_metadata)
111120

112-
with pytest.raises(ValueError):
121+
with pytest.raises(FileExistsError):
113122
_init_pyproj(path=project_dir, project="exists", version="0.1.0", description="")
114123

115124

0 commit comments

Comments
 (0)