Skip to content

Commit ea10b59

Browse files
committed
remove wrong source dist mapping assumption
1 parent 26f2630 commit ea10b59

3 files changed

Lines changed: 6 additions & 19 deletions

File tree

plux/build/hatchling.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class HatchlingPackageFinder(PackageFinder):
8181
Uses hatchling's BuilderConfig abstraction to enumerate packages.
8282
8383
TODO: include/exclude configuration of packages in hatch needs more thorough testing with different scenarios.
84+
TODO: hatchling supports path rewrites with the sources config, which is currently not supported
8485
"""
8586

8687
builder_config: BuilderConfig
@@ -116,9 +117,9 @@ def find_packages(self) -> t.Iterable[str]:
116117

117118
# Package paths in hatchling are always relative to the project root, so we join
118119
# with the project root (not self.path, which is the sources root).
119-
package_path = os.path.join(
120+
package_path = str(os.path.join(
120121
self.builder_config.root, relative_package_path
121-
)
122+
))
122123
if not os.path.isdir(package_path):
123124
continue
124125

@@ -150,8 +151,6 @@ def path(self) -> str:
150151
*contains* the top-level packages (not the project root in general).
151152
152153
Hatchling's ``sources`` dict maps ``{source_dir: dest_dir_in_wheel}``:
153-
154-
- ``{"": "src"}`` — explicit src-layout: source root is ``src/``
155154
- ``{"localstack-core/": ""}`` — packages in a subdirectory: source root is
156155
``localstack-core/`` (the key, not the value)
157156
- ``{"": ""}`` — packages directly in the project root
@@ -161,16 +160,11 @@ def path(self) -> str:
161160
if not self.builder_config.sources:
162161
return root
163162

164-
source_root = self.builder_config.sources.get("")
165-
if source_root:
166-
# Explicit mapping: "" -> "src" (or similar). The value is the source dir.
167-
return os.path.join(root, source_root)
168-
169163
# No "" key. The keys themselves are source directories (e.g. "localstack-core/").
170164
# Filter out any empty-string key that slipped through, strip trailing separators.
171165
source_dirs = [k.rstrip("/") for k in self.builder_config.sources.keys() if k]
172166
if len(source_dirs) == 1:
173-
return os.path.join(root, source_dirs[0])
167+
return os.path.join(root, str(source_dirs[0]))
174168

175169
if source_dirs:
176170
LOG.warning("plux doesn't know how to resolve multiple sources directories")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ setuptools = [
3535
"setuptools"
3636
]
3737
dev = [
38+
"plux[hatchling,setuptools]",
3839
"build",
39-
"setuptools",
4040
"pytest==8.4.1",
4141
"ruff==0.9.1",
4242
"mypy",

tests/build/test_hatchling.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -419,11 +419,4 @@ def test_path_with_packages_in_root(self, tmp_path):
419419
"""When packages are in the project root (sources = {'': ''}), path returns root."""
420420
finder = self._make_finder(sources={"": ""}, root=str(tmp_path))
421421

422-
assert finder.path == str(tmp_path)
423-
424-
def test_path_with_src_layout(self, tmp_path):
425-
"""When sources maps '' -> 'src', path returns the sources root joined to the project root."""
426-
import os
427-
finder = self._make_finder(sources={"": "src"}, root=str(tmp_path))
428-
429-
assert finder.path == os.path.join(str(tmp_path), "src")
422+
assert finder.path == str(tmp_path)

0 commit comments

Comments
 (0)