Skip to content

Commit 9a9884a

Browse files
authored
feat: out-of-box stubs package support (#280)
* out-of-box stubs package support * Update pyproject.toml
1 parent 4bd3755 commit 9a9884a

File tree

6 files changed

+24
-1
lines changed

6 files changed

+24
-1
lines changed

src/pdm/backend/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ def is_python_package(fullpath: str) -> bool:
4444
return False
4545
if os.path.basename(fullpath.rstrip("/")) in ("__pycache__", "__pypackages__"):
4646
return False
47-
return os.path.isfile(os.path.join(fullpath, "__init__.py"))
47+
if os.path.isfile(os.path.join(fullpath, "__init__.py")):
48+
return True
49+
# stubs
50+
return os.path.basename(fullpath).endswith("-stubs") and os.path.isfile(
51+
os.path.join(fullpath, "__init__.pyi")
52+
)
4853

4954

5055
def merge_marker(requirement: Requirement, marker: str) -> None:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MIT License
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This is a demo module for a stub package
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[build-system]
2+
requires = ["pdm-backend"]
3+
build-backend = "pdm.backend"
4+
5+
[project]
6+
authors = [
7+
{name = "frostming", email = "[email protected]"},
8+
]
9+
version = '0.0.0'
10+
requires-python = ">=2.7"
11+
license = "MIT"
12+
dependencies = ["flask"]
13+
description = ""
14+
name = "demo-package-stubs"
15+
readme = "README.md"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def hello_world() -> None: ...

tests/fixtures/projects/demo-package-stubs/src/my_package-stubs/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)