Skip to content

Commit ba1e104

Browse files
committed
Don't support py_modules in build
1 parent 98e1260 commit ba1e104

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

repo_helper/build.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,9 @@ def __init__(
8181
verbose: bool = False
8282
):
8383

84-
#: The repository
85-
self.repo_dir = PathPlus(repo_dir)
86-
8784
# Walk up the tree until a "repo_helper.yml" or "git_helper.yml" (old name) file is found.
88-
self.repo_dir = traverse_to_file(self.repo_dir, "repo_helper.yml", "git_helper.yml")
85+
#: The repository
86+
self.repo_dir: PathPlus = traverse_to_file(PathPlus(repo_dir), "repo_helper.yml", "git_helper.yml")
8987

9088
#: The tag for the wheel
9189
self.tag = "py3-none-any"
@@ -137,31 +135,26 @@ def info_dir(self) -> PathPlus:
137135
return info_dir
138136

139137
@property
140-
def pkg_dir(self) -> Optional[str]:
138+
def pkg_dir(self) -> str:
141139
"""
142140
The path of the package directory.
143-
144-
Returns :py:obj:`None` if the project only has modules.
145141
"""
146142

147-
if not self.config["py_modules"]:
148-
if self.config["stubs_package"]:
149-
return posixpath.join(self.config["source_dir"], f"{self.config['import_name'].replace('.', '/')}-stubs")
150-
else:
151-
return posixpath.join(self.config["source_dir"], self.config["import_name"].replace(".", "/"))
152-
153-
return None
143+
if self.config["stubs_package"]:
144+
return posixpath.join(
145+
self.config["source_dir"], f"{self.config['import_name'].replace('.', '/')}-stubs"
146+
)
147+
else:
148+
return posixpath.join(self.config["source_dir"], self.config["import_name"].replace(".", "/"))
154149

155150
def iter_source_files(self) -> Iterator[PathPlus]:
156-
if self.config["py_modules"]:
157-
yield from self.config["py_modules"]
158-
else:
159-
pkgdir = self.repo_dir / self.pkg_dir
151+
pkgdir = self.repo_dir / self.pkg_dir
160152

161-
for py_pattern in {"**/*.py", "**/*.pyi", "**/*.pyx", "**/py.typed"}:
162-
for py_file in pkgdir.rglob(py_pattern):
163-
if "__pycache__" not in py_file.parts:
164-
yield py_file
153+
for py_pattern in {"**/*.py", "**/*.pyi", "**/*.pyx", "**/py.typed"}:
154+
for py_file in pkgdir.rglob(py_pattern):
155+
if "__pycache__" not in py_file.parts:
156+
# ref: https://github.com/python/typeshed/issues/4746
157+
yield py_file # type: ignore
165158

166159
def copy_source(self) -> None:
167160
"""

repo_helper/configuration/packaging.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ def validate(cls, raw_config_vars: Optional[Dict[str, Any]] = None) -> Any: # n
257257
disallowed_keys = (
258258
additional_setup_args,
259259
setup_pre,
260+
py_modules,
260261
)
261262

262263
for key in disallowed_keys:

0 commit comments

Comments
 (0)