python-package-folder 7.0.0__py3-none-any.whl → 8.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- python_package_folder/manager.py +53 -0
- python_package_folder/subfolder_build.py +42 -14
- {python_package_folder-7.0.0.dist-info → python_package_folder-8.0.0.dist-info}/METADATA +1 -1
- {python_package_folder-7.0.0.dist-info → python_package_folder-8.0.0.dist-info}/RECORD +7 -7
- {python_package_folder-7.0.0.dist-info → python_package_folder-8.0.0.dist-info}/WHEEL +0 -0
- {python_package_folder-7.0.0.dist-info → python_package_folder-8.0.0.dist-info}/entry_points.txt +0 -0
- {python_package_folder-7.0.0.dist-info → python_package_folder-8.0.0.dist-info}/licenses/LICENSE +0 -0
python_package_folder/manager.py
CHANGED
|
@@ -933,6 +933,9 @@ class BuildManager:
|
|
|
933
933
|
ambiguous: list[ImportInfo] = []
|
|
934
934
|
|
|
935
935
|
for file_path in python_files:
|
|
936
|
+
# Skip files that don't exist (might be in temp directory that wasn't fully created)
|
|
937
|
+
if not file_path.exists():
|
|
938
|
+
continue
|
|
936
939
|
imports = analyzer.extract_imports(file_path)
|
|
937
940
|
for imp in imports:
|
|
938
941
|
analyzer.classify_import(imp, self.src_dir)
|
|
@@ -1142,6 +1145,26 @@ class BuildManager:
|
|
|
1142
1145
|
else:
|
|
1143
1146
|
print("No external dependencies found\n")
|
|
1144
1147
|
|
|
1148
|
+
# Verify temporary package directory exists if using subfolder build
|
|
1149
|
+
if self.subfolder_config and self.subfolder_config._temp_package_dir:
|
|
1150
|
+
temp_dir = self.subfolder_config._temp_package_dir
|
|
1151
|
+
if not temp_dir.exists():
|
|
1152
|
+
raise RuntimeError(
|
|
1153
|
+
f"Temporary package directory does not exist: {temp_dir}. "
|
|
1154
|
+
"This should have been created during prepare_build()."
|
|
1155
|
+
)
|
|
1156
|
+
# Verify it contains Python files
|
|
1157
|
+
py_files = list(temp_dir.glob("*.py"))
|
|
1158
|
+
if not py_files:
|
|
1159
|
+
raise RuntimeError(
|
|
1160
|
+
f"Temporary package directory exists but contains no Python files: {temp_dir}"
|
|
1161
|
+
)
|
|
1162
|
+
# Verify __init__.py exists
|
|
1163
|
+
if not (temp_dir / "__init__.py").exists():
|
|
1164
|
+
raise RuntimeError(
|
|
1165
|
+
f"Temporary package directory missing __init__.py: {temp_dir}"
|
|
1166
|
+
)
|
|
1167
|
+
|
|
1145
1168
|
print("Running build...")
|
|
1146
1169
|
# Build command should run from project root to find pyproject.toml
|
|
1147
1170
|
import os
|
|
@@ -1152,6 +1175,36 @@ class BuildManager:
|
|
|
1152
1175
|
build_command()
|
|
1153
1176
|
finally:
|
|
1154
1177
|
os.chdir(original_cwd)
|
|
1178
|
+
|
|
1179
|
+
# Verify wheel contents after build (for subfolder builds)
|
|
1180
|
+
if self.subfolder_config and self.subfolder_config.package_name:
|
|
1181
|
+
import_name = self.subfolder_config.package_name.replace("-", "_")
|
|
1182
|
+
dist_dir = self.project_root / "dist"
|
|
1183
|
+
if dist_dir.exists():
|
|
1184
|
+
wheel_files = list(dist_dir.glob("*.whl"))
|
|
1185
|
+
if wheel_files:
|
|
1186
|
+
import zipfile
|
|
1187
|
+
wheel_file = wheel_files[0]
|
|
1188
|
+
try:
|
|
1189
|
+
with zipfile.ZipFile(wheel_file, "r") as wheel:
|
|
1190
|
+
file_names = wheel.namelist()
|
|
1191
|
+
package_files = [f for f in file_names if f.startswith(f"{import_name}/")]
|
|
1192
|
+
if not package_files:
|
|
1193
|
+
print(
|
|
1194
|
+
f"\nWARNING: Built wheel does not contain package directory '{import_name}/'. "
|
|
1195
|
+
f"Only found: {[f for f in file_names if '.dist-info' not in f][:10]}",
|
|
1196
|
+
file=sys.stderr,
|
|
1197
|
+
)
|
|
1198
|
+
else:
|
|
1199
|
+
print(
|
|
1200
|
+
f"\nVerified wheel contains package directory '{import_name}/' "
|
|
1201
|
+
f"with {len(package_files)} files"
|
|
1202
|
+
)
|
|
1203
|
+
except Exception as e:
|
|
1204
|
+
print(
|
|
1205
|
+
f"\nWARNING: Could not verify wheel contents: {e}",
|
|
1206
|
+
file=sys.stderr,
|
|
1207
|
+
)
|
|
1155
1208
|
|
|
1156
1209
|
finally:
|
|
1157
1210
|
print("\nCleaning up copied files...")
|
|
@@ -280,9 +280,19 @@ class SubfolderBuildConfig:
|
|
|
280
280
|
in_sdist_section = False
|
|
281
281
|
result.append(line)
|
|
282
282
|
elif in_sdist_section:
|
|
283
|
-
#
|
|
283
|
+
# Replace only-include path if it exists
|
|
284
284
|
if re.match(r"^\s*only-include\s*=", line):
|
|
285
285
|
only_include_set = True
|
|
286
|
+
# Replace with correct path
|
|
287
|
+
only_include_paths = [correct_packages_path]
|
|
288
|
+
only_include_paths.append("pyproject.toml")
|
|
289
|
+
only_include_paths.append("README.md")
|
|
290
|
+
only_include_paths.append("README.rst")
|
|
291
|
+
only_include_paths.append("README.txt")
|
|
292
|
+
only_include_paths.append("README")
|
|
293
|
+
only_include_str = ", ".join(f'"{p}"' for p in only_include_paths)
|
|
294
|
+
result.append(f"only-include = [{only_include_str}]")
|
|
295
|
+
continue
|
|
286
296
|
result.append(line)
|
|
287
297
|
elif in_hatch_build_section:
|
|
288
298
|
result.append(line)
|
|
@@ -327,19 +337,27 @@ class SubfolderBuildConfig:
|
|
|
327
337
|
|
|
328
338
|
# Use only-include for source distributions to ensure only the subfolder is included
|
|
329
339
|
# This prevents including files from the project root
|
|
330
|
-
if
|
|
331
|
-
|
|
332
|
-
result
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
340
|
+
# Only add sdist section if it doesn't already exist and only-include wasn't set
|
|
341
|
+
if correct_packages_path:
|
|
342
|
+
# Check if sdist section already exists in result
|
|
343
|
+
sdist_section_exists = any(
|
|
344
|
+
line.strip().startswith("[tool.hatch.build.targets.sdist]")
|
|
345
|
+
for line in result
|
|
346
|
+
)
|
|
347
|
+
# Only add section and only-include if they don't already exist
|
|
348
|
+
if not sdist_section_exists and not only_include_set:
|
|
349
|
+
result.append("")
|
|
350
|
+
result.append("[tool.hatch.build.targets.sdist]")
|
|
351
|
+
# Include only the subfolder directory and necessary files
|
|
352
|
+
only_include_paths = [correct_packages_path]
|
|
353
|
+
# Also include pyproject.toml and README if they exist
|
|
354
|
+
only_include_paths.append("pyproject.toml")
|
|
355
|
+
only_include_paths.append("README.md")
|
|
356
|
+
only_include_paths.append("README.rst")
|
|
357
|
+
only_include_paths.append("README.txt")
|
|
358
|
+
only_include_paths.append("README")
|
|
359
|
+
only_include_str = ", ".join(f'"{p}"' for p in only_include_paths)
|
|
360
|
+
result.append(f"only-include = [{only_include_str}]")
|
|
343
361
|
|
|
344
362
|
return "\n".join(result)
|
|
345
363
|
|
|
@@ -407,6 +425,14 @@ class SubfolderBuildConfig:
|
|
|
407
425
|
# This will copy the __init__.py we just created (if any)
|
|
408
426
|
self._create_temp_package_directory()
|
|
409
427
|
|
|
428
|
+
# Verify temporary package directory was created
|
|
429
|
+
if not self._temp_package_dir or not self._temp_package_dir.exists():
|
|
430
|
+
print(
|
|
431
|
+
f"Warning: Temporary package directory was not created. "
|
|
432
|
+
f"Falling back to using src_dir: {self.src_dir}",
|
|
433
|
+
file=sys.stderr,
|
|
434
|
+
)
|
|
435
|
+
|
|
410
436
|
# Determine which directory to use (temp package dir or src_dir)
|
|
411
437
|
package_dir = self._temp_package_dir if self._temp_package_dir and self._temp_package_dir.exists() else self.src_dir
|
|
412
438
|
# Use the subfolder's pyproject.toml
|
|
@@ -421,6 +447,8 @@ class SubfolderBuildConfig:
|
|
|
421
447
|
temp_pyproject_path = self.project_root / "pyproject.toml.temp"
|
|
422
448
|
|
|
423
449
|
# Adjust packages path to be relative to project root
|
|
450
|
+
# This must be called AFTER _create_temp_package_directory() so _get_package_structure()
|
|
451
|
+
# can find the temporary directory
|
|
424
452
|
adjusted_content = self._adjust_subfolder_pyproject_packages_path(subfolder_content)
|
|
425
453
|
|
|
426
454
|
# Read exclude patterns from root pyproject.toml and inject them (if it exists)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-package-folder
|
|
3
|
-
Version:
|
|
3
|
+
Version: 8.0.0
|
|
4
4
|
Summary: Python package to automatically package and build a folder, fetching all relevant dependencies.
|
|
5
5
|
Project-URL: Repository, https://github.com/alelom/python-package-folder
|
|
6
6
|
Author-email: Alessio Lombardi <work@alelom.com>
|
|
@@ -2,17 +2,17 @@ python_package_folder/__init__.py,sha256=DQt-uldOEKfh0MUqCvKdeNKOnpuOvpb7blYvXMy
|
|
|
2
2
|
python_package_folder/__main__.py,sha256=a-__-VLhYw-J7S7CsHdhtEvQr3RiAZxiYDvKhKTgMX4,291
|
|
3
3
|
python_package_folder/analyzer.py,sha256=8DCc5AaVpYF9qh8NbMJ5igeW5AVYnQqy_XqRtl16ZLc,15981
|
|
4
4
|
python_package_folder/finder.py,sha256=RPidZ7LKCFuQ_KgCFIZdHWPXsZIDor3M4C0hKeYW7EI,11799
|
|
5
|
-
python_package_folder/manager.py,sha256=
|
|
5
|
+
python_package_folder/manager.py,sha256=XcFVFe8O96SJfck4sY4a75j3WrdYP7km6Lh2JkQC6JY,62407
|
|
6
6
|
python_package_folder/publisher.py,sha256=fmf3l0zMY9CD49gurxlXyvm9mOP0FzDjmiSt0yDqt1M,18813
|
|
7
7
|
python_package_folder/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
python_package_folder/python_package_folder.py,sha256=QZ-vdOZ40wF-eGbp39JotDhMwIhhT3Z_sC5obQj3i4s,17024
|
|
9
|
-
python_package_folder/subfolder_build.py,sha256=
|
|
9
|
+
python_package_folder/subfolder_build.py,sha256=KKrvcngx8-IXo-Cl7PUaX8XPEy3WIynIwlRgJOMz0Zo,61121
|
|
10
10
|
python_package_folder/types.py,sha256=3yeSRR5p_3PDKEAaehW_RJ7NwJHexOIeA08bGaT1iSY,2368
|
|
11
11
|
python_package_folder/utils.py,sha256=b6Ukcc0fctXdxS5zhGLS86kqn0vz1yOEK7XjCY9fjfY,5621
|
|
12
12
|
python_package_folder/version.py,sha256=kIDP6S9trEfs9gj7lBYGxrWm4RPssRla24UtlO9Jkh4,9111
|
|
13
13
|
python_package_folder/version_calculator.py,sha256=_gcc8IbMjt27UxePcc7RZlFTMCG3AGnRI_-Mp_4qRG0,39568
|
|
14
|
-
python_package_folder-
|
|
15
|
-
python_package_folder-
|
|
16
|
-
python_package_folder-
|
|
17
|
-
python_package_folder-
|
|
18
|
-
python_package_folder-
|
|
14
|
+
python_package_folder-8.0.0.dist-info/METADATA,sha256=6icCAnYKRqZLbCdrPdi1Bj8cwzRRGax4YzaY12PSiP0,7838
|
|
15
|
+
python_package_folder-8.0.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
16
|
+
python_package_folder-8.0.0.dist-info/entry_points.txt,sha256=ttu4wAhoYSHGhWQNercLz9IVTTpXxhVlRA9vSTvaLe0,91
|
|
17
|
+
python_package_folder-8.0.0.dist-info/licenses/LICENSE,sha256=vNgRJh8YiecqZoZld7TtwPI5I72HIymKD9g32fiJjCE,1073
|
|
18
|
+
python_package_folder-8.0.0.dist-info/RECORD,,
|
|
File without changes
|
{python_package_folder-7.0.0.dist-info → python_package_folder-8.0.0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{python_package_folder-7.0.0.dist-info → python_package_folder-8.0.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|