Skip to content

Commit

Permalink
Don't support py_modules in build
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Nov 5, 2020
1 parent 98e1260 commit ba1e104
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
37 changes: 15 additions & 22 deletions repo_helper/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ def __init__(
verbose: bool = False
):

#: The repository
self.repo_dir = PathPlus(repo_dir)

# Walk up the tree until a "repo_helper.yml" or "git_helper.yml" (old name) file is found.
self.repo_dir = traverse_to_file(self.repo_dir, "repo_helper.yml", "git_helper.yml")
#: The repository
self.repo_dir: PathPlus = traverse_to_file(PathPlus(repo_dir), "repo_helper.yml", "git_helper.yml")

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

@property
def pkg_dir(self) -> Optional[str]:
def pkg_dir(self) -> str:
"""
The path of the package directory.
Returns :py:obj:`None` if the project only has modules.
"""

if not self.config["py_modules"]:
if self.config["stubs_package"]:
return posixpath.join(self.config["source_dir"], f"{self.config['import_name'].replace('.', '/')}-stubs")
else:
return posixpath.join(self.config["source_dir"], self.config["import_name"].replace(".", "/"))

return None
if self.config["stubs_package"]:
return posixpath.join(
self.config["source_dir"], f"{self.config['import_name'].replace('.', '/')}-stubs"
)
else:
return posixpath.join(self.config["source_dir"], self.config["import_name"].replace(".", "/"))

def iter_source_files(self) -> Iterator[PathPlus]:
if self.config["py_modules"]:
yield from self.config["py_modules"]
else:
pkgdir = self.repo_dir / self.pkg_dir
pkgdir = self.repo_dir / self.pkg_dir

for py_pattern in {"**/*.py", "**/*.pyi", "**/*.pyx", "**/py.typed"}:
for py_file in pkgdir.rglob(py_pattern):
if "__pycache__" not in py_file.parts:
yield py_file
for py_pattern in {"**/*.py", "**/*.pyi", "**/*.pyx", "**/py.typed"}:
for py_file in pkgdir.rglob(py_pattern):
if "__pycache__" not in py_file.parts:
# ref: https://github.com/python/typeshed/issues/4746
yield py_file # type: ignore

def copy_source(self) -> None:
"""
Expand Down
1 change: 1 addition & 0 deletions repo_helper/configuration/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def validate(cls, raw_config_vars: Optional[Dict[str, Any]] = None) -> Any: # n
disallowed_keys = (
additional_setup_args,
setup_pre,
py_modules,
)

for key in disallowed_keys:
Expand Down

0 comments on commit ba1e104

Please sign in to comment.