Skip to content

Commit

Permalink
Support pyproject.toml without build system to detect project name
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Feb 11, 2023
1 parent 4672fcc commit e62593c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/84.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support pyproject.toml without build system to detect project name.
3 changes: 1 addition & 2 deletions src/pip_deepfreeze/project_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ def get_project_name_from_pyproject_toml_pep621(
pyproject_toml: Optional[PyProjectToml],
) -> Optional[str]:
log_info(".", nl=False)
if not _get_build_backend(pyproject_toml):
if not pyproject_toml:
return None
assert pyproject_toml
project_name = pyproject_toml.get("project", {}).get("name")
if not project_name:
return None
Expand Down
16 changes: 16 additions & 0 deletions tests/test_project_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,22 @@ def test_get_project_name_from_pyproject_toml_pep621_no_project(tmp_path):
)


def test_get_project_name_from_pyproject_toml_pep621_no_build_system(tmp_path):
(tmp_path / "pyproject.toml").write_text(
textwrap.dedent(
"""\
[project]
name = "theproject"
"""
)
)
assert (
get_project_name_from_pyproject_toml_pep621(_load_pyproject_toml(tmp_path))
== "theproject"
)
assert get_project_name(sys.executable, tmp_path) == "theproject"


def test_project_name_from_pep517_setup_py(tmp_path):
setup_py = tmp_path / "setup.py"
setup_py.write_text(
Expand Down

0 comments on commit e62593c

Please sign in to comment.