python-package-folder 8.1.0__py3-none-any.whl → 8.2.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/finder.py +46 -29
- python_package_folder/manager.py +4 -0
- {python_package_folder-8.1.0.dist-info → python_package_folder-8.2.0.dist-info}/METADATA +1 -1
- {python_package_folder-8.1.0.dist-info → python_package_folder-8.2.0.dist-info}/RECORD +7 -7
- {python_package_folder-8.1.0.dist-info → python_package_folder-8.2.0.dist-info}/WHEEL +0 -0
- {python_package_folder-8.1.0.dist-info → python_package_folder-8.2.0.dist-info}/entry_points.txt +0 -0
- {python_package_folder-8.1.0.dist-info → python_package_folder-8.2.0.dist-info}/licenses/LICENSE +0 -0
python_package_folder/finder.py
CHANGED
|
@@ -29,18 +29,26 @@ class ExternalDependencyFinder:
|
|
|
29
29
|
"""
|
|
30
30
|
|
|
31
31
|
def __init__(
|
|
32
|
-
self,
|
|
32
|
+
self,
|
|
33
|
+
project_root: Path,
|
|
34
|
+
src_dir: Path,
|
|
35
|
+
exclude_patterns: list[str] | None = None,
|
|
36
|
+
original_src_dir: Path | None = None,
|
|
33
37
|
) -> None:
|
|
34
38
|
"""
|
|
35
39
|
Initialize the dependency finder.
|
|
36
40
|
|
|
37
41
|
Args:
|
|
38
42
|
project_root: Root directory of the project
|
|
39
|
-
src_dir: Source directory to analyze
|
|
43
|
+
src_dir: Source directory to analyze (may be temp directory for subfolder builds)
|
|
40
44
|
exclude_patterns: Additional patterns to exclude (default: common sandbox patterns)
|
|
45
|
+
original_src_dir: Original source directory before any changes (e.g., before temp directory creation).
|
|
46
|
+
Used for relative path checks. If not provided, uses src_dir.
|
|
41
47
|
"""
|
|
42
48
|
self.project_root = project_root.resolve()
|
|
43
49
|
self.src_dir = src_dir.resolve()
|
|
50
|
+
# Store original src_dir for relative path checks (important for subfolder builds)
|
|
51
|
+
self.original_src_dir = (original_src_dir or src_dir).resolve()
|
|
44
52
|
self.analyzer = ImportAnalyzer(project_root)
|
|
45
53
|
# Patterns for directories/files to exclude (sandbox, skip, etc.)
|
|
46
54
|
default_patterns = [
|
|
@@ -90,34 +98,43 @@ class ExternalDependencyFinder:
|
|
|
90
98
|
if source_path.is_file():
|
|
91
99
|
parent_dir = source_path.parent
|
|
92
100
|
|
|
93
|
-
#
|
|
94
|
-
#
|
|
95
|
-
#
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
files_are_imported = True # Always true when processing an import
|
|
99
|
-
|
|
100
|
-
# Only copy immediate parent directory, not grandparent directories
|
|
101
|
-
# This prevents copying entire trees like models/Information_extraction
|
|
102
|
-
# when we only need models/Information_extraction/_shared_ie
|
|
103
|
-
should_copy_dir = (
|
|
104
|
-
not self._should_exclude_path(parent_dir)
|
|
105
|
-
and (
|
|
106
|
-
parent_is_package or files_are_imported
|
|
107
|
-
) # Package OR files imported
|
|
108
|
-
and not parent_dir.is_relative_to(self.src_dir)
|
|
109
|
-
and not self.src_dir.is_relative_to(parent_dir)
|
|
110
|
-
and parent_dir != self.project_root
|
|
111
|
-
and parent_dir != self.project_root.parent
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
if should_copy_dir:
|
|
115
|
-
# Copy the directory instead of just the file
|
|
116
|
-
track_path = parent_dir
|
|
117
|
-
source_path = parent_dir
|
|
118
|
-
else:
|
|
119
|
-
# Copy just the file
|
|
101
|
+
# Never copy the src/ directory itself - only copy individual files at its root
|
|
102
|
+
# This prevents copying the entire src/ directory (with all subdirectories)
|
|
103
|
+
# when only a file like _globals.py is needed
|
|
104
|
+
if parent_dir == self.project_root / "src":
|
|
105
|
+
# For files at root of src/, only copy the file, not the directory
|
|
120
106
|
track_path = source_path
|
|
107
|
+
else:
|
|
108
|
+
# Only copy parent directory if:
|
|
109
|
+
# 1. It's a package (has __init__.py), OR
|
|
110
|
+
# 2. Files from it are actually imported (which is the case here)
|
|
111
|
+
# But only copy the immediate parent, not entire directory trees
|
|
112
|
+
parent_is_package = (parent_dir / "__init__.py").exists()
|
|
113
|
+
files_are_imported = True # Always true when processing an import
|
|
114
|
+
|
|
115
|
+
# Only copy immediate parent directory, not grandparent directories
|
|
116
|
+
# This prevents copying entire trees like models/Information_extraction
|
|
117
|
+
# when we only need models/Information_extraction/_shared_ie
|
|
118
|
+
# Use original_src_dir for relative path checks to correctly handle
|
|
119
|
+
# subfolder builds where src_dir may point to temp directory
|
|
120
|
+
should_copy_dir = (
|
|
121
|
+
not self._should_exclude_path(parent_dir)
|
|
122
|
+
and (
|
|
123
|
+
parent_is_package or files_are_imported
|
|
124
|
+
) # Package OR files imported
|
|
125
|
+
and not parent_dir.is_relative_to(self.src_dir)
|
|
126
|
+
and not self.original_src_dir.is_relative_to(parent_dir)
|
|
127
|
+
and parent_dir != self.project_root
|
|
128
|
+
and parent_dir != self.project_root.parent
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
if should_copy_dir:
|
|
132
|
+
# Copy the directory instead of just the file
|
|
133
|
+
track_path = parent_dir
|
|
134
|
+
source_path = parent_dir
|
|
135
|
+
else:
|
|
136
|
+
# Copy just the file
|
|
137
|
+
track_path = source_path
|
|
121
138
|
elif source_path.is_dir():
|
|
122
139
|
# Don't copy directories that contain src_dir
|
|
123
140
|
if self.src_dir.is_relative_to(source_path):
|
python_package_folder/manager.py
CHANGED
|
@@ -71,6 +71,8 @@ class BuildManager:
|
|
|
71
71
|
src_dir = self.project_root / "src"
|
|
72
72
|
|
|
73
73
|
self.src_dir = Path(src_dir).resolve()
|
|
74
|
+
# Store original src_dir before any changes (e.g., when temp directory is created)
|
|
75
|
+
self.original_src_dir = self.src_dir
|
|
74
76
|
|
|
75
77
|
# Validate source directory
|
|
76
78
|
if not self.src_dir.exists():
|
|
@@ -280,10 +282,12 @@ class BuildManager:
|
|
|
280
282
|
# Update src_dir to point to temp package directory
|
|
281
283
|
self.src_dir = self.subfolder_config._temp_package_dir
|
|
282
284
|
# Recreate finder with updated src_dir so it calculates target paths correctly
|
|
285
|
+
# Pass original_src_dir for relative path checks to prevent copying entire src/ directory
|
|
283
286
|
self.finder = ExternalDependencyFinder(
|
|
284
287
|
self.project_root,
|
|
285
288
|
self.src_dir,
|
|
286
289
|
exclude_patterns=self.exclude_patterns,
|
|
290
|
+
original_src_dir=self.original_src_dir,
|
|
287
291
|
)
|
|
288
292
|
print(
|
|
289
293
|
f"Using temporary package directory for build: {self.src_dir}"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-package-folder
|
|
3
|
-
Version: 8.
|
|
3
|
+
Version: 8.2.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,8 +1,8 @@
|
|
|
1
1
|
python_package_folder/__init__.py,sha256=DQt-uldOEKfh0MUqCvKdeNKOnpuOvpb7blYvXMyO9Wc,719
|
|
2
2
|
python_package_folder/__main__.py,sha256=a-__-VLhYw-J7S7CsHdhtEvQr3RiAZxiYDvKhKTgMX4,291
|
|
3
3
|
python_package_folder/analyzer.py,sha256=8DCc5AaVpYF9qh8NbMJ5igeW5AVYnQqy_XqRtl16ZLc,15981
|
|
4
|
-
python_package_folder/finder.py,sha256=
|
|
5
|
-
python_package_folder/manager.py,sha256=
|
|
4
|
+
python_package_folder/finder.py,sha256=wChaKPcku_U9LBQD2i6xIEKmUsKQzVUpO6H2cnxqPTE,13089
|
|
5
|
+
python_package_folder/manager.py,sha256=znZMn6BjXy6BlIgBCfPhDyNQMXcrF8pUfkiCDfW9ZXI,63375
|
|
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
|
|
@@ -11,8 +11,8 @@ python_package_folder/types.py,sha256=3yeSRR5p_3PDKEAaehW_RJ7NwJHexOIeA08bGaT1iS
|
|
|
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-8.
|
|
15
|
-
python_package_folder-8.
|
|
16
|
-
python_package_folder-8.
|
|
17
|
-
python_package_folder-8.
|
|
18
|
-
python_package_folder-8.
|
|
14
|
+
python_package_folder-8.2.0.dist-info/METADATA,sha256=Up5d-XslEXQZOjv1od0o9qwqzp1VqWekDIIHHxNR-Ro,7838
|
|
15
|
+
python_package_folder-8.2.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
16
|
+
python_package_folder-8.2.0.dist-info/entry_points.txt,sha256=ttu4wAhoYSHGhWQNercLz9IVTTpXxhVlRA9vSTvaLe0,91
|
|
17
|
+
python_package_folder-8.2.0.dist-info/licenses/LICENSE,sha256=vNgRJh8YiecqZoZld7TtwPI5I72HIymKD9g32fiJjCE,1073
|
|
18
|
+
python_package_folder-8.2.0.dist-info/RECORD,,
|
|
File without changes
|
{python_package_folder-8.1.0.dist-info → python_package_folder-8.2.0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{python_package_folder-8.1.0.dist-info → python_package_folder-8.2.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|