Skip to content

Commit

Permalink
fix: crash when output directory parents don't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
fyhertz committed Feb 2, 2023
1 parent 4f67c1f commit 173d5a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
7 changes: 3 additions & 4 deletions src/wheel2deb/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,12 @@ def convert_wheels(
output_directory: Path,
wheel_paths: List[Path],
) -> List[SourcePackage]:
if output_directory.exists() is False:
output_directory.mkdir(exist_ok=True)

if output_directory.is_dir() is False:
if output_directory.exists() is True and output_directory.is_dir() is False:
logger.error(f"{output_directory} is not a directory")
return []

output_directory.mkdir(exist_ok=True, parents=True)

if wheel_paths:
logger.task("Unpacking %s wheels", len(wheel_paths))

Expand Down
11 changes: 5 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ def _sha256sum(file_path: Path) -> str:

@pytest.fixture(scope="module")
def wheel_path():
"""
Create a dummy python wheel
"""
"""Create a dummy python wheel"""

tmp_path = Path(mkdtemp())
os.chdir(str(tmp_path))
(tmp_path / "foobar").mkdir()
src_path = tmp_path / "foobar"
src_path.mkdir()

open("foobar/test.py", "w").close()
open("foobar/__init__.py", "w").close()
(src_path / "test.py").touch()
(src_path / "__init__.py").touch()

with patch.object(sys, "argv", ["", "bdist_wheel"]):
from setuptools import setup
Expand Down

0 comments on commit 173d5a9

Please # to comment.