python-package-folder 4.0.0__py3-none-any.whl → 4.1.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.
@@ -27,6 +27,8 @@ def resolve_version_via_semantic_release(
27
27
  project_root: Path,
28
28
  subfolder_path: Path | None = None,
29
29
  package_name: str | None = None,
30
+ repository: str | None = None,
31
+ repository_url: str | None = None,
30
32
  ) -> str | None:
31
33
  """
32
34
  Resolve the next version using semantic-release via Node.js script.
@@ -35,6 +37,8 @@ def resolve_version_via_semantic_release(
35
37
  project_root: Root directory of the project
36
38
  subfolder_path: Optional path to subfolder (relative to project_root) for Workflow 1
37
39
  package_name: Optional package name for subfolder builds
40
+ repository: Optional target repository ('pypi', 'testpypi', or 'azure')
41
+ repository_url: Optional repository URL (required for Azure Artifacts)
38
42
 
39
43
  Returns:
40
44
  Version string if a release is determined, None if no release or error
@@ -98,7 +102,17 @@ def resolve_version_via_semantic_release(
98
102
  else subfolder_path
99
103
  )
100
104
  cmd.extend([str(rel_path), package_name])
101
- # Workflow 2: main package (no additional args needed)
105
+ elif package_name:
106
+ # Main package build with package_name (for registry queries)
107
+ # Pass null for subfolder_path, then package_name
108
+ cmd.extend(["", package_name])
109
+ # Workflow 2: main package without package_name (no additional args needed)
110
+
111
+ # Add repository information if provided
112
+ if repository:
113
+ cmd.append(repository)
114
+ if repository_url:
115
+ cmd.append(repository_url)
102
116
 
103
117
  result = subprocess.run(
104
118
  cmd,
@@ -297,6 +311,10 @@ def main() -> int:
297
311
  # Version is needed for subfolder builds or when publishing main package
298
312
  if is_subfolder or args.publish:
299
313
  print("No --version provided, attempting to resolve via semantic-release...")
314
+ # Get repository info if publishing
315
+ repository = args.publish if args.publish else None
316
+ repository_url = args.repository_url if args.publish else None
317
+
300
318
  if is_subfolder:
301
319
  # Workflow 1: subfolder build
302
320
  # src_dir is guaranteed to be relative to project_root due to is_subfolder check
@@ -305,11 +323,34 @@ def main() -> int:
305
323
  ).lower().strip("-")
306
324
  subfolder_rel_path = src_dir.relative_to(project_root)
307
325
  resolved_version = resolve_version_via_semantic_release(
308
- project_root, subfolder_rel_path, package_name
326
+ project_root,
327
+ subfolder_rel_path,
328
+ package_name,
329
+ repository=repository,
330
+ repository_url=repository_url,
309
331
  )
310
332
  else:
311
333
  # Workflow 2: main package
312
- resolved_version = resolve_version_via_semantic_release(project_root)
334
+ # For main package, we need package_name from pyproject.toml for registry queries
335
+ package_name_for_registry = None
336
+ if repository:
337
+ try:
338
+ import tomllib
339
+ pyproject_path = project_root / "pyproject.toml"
340
+ if pyproject_path.exists():
341
+ with open(pyproject_path, "rb") as f:
342
+ data = tomllib.load(f)
343
+ package_name_for_registry = data.get("project", {}).get("name")
344
+ except Exception:
345
+ pass
346
+
347
+ resolved_version = resolve_version_via_semantic_release(
348
+ project_root,
349
+ subfolder_path=None,
350
+ package_name=package_name_for_registry,
351
+ repository=repository,
352
+ repository_url=repository_url,
353
+ )
313
354
 
314
355
  if resolved_version:
315
356
  print(f"Resolved version via semantic-release: {resolved_version}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-package-folder
3
- Version: 4.0.0
3
+ Version: 4.1.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>
@@ -475,15 +475,32 @@ The `--version` option:
475
475
 
476
476
  When `--version` is not provided, the tool can automatically determine the next version using semantic-release. This requires Node.js, npm, and semantic-release to be installed.
477
477
 
478
+ **Version Detection:**
479
+ - **Baseline version**:
480
+ - **Registry Query (Preferred)**: When publishing to a repository (PyPI, TestPyPI, or Azure Artifacts), the tool queries the target registry for the latest published version and uses it as the baseline for version calculation. This ensures version calculations are based on what's actually published, not just git tags.
481
+ - **Git Tags (Fallback)**: If the package doesn't exist on the registry yet (first release) or if registry query fails, the tool falls back to using git tags to determine the starting version.
482
+ - **New version to publish**: After determining the baseline version, [`semantic-release`](https://semantic-release.gitbook.io/semantic-release/) analyzes commits since that version to calculate the next version bump (major, minor, or patch) based on [_conventional commit_](https://www.conventionalcommits.org/en/v1.0.0/) messages.
483
+
478
484
  **For subfolder builds (Workflow 1):**
479
485
  - Uses per-package tags: `{package-name}-v{version}` (e.g., `my-package-v1.2.3`)
486
+ - Queries the target registry for the latest published version of the subfolder package
480
487
  - Filters commits to only those affecting the subfolder path
488
+ - **Commit filtering behavior**: Only commits that modify files within the subfolder path are considered for version calculation. Commits that only target files outside the subfolder are excluded. For example:
489
+ - `fix: update my_subfolder/foo.py` → **Included** (affects subfolder)
490
+ - `feat: add feature to other_package/bar.py` → **Excluded** (doesn't affect subfolder)
491
+ - `fix: update my_subfolder/baz.py and shared/utils.py` → **Included** (affects subfolder, even if it also touches files outside)
481
492
  - Requires `semantic-release-commit-filter` plugin
482
493
 
483
494
  **For main package builds (Workflow 2):**
484
495
  - Uses repo-level tags: `v{version}` (e.g., `v1.2.3`)
496
+ - Queries the target registry for the latest published version when publishing
485
497
  - Analyzes all commits in the repository
486
498
 
499
+ **Registry Support:**
500
+ - **PyPI**: Fully supported via JSON API (`https://pypi.org/pypi/{package-name}/json`)
501
+ - **TestPyPI**: Fully supported via JSON API (`https://test.pypi.org/pypi/{package-name}/json`)
502
+ - **Azure Artifacts**: Basic support with fallback to git tags. Azure Artifacts uses a different API format and may require authentication, so if the query fails, the tool automatically falls back to git tags.
503
+
487
504
  **Setup:**
488
505
  ```bash
489
506
  # Install semantic-release globally
@@ -6,13 +6,13 @@ python_package_folder/finder.py,sha256=RPidZ7LKCFuQ_KgCFIZdHWPXsZIDor3M4C0hKeYW7
6
6
  python_package_folder/manager.py,sha256=Z9RPg0ZQ7jZhmEXfCzX9OrD_oiA5p2Pnm5Y9tgW3ObQ,55970
7
7
  python_package_folder/publisher.py,sha256=TSjdOvxvnWLbJCnduTK_xZBRfvsrq9kpEH-sfebeWkU,13507
8
8
  python_package_folder/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- python_package_folder/python_package_folder.py,sha256=yqwAFKjP8eAq5-cTiJJktndji5GYXPz6-uXb7b4ZwfI,15912
9
+ python_package_folder/python_package_folder.py,sha256=xSMUD_uiCOVHDDT4WNso9AxAYNyqhKI103G2rJztaXw,17907
10
10
  python_package_folder/subfolder_build.py,sha256=oH_KKLJIMByUZCl8y3AyohUO6Om0OvsIQ7Xg1fkd3jE,38782
11
11
  python_package_folder/types.py,sha256=3yeSRR5p_3PDKEAaehW_RJ7NwJHexOIeA08bGaT1iSY,2368
12
12
  python_package_folder/utils.py,sha256=lIkWsFKeAYAJ9TDUM99T4pUBHJVbUvCdUgkWQN-LUho,3111
13
13
  python_package_folder/version.py,sha256=kIDP6S9trEfs9gj7lBYGxrWm4RPssRla24UtlO9Jkh4,9111
14
- python_package_folder-4.0.0.dist-info/METADATA,sha256=nEAxlP6arQTeduyXCqtfR8ZdR5rLAAAEqGaPpoJtNyM,35525
15
- python_package_folder-4.0.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
16
- python_package_folder-4.0.0.dist-info/entry_points.txt,sha256=ttu4wAhoYSHGhWQNercLz9IVTTpXxhVlRA9vSTvaLe0,91
17
- python_package_folder-4.0.0.dist-info/licenses/LICENSE,sha256=vNgRJh8YiecqZoZld7TtwPI5I72HIymKD9g32fiJjCE,1073
18
- python_package_folder-4.0.0.dist-info/RECORD,,
14
+ python_package_folder-4.1.0.dist-info/METADATA,sha256=yk49H6KBuadlyqKiHeC589X6pBvUTBVd4YXs6idsnYE,37517
15
+ python_package_folder-4.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
16
+ python_package_folder-4.1.0.dist-info/entry_points.txt,sha256=ttu4wAhoYSHGhWQNercLz9IVTTpXxhVlRA9vSTvaLe0,91
17
+ python_package_folder-4.1.0.dist-info/licenses/LICENSE,sha256=vNgRJh8YiecqZoZld7TtwPI5I72HIymKD9g32fiJjCE,1073
18
+ python_package_folder-4.1.0.dist-info/RECORD,,