python-package-folder 5.4.0__py3-none-any.whl → 7.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/analyzer.py +37 -49
- python_package_folder/manager.py +21 -1
- python_package_folder/subfolder_build.py +202 -69
- {python_package_folder-5.4.0.dist-info → python_package_folder-7.0.0.dist-info}/METADATA +1 -1
- {python_package_folder-5.4.0.dist-info → python_package_folder-7.0.0.dist-info}/RECORD +8 -8
- {python_package_folder-5.4.0.dist-info → python_package_folder-7.0.0.dist-info}/WHEEL +0 -0
- {python_package_folder-5.4.0.dist-info → python_package_folder-7.0.0.dist-info}/entry_points.txt +0 -0
- {python_package_folder-5.4.0.dist-info → python_package_folder-7.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -227,9 +227,22 @@ class ImportAnalyzer:
|
|
|
227
227
|
import_info.classification = "stdlib"
|
|
228
228
|
return
|
|
229
229
|
|
|
230
|
+
# Check if it's a third-party package (in site-packages) FIRST
|
|
231
|
+
# This must be checked before resolve_local_import to avoid incorrectly
|
|
232
|
+
# classifying site-packages modules as "external" when they're found
|
|
233
|
+
# by the recursive search
|
|
234
|
+
if self.is_third_party(module_name):
|
|
235
|
+
import_info.classification = "third_party"
|
|
236
|
+
return
|
|
237
|
+
|
|
230
238
|
# Try to resolve as a local import
|
|
231
239
|
resolved = self.resolve_local_import(import_info, src_dir)
|
|
232
240
|
if resolved is not None:
|
|
241
|
+
# Double-check: if resolved path is in site-packages, it's actually third-party
|
|
242
|
+
# (this can happen if the recursive search finds it before importlib does)
|
|
243
|
+
if "site-packages" in str(resolved) or "dist-packages" in str(resolved):
|
|
244
|
+
import_info.classification = "third_party"
|
|
245
|
+
return
|
|
233
246
|
if resolved.is_relative_to(src_dir):
|
|
234
247
|
import_info.classification = "local"
|
|
235
248
|
else:
|
|
@@ -237,11 +250,6 @@ class ImportAnalyzer:
|
|
|
237
250
|
import_info.resolved_path = resolved
|
|
238
251
|
return
|
|
239
252
|
|
|
240
|
-
# Check if it's a third-party package (in site-packages)
|
|
241
|
-
if self.is_third_party(module_name):
|
|
242
|
-
import_info.classification = "third_party"
|
|
243
|
-
return
|
|
244
|
-
|
|
245
253
|
# Mark as ambiguous if we can't determine
|
|
246
254
|
import_info.classification = "ambiguous"
|
|
247
255
|
|
|
@@ -330,56 +338,36 @@ class ImportAnalyzer:
|
|
|
330
338
|
|
|
331
339
|
# Check all subdirectories in parent (not just common ones)
|
|
332
340
|
# This handles cases like src/data/spreadsheet_creation/spreadsheet_formatting_dataclasses.py
|
|
333
|
-
|
|
341
|
+
# Use recursive search to find modules in nested directories
|
|
342
|
+
if parent.is_dir() and parent.is_relative_to(self.project_root):
|
|
343
|
+
# Recursively search for the module file in subdirectories
|
|
344
|
+
# Limit search to project_root and its subdirectories to avoid searching too broadly
|
|
345
|
+
module_basename = module_name.split(".")[-1]
|
|
334
346
|
try:
|
|
335
|
-
for
|
|
336
|
-
|
|
347
|
+
# Search recursively for the module file
|
|
348
|
+
for potential_file in parent.rglob(f"{module_basename}.py"):
|
|
349
|
+
# Only search within project_root to avoid going too far
|
|
350
|
+
if not potential_file.is_relative_to(self.project_root):
|
|
337
351
|
continue
|
|
338
|
-
# Skip
|
|
339
|
-
if
|
|
352
|
+
# Skip site-packages and dist-packages (these are third-party, not external)
|
|
353
|
+
if "site-packages" in str(potential_file) or "dist-packages" in str(potential_file):
|
|
340
354
|
continue
|
|
341
|
-
#
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
potential_subdir_module.is_dir()
|
|
349
|
-
and (potential_subdir_module / "__init__.py").exists()
|
|
355
|
+
# Skip excluded patterns
|
|
356
|
+
if any(
|
|
357
|
+
part.startswith("_SS")
|
|
358
|
+
or part.startswith("__SS")
|
|
359
|
+
or part.startswith("_sandbox")
|
|
360
|
+
or part.startswith("__sandbox")
|
|
361
|
+
for part in potential_file.parts
|
|
350
362
|
):
|
|
351
|
-
return potential_subdir_module / "__init__.py"
|
|
352
|
-
if potential_subdir_module.with_suffix(".py").is_file():
|
|
353
|
-
return potential_subdir_module.with_suffix(".py")
|
|
354
|
-
# Check nested subdirectories (e.g., data/spreadsheet_creation)
|
|
355
|
-
# Recursively check subdirectories up to 2 levels deep
|
|
356
|
-
try:
|
|
357
|
-
for nested_subdir in subdir.iterdir():
|
|
358
|
-
if not nested_subdir.is_dir():
|
|
359
|
-
continue
|
|
360
|
-
# Check if module file exists in nested subdirectory
|
|
361
|
-
potential_nested_file = (
|
|
362
|
-
nested_subdir / f"{module_name.split('.')[-1]}.py"
|
|
363
|
-
)
|
|
364
|
-
if potential_nested_file.exists():
|
|
365
|
-
return potential_nested_file
|
|
366
|
-
# Check if module directory exists in nested subdirectory
|
|
367
|
-
potential_nested_module = nested_subdir / module_name.replace(
|
|
368
|
-
".", "/"
|
|
369
|
-
)
|
|
370
|
-
if (
|
|
371
|
-
potential_nested_module.is_dir()
|
|
372
|
-
and (potential_nested_module / "__init__.py").exists()
|
|
373
|
-
):
|
|
374
|
-
return potential_nested_module / "__init__.py"
|
|
375
|
-
if potential_nested_module.with_suffix(".py").is_file():
|
|
376
|
-
return potential_nested_module.with_suffix(".py")
|
|
377
|
-
except (OSError, PermissionError):
|
|
378
|
-
# Skip nested directories we can't read
|
|
379
363
|
continue
|
|
364
|
+
# Skip if it's in the src_dir (we're looking for external dependencies)
|
|
365
|
+
if potential_file.is_relative_to(src_dir):
|
|
366
|
+
continue
|
|
367
|
+
return potential_file
|
|
380
368
|
except (OSError, PermissionError):
|
|
381
|
-
# Skip
|
|
382
|
-
|
|
369
|
+
# Skip if we can't read the directory
|
|
370
|
+
pass
|
|
383
371
|
|
|
384
372
|
# Check common subdirectories in parent (e.g., _shared, shared, common)
|
|
385
373
|
# This handles cases like src/_shared/better_enum.py
|
python_package_folder/manager.py
CHANGED
|
@@ -268,10 +268,30 @@ class BuildManager:
|
|
|
268
268
|
# This is acceptable for tests or dependency-only operations
|
|
269
269
|
if temp_pyproject is None:
|
|
270
270
|
self.subfolder_config = None
|
|
271
|
+
else:
|
|
272
|
+
# If temporary package directory was created, use it for all operations
|
|
273
|
+
# This ensures dependencies are copied to the correct location and
|
|
274
|
+
# imports are fixed in the files that will actually be packaged
|
|
275
|
+
if (
|
|
276
|
+
self.subfolder_config
|
|
277
|
+
and self.subfolder_config._temp_package_dir
|
|
278
|
+
and self.subfolder_config._temp_package_dir.exists()
|
|
279
|
+
):
|
|
280
|
+
# Update src_dir to point to temp package directory
|
|
281
|
+
self.src_dir = self.subfolder_config._temp_package_dir
|
|
282
|
+
# Recreate finder with updated src_dir so it calculates target paths correctly
|
|
283
|
+
self.finder = ExternalDependencyFinder(
|
|
284
|
+
self.project_root,
|
|
285
|
+
self.src_dir,
|
|
286
|
+
exclude_patterns=self.exclude_patterns,
|
|
287
|
+
)
|
|
288
|
+
print(
|
|
289
|
+
f"Using temporary package directory for build: {self.src_dir}"
|
|
290
|
+
)
|
|
271
291
|
|
|
272
292
|
analyzer = ImportAnalyzer(self.project_root)
|
|
273
293
|
|
|
274
|
-
# Find all Python files in src/
|
|
294
|
+
# Find all Python files in src/ (which may now be the temp package directory)
|
|
275
295
|
python_files = analyzer.find_all_python_files(self.src_dir)
|
|
276
296
|
|
|
277
297
|
# Find external dependencies using the configured finder
|
|
@@ -78,6 +78,7 @@ class SubfolderBuildConfig:
|
|
|
78
78
|
self._used_subfolder_pyproject = False
|
|
79
79
|
self._excluded_files: list[tuple[Path, Path]] = [] # List of (original_path, temp_path) tuples
|
|
80
80
|
self._exclude_temp_dir: Path | None = None
|
|
81
|
+
self._temp_package_dir: Path | None = None
|
|
81
82
|
|
|
82
83
|
def _derive_package_name(self) -> str:
|
|
83
84
|
"""
|
|
@@ -121,6 +122,70 @@ class SubfolderBuildConfig:
|
|
|
121
122
|
# Fallback to just subfolder name
|
|
122
123
|
return subfolder_name
|
|
123
124
|
|
|
125
|
+
def _create_temp_package_directory(self) -> None:
|
|
126
|
+
"""
|
|
127
|
+
Create a temporary package directory with the correct import name.
|
|
128
|
+
|
|
129
|
+
This ensures the installed package has the correct directory structure.
|
|
130
|
+
The package name (with hyphens) is converted to the import name (with underscores).
|
|
131
|
+
For example: 'ml-drawing-assistant-data' -> 'ml_drawing_assistant_data'
|
|
132
|
+
|
|
133
|
+
The temporary directory is created in the project root with the import name directly.
|
|
134
|
+
This way, hatchling will install it with the correct name without needing force-include.
|
|
135
|
+
"""
|
|
136
|
+
if not self.package_name:
|
|
137
|
+
return
|
|
138
|
+
|
|
139
|
+
# Convert package name (with hyphens) to import name (with underscores)
|
|
140
|
+
# PyPI package names use hyphens, but Python import names use underscores
|
|
141
|
+
import_name = self.package_name.replace("-", "_")
|
|
142
|
+
|
|
143
|
+
# Create temporary directory with the import name directly
|
|
144
|
+
# This way, hatchling will install it with the correct name
|
|
145
|
+
import_name_dir = self.project_root / import_name
|
|
146
|
+
|
|
147
|
+
# Check if the directory already exists and is the correct one
|
|
148
|
+
if import_name_dir.exists() and import_name_dir == self._temp_package_dir:
|
|
149
|
+
# Directory already exists and is the correct one, no need to recreate
|
|
150
|
+
return
|
|
151
|
+
|
|
152
|
+
# Remove if it already exists (from a previous build)
|
|
153
|
+
if import_name_dir.exists():
|
|
154
|
+
shutil.rmtree(import_name_dir)
|
|
155
|
+
|
|
156
|
+
# Copy the entire source directory contents directly to the import name directory
|
|
157
|
+
# Check if src_dir exists and is a directory before copying
|
|
158
|
+
if not self.src_dir.exists():
|
|
159
|
+
print(
|
|
160
|
+
f"Warning: Source directory does not exist: {self.src_dir}",
|
|
161
|
+
file=sys.stderr,
|
|
162
|
+
)
|
|
163
|
+
self._temp_package_dir = None
|
|
164
|
+
return
|
|
165
|
+
|
|
166
|
+
if not self.src_dir.is_dir():
|
|
167
|
+
print(
|
|
168
|
+
f"Warning: Source path is not a directory: {self.src_dir}",
|
|
169
|
+
file=sys.stderr,
|
|
170
|
+
)
|
|
171
|
+
self._temp_package_dir = None
|
|
172
|
+
return
|
|
173
|
+
|
|
174
|
+
try:
|
|
175
|
+
shutil.copytree(self.src_dir, import_name_dir)
|
|
176
|
+
self._temp_package_dir = import_name_dir
|
|
177
|
+
print(
|
|
178
|
+
f"Created temporary package directory: {import_name_dir} "
|
|
179
|
+
f"(import name: {import_name})"
|
|
180
|
+
)
|
|
181
|
+
except Exception as e:
|
|
182
|
+
print(
|
|
183
|
+
f"Warning: Could not create temporary package directory: {e}",
|
|
184
|
+
file=sys.stderr,
|
|
185
|
+
)
|
|
186
|
+
# Fall back to using src_dir directly
|
|
187
|
+
self._temp_package_dir = None
|
|
188
|
+
|
|
124
189
|
def _get_package_structure(self) -> tuple[str, list[str]]:
|
|
125
190
|
"""
|
|
126
191
|
Determine the package structure for hatchling.
|
|
@@ -130,21 +195,24 @@ class SubfolderBuildConfig:
|
|
|
130
195
|
- packages_path: The path to the directory containing packages
|
|
131
196
|
- package_dirs: List of package directories to include
|
|
132
197
|
"""
|
|
133
|
-
#
|
|
134
|
-
|
|
198
|
+
# Use temporary package directory if it exists, otherwise use src_dir
|
|
199
|
+
package_dir = self._temp_package_dir if self._temp_package_dir and self._temp_package_dir.exists() else self.src_dir
|
|
200
|
+
|
|
201
|
+
# Check if package_dir itself is a package (has __init__.py)
|
|
202
|
+
has_init = (package_dir / "__init__.py").exists()
|
|
135
203
|
|
|
136
|
-
# Check for Python files directly in
|
|
137
|
-
py_files = list(
|
|
204
|
+
# Check for Python files directly in package_dir
|
|
205
|
+
py_files = list(package_dir.glob("*.py"))
|
|
138
206
|
has_py_files = bool(py_files)
|
|
139
207
|
|
|
140
|
-
# Calculate relative path
|
|
208
|
+
# Calculate relative path from project root
|
|
141
209
|
try:
|
|
142
|
-
rel_path =
|
|
210
|
+
rel_path = package_dir.relative_to(self.project_root)
|
|
143
211
|
packages_path = str(rel_path).replace("\\", "/")
|
|
144
212
|
except ValueError:
|
|
145
213
|
packages_path = None
|
|
146
214
|
|
|
147
|
-
# If
|
|
215
|
+
# If package_dir has Python files but no __init__.py, we need to make it a package
|
|
148
216
|
# or include it as a module directory
|
|
149
217
|
if has_py_files and not has_init:
|
|
150
218
|
# For flat structures, we include the directory itself
|
|
@@ -298,80 +366,133 @@ class SubfolderBuildConfig:
|
|
|
298
366
|
if not self.version:
|
|
299
367
|
raise ValueError("Version is required for subfolder builds")
|
|
300
368
|
|
|
301
|
-
#
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
self._temp_init_created = True
|
|
307
|
-
else:
|
|
308
|
-
self._temp_init_created = False
|
|
309
|
-
|
|
310
|
-
# Check if pyproject.toml exists in subfolder
|
|
311
|
-
subfolder_pyproject = self.src_dir / "pyproject.toml"
|
|
312
|
-
if subfolder_pyproject.exists():
|
|
313
|
-
# Use the subfolder's pyproject.toml
|
|
314
|
-
print(f"Using existing pyproject.toml from subfolder: {subfolder_pyproject}")
|
|
315
|
-
self._used_subfolder_pyproject = True
|
|
316
|
-
|
|
317
|
-
# Store reference to original project root pyproject.toml
|
|
318
|
-
original_pyproject = self.project_root / "pyproject.toml"
|
|
319
|
-
self.original_pyproject_path = original_pyproject
|
|
320
|
-
|
|
321
|
-
# Create temporary pyproject.toml file
|
|
322
|
-
temp_pyproject_path = self.project_root / "pyproject.toml.temp"
|
|
323
|
-
|
|
324
|
-
# Read and adjust the subfolder pyproject.toml
|
|
325
|
-
subfolder_content = subfolder_pyproject.read_text(encoding="utf-8")
|
|
326
|
-
# Adjust packages path to be relative to project root
|
|
327
|
-
adjusted_content = self._adjust_subfolder_pyproject_packages_path(subfolder_content)
|
|
328
|
-
|
|
329
|
-
# Read exclude patterns from root pyproject.toml and inject them
|
|
330
|
-
exclude_patterns = read_exclude_patterns(original_pyproject)
|
|
369
|
+
# Check if pyproject.toml exists in subfolder FIRST
|
|
370
|
+
# This allows us to handle subfolder pyproject.toml even when parent doesn't exist
|
|
371
|
+
# But first ensure src_dir exists
|
|
372
|
+
if not self.src_dir.exists() or not self.src_dir.is_dir():
|
|
373
|
+
# If src_dir doesn't exist, we can't proceed
|
|
331
374
|
print(
|
|
332
|
-
f"
|
|
375
|
+
f"Warning: Source directory does not exist or is not a directory: {self.src_dir}",
|
|
333
376
|
file=sys.stderr,
|
|
334
377
|
)
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
378
|
+
return None
|
|
379
|
+
|
|
380
|
+
subfolder_pyproject = self.src_dir / "pyproject.toml"
|
|
381
|
+
if subfolder_pyproject.exists() and subfolder_pyproject.is_file():
|
|
382
|
+
# Read the subfolder pyproject.toml content IMMEDIATELY after checking it exists
|
|
383
|
+
# This prevents any issues if the file is affected by subsequent operations
|
|
384
|
+
try:
|
|
385
|
+
subfolder_content = subfolder_pyproject.read_text(encoding="utf-8")
|
|
386
|
+
except (FileNotFoundError, OSError) as e:
|
|
387
|
+
# File was deleted or inaccessible between check and read
|
|
388
|
+
print(
|
|
389
|
+
f"Warning: Could not read subfolder pyproject.toml at {subfolder_pyproject}: {e}. "
|
|
390
|
+
"Falling back to creating from parent.",
|
|
391
|
+
file=sys.stderr,
|
|
392
|
+
)
|
|
393
|
+
subfolder_content = None
|
|
394
|
+
|
|
395
|
+
if subfolder_content is not None:
|
|
396
|
+
# Ensure src_dir is a package (has __init__.py) before creating temp directory
|
|
397
|
+
# This way the __init__.py will be copied to the temp directory
|
|
398
|
+
init_file = self.src_dir / "__init__.py"
|
|
399
|
+
if not init_file.exists():
|
|
400
|
+
# Create a temporary __init__.py to make it a package
|
|
401
|
+
init_file.write_text("# Temporary __init__.py for build\n", encoding="utf-8")
|
|
402
|
+
self._temp_init_created = True
|
|
403
|
+
else:
|
|
404
|
+
self._temp_init_created = False
|
|
341
405
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
406
|
+
# Create temporary package directory with correct import name
|
|
407
|
+
# This will copy the __init__.py we just created (if any)
|
|
408
|
+
self._create_temp_package_directory()
|
|
409
|
+
|
|
410
|
+
# Determine which directory to use (temp package dir or src_dir)
|
|
411
|
+
package_dir = self._temp_package_dir if self._temp_package_dir and self._temp_package_dir.exists() else self.src_dir
|
|
412
|
+
# Use the subfolder's pyproject.toml
|
|
413
|
+
print(f"Using existing pyproject.toml from subfolder: {subfolder_pyproject}")
|
|
414
|
+
self._used_subfolder_pyproject = True
|
|
348
415
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
# Remove backup if it already exists (from previous failed test or run)
|
|
353
|
-
if backup_path.exists():
|
|
354
|
-
backup_path.unlink()
|
|
355
|
-
original_pyproject.rename(backup_path)
|
|
356
|
-
self.original_pyproject_backup = backup_path
|
|
357
|
-
|
|
358
|
-
# Move temp file to pyproject.toml for the build
|
|
359
|
-
temp_pyproject_path.rename(original_pyproject)
|
|
360
|
-
self.temp_pyproject = original_pyproject
|
|
361
|
-
|
|
362
|
-
# Handle README file
|
|
363
|
-
self._handle_readme()
|
|
416
|
+
# Store reference to original project root pyproject.toml
|
|
417
|
+
original_pyproject = self.project_root / "pyproject.toml"
|
|
418
|
+
self.original_pyproject_path = original_pyproject
|
|
364
419
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
self._exclude_files_by_patterns(exclude_patterns)
|
|
420
|
+
# Create temporary pyproject.toml file
|
|
421
|
+
temp_pyproject_path = self.project_root / "pyproject.toml.temp"
|
|
368
422
|
|
|
369
|
-
|
|
423
|
+
# Adjust packages path to be relative to project root
|
|
424
|
+
adjusted_content = self._adjust_subfolder_pyproject_packages_path(subfolder_content)
|
|
425
|
+
|
|
426
|
+
# Read exclude patterns from root pyproject.toml and inject them (if it exists)
|
|
427
|
+
exclude_patterns = []
|
|
428
|
+
if original_pyproject.exists():
|
|
429
|
+
exclude_patterns = read_exclude_patterns(original_pyproject)
|
|
430
|
+
print(
|
|
431
|
+
f"INFO: Read exclude patterns from {original_pyproject}: {exclude_patterns}",
|
|
432
|
+
file=sys.stderr,
|
|
433
|
+
)
|
|
434
|
+
else:
|
|
435
|
+
print(
|
|
436
|
+
f"INFO: No parent pyproject.toml found at {original_pyproject}, skipping exclude patterns",
|
|
437
|
+
file=sys.stderr,
|
|
438
|
+
)
|
|
439
|
+
if exclude_patterns:
|
|
440
|
+
adjusted_content = self._inject_exclude_patterns(adjusted_content, exclude_patterns)
|
|
441
|
+
|
|
442
|
+
# Write adjusted content to temporary file
|
|
443
|
+
temp_pyproject_path.write_text(adjusted_content, encoding="utf-8")
|
|
444
|
+
self.temp_pyproject = temp_pyproject_path
|
|
445
|
+
|
|
446
|
+
# Print the temporary pyproject.toml content for debugging
|
|
447
|
+
print("\n" + "=" * 80)
|
|
448
|
+
print("Temporary pyproject.toml content (from subfolder pyproject.toml):")
|
|
449
|
+
print("=" * 80)
|
|
450
|
+
print(adjusted_content)
|
|
451
|
+
print("=" * 80 + "\n")
|
|
452
|
+
|
|
453
|
+
# If original pyproject.toml exists, temporarily move it
|
|
454
|
+
if original_pyproject.exists():
|
|
455
|
+
backup_path = self.project_root / "pyproject.toml.original"
|
|
456
|
+
# Remove backup if it already exists (from previous failed test or run)
|
|
457
|
+
if backup_path.exists():
|
|
458
|
+
backup_path.unlink()
|
|
459
|
+
original_pyproject.rename(backup_path)
|
|
460
|
+
self.original_pyproject_backup = backup_path
|
|
461
|
+
|
|
462
|
+
# Move temp file to pyproject.toml for the build
|
|
463
|
+
temp_pyproject_path.rename(original_pyproject)
|
|
464
|
+
self.temp_pyproject = original_pyproject
|
|
465
|
+
|
|
466
|
+
# Handle README file
|
|
467
|
+
self._handle_readme()
|
|
468
|
+
|
|
469
|
+
# Exclude files matching exclude patterns
|
|
470
|
+
if exclude_patterns:
|
|
471
|
+
self._exclude_files_by_patterns(exclude_patterns)
|
|
472
|
+
|
|
473
|
+
return original_pyproject
|
|
370
474
|
|
|
371
475
|
# No pyproject.toml in subfolder, create one from parent
|
|
372
476
|
self._used_subfolder_pyproject = False
|
|
373
477
|
print("No pyproject.toml found in subfolder, creating temporary one from parent")
|
|
374
478
|
|
|
479
|
+
# Ensure src_dir is a package (has __init__.py) before creating temp directory
|
|
480
|
+
# This way the __init__.py will be copied to the temp directory
|
|
481
|
+
init_file = self.src_dir / "__init__.py"
|
|
482
|
+
if not init_file.exists():
|
|
483
|
+
# Create a temporary __init__.py to make it a package
|
|
484
|
+
init_file.write_text("# Temporary __init__.py for build\n", encoding="utf-8")
|
|
485
|
+
self._temp_init_created = True
|
|
486
|
+
else:
|
|
487
|
+
self._temp_init_created = False
|
|
488
|
+
|
|
489
|
+
# Create temporary package directory with correct import name
|
|
490
|
+
# This will copy the __init__.py we just created (if any)
|
|
491
|
+
self._create_temp_package_directory()
|
|
492
|
+
|
|
493
|
+
# Determine which directory to use (temp package dir or src_dir)
|
|
494
|
+
package_dir = self._temp_package_dir if self._temp_package_dir and self._temp_package_dir.exists() else self.src_dir
|
|
495
|
+
|
|
375
496
|
# Read the original pyproject.toml
|
|
376
497
|
original_pyproject = self.project_root / "pyproject.toml"
|
|
377
498
|
if not original_pyproject.exists():
|
|
@@ -1206,6 +1327,18 @@ class SubfolderBuildConfig:
|
|
|
1206
1327
|
self.original_pyproject_path = None
|
|
1207
1328
|
self._used_subfolder_pyproject = False
|
|
1208
1329
|
|
|
1330
|
+
# Remove temporary package directory if it exists
|
|
1331
|
+
if self._temp_package_dir and self._temp_package_dir.exists():
|
|
1332
|
+
try:
|
|
1333
|
+
shutil.rmtree(self._temp_package_dir)
|
|
1334
|
+
print(f"Removed temporary package directory: {self._temp_package_dir}")
|
|
1335
|
+
except Exception as e:
|
|
1336
|
+
print(
|
|
1337
|
+
f"Warning: Could not remove temporary package directory {self._temp_package_dir}: {e}",
|
|
1338
|
+
file=sys.stderr,
|
|
1339
|
+
)
|
|
1340
|
+
self._temp_package_dir = None
|
|
1341
|
+
|
|
1209
1342
|
def __enter__(self) -> Self:
|
|
1210
1343
|
"""Context manager entry."""
|
|
1211
1344
|
return self
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-package-folder
|
|
3
|
-
Version:
|
|
3
|
+
Version: 7.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>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
python_package_folder/__init__.py,sha256=DQt-uldOEKfh0MUqCvKdeNKOnpuOvpb7blYvXMyO9Wc,719
|
|
2
2
|
python_package_folder/__main__.py,sha256=a-__-VLhYw-J7S7CsHdhtEvQr3RiAZxiYDvKhKTgMX4,291
|
|
3
|
-
python_package_folder/analyzer.py,sha256=
|
|
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=erX8uPu3KA593wsSH9o15O8MNc6mwIZgGGqUJf7Z5i0,59423
|
|
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=tkZuaKFNgSTptOVu6v2sjxPfgShUmpMkapZSSyZ4UTk,59465
|
|
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-7.0.0.dist-info/METADATA,sha256=mGdHt_HrzSDGj-tBuvwG2axyjGUxoAIZhTLrgPCBPZQ,7838
|
|
15
|
+
python_package_folder-7.0.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
16
|
+
python_package_folder-7.0.0.dist-info/entry_points.txt,sha256=ttu4wAhoYSHGhWQNercLz9IVTTpXxhVlRA9vSTvaLe0,91
|
|
17
|
+
python_package_folder-7.0.0.dist-info/licenses/LICENSE,sha256=vNgRJh8YiecqZoZld7TtwPI5I72HIymKD9g32fiJjCE,1073
|
|
18
|
+
python_package_folder-7.0.0.dist-info/RECORD,,
|
|
File without changes
|
{python_package_folder-5.4.0.dist-info → python_package_folder-7.0.0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{python_package_folder-5.4.0.dist-info → python_package_folder-7.0.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|