-
Notifications
You must be signed in to change notification settings - Fork 15
Use same versioning for monorepo #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
055782f
Update dependencies for packages
ryukofc 7e735c4
Use same versioning for monorepo
ryukofc 577cc91
Revert "Use same versioning for monorepo"
ryukofc 75c3905
Use same versioning for monorepo
ryukofc aabcdaa
Use same versioning for monorepo
ryukofc 004b6db
Use same versioning for monorepo
ryukofc 86aef22
fix setup files and other tomls
ryukofc c79ad17
Fix format
ryukofc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 16 additions & 1 deletion
17
libraries/microsoft-agents-a365-observability-extensions-semantickernel/setup.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,28 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| import sys | ||
| from pathlib import Path | ||
| from os import environ | ||
| from setuptools import setup | ||
|
|
||
| # Get version from environment variable set by CI/CD | ||
| # This will be set by setuptools-git-versioning in the CI pipeline | ||
| package_version = environ.get("AGENT365_PYTHON_SDK_PACKAGE_VERSION", "0.0.0") | ||
|
|
||
| # Add versioning helper to path | ||
| helper_path = Path(__file__).parent.parent.parent / "versioning" / "helper" | ||
|
rahuldevikar761 marked this conversation as resolved.
|
||
| sys.path.insert(0, str(helper_path)) | ||
|
|
||
| from setup_utils import get_dynamic_dependencies | ||
|
|
||
| # Use minimum version strategy: | ||
| # - Internal packages get: >= current_base_version (e.g., >= 0.1.0) | ||
| # - Automatically updates when you build new versions | ||
| # - Consumers can upgrade to any higher version | ||
| setup( | ||
| version=package_version, | ||
| install_requires=get_dynamic_dependencies( | ||
| use_compatible_release=False, # No upper bound | ||
| use_exact_match=False, # Not exact match | ||
| ), | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| """ | ||
| Shared utilities for setup.py files across all Agent365 Python SDK packages. | ||
|
|
||
| This module provides helper functions to dynamically set internal package versions | ||
| at build time, ensuring all packages in the monorepo use the exact same version. | ||
| """ | ||
|
|
||
| from os import environ | ||
| from typing import List | ||
|
|
||
|
|
||
| def get_package_version() -> str: | ||
| """ | ||
| Get the package version from environment variable. | ||
|
|
||
| Returns: | ||
| The version string from AGENT365_PYTHON_SDK_PACKAGE_VERSION environment variable, | ||
| or "0.0.0" if not set. | ||
| """ | ||
| return environ.get("AGENT365_PYTHON_SDK_PACKAGE_VERSION", "0.0.0") | ||
|
|
||
|
|
||
| def get_dynamic_dependencies( | ||
| pyproject_path: str = "pyproject.toml", | ||
| use_exact_match: bool = False, | ||
| use_compatible_release: bool = False, | ||
| ) -> List[str]: | ||
| """ | ||
| Read dependencies from pyproject.toml and update internal package versions. | ||
|
|
||
| Internal packages (microsoft-agents-a365-*) can use different versioning strategies: | ||
|
|
||
| 1. Minimum version (default, recommended): | ||
| >= base_version | ||
| Example: >= 0.1.0 | ||
| - Maximum flexibility for consumers | ||
|
|
||
| 2. Compatible release: | ||
| >= base_version, < next_major_version | ||
| Example: >= 0.1.0, < 0.2.0 | ||
| - Allows updates within major version | ||
|
|
||
| 3. Exact match: | ||
| == current_version | ||
|
rahuldevikar761 marked this conversation as resolved.
|
||
| Example: == 0.1.0.dev5 | ||
| - Forces exact version match | ||
|
|
||
| External packages keep their original version constraints. | ||
|
|
||
| Args: | ||
| pyproject_path: Path to the pyproject.toml file (default: "pyproject.toml") | ||
| use_exact_match: If True, use == for internal packages | ||
| use_compatible_release: If True, use >= with < upper bound | ||
|
|
||
| Returns: | ||
| List of dependency strings with updated internal package versions | ||
| """ | ||
| package_version = get_package_version() | ||
|
|
||
| # Extract base version (remove dev/pre-release suffixes) | ||
| base_version = package_version.split(".dev")[0].split("a")[0].split("b")[0].split("rc")[0] | ||
|
rahuldevikar761 marked this conversation as resolved.
Outdated
|
||
|
|
||
| try: | ||
| import tomllib # Python 3.11+ | ||
| except ImportError: | ||
| import tomli as tomllib # Fallback for older Python | ||
|
|
||
|
rahuldevikar761 marked this conversation as resolved.
Outdated
|
||
| with open(pyproject_path, "rb") as f: | ||
| pyproject = tomllib.load(f) | ||
|
|
||
|
rahuldevikar761 marked this conversation as resolved.
Outdated
|
||
| dependencies = pyproject.get("project", {}).get("dependencies", []) | ||
|
|
||
| # Update internal package versions dynamically | ||
| updated_dependencies = [] | ||
| for dep in dependencies: | ||
| if dep.startswith("microsoft-agents-a365-"): | ||
| # Extract package name (everything before >=, ==, or other operators) | ||
| pkg_name = dep.split(">=")[0].split("==")[0].split("<")[0].strip() | ||
|
rahuldevikar761 marked this conversation as resolved.
rahuldevikar761 marked this conversation as resolved.
|
||
|
|
||
| if use_exact_match: | ||
| # Exact match: == current_version | ||
| updated_dependencies.append(f"{pkg_name} == {package_version}") | ||
| elif use_compatible_release: | ||
| # Compatible release: >= base_version, < next_major | ||
| parts = base_version.split(".") | ||
| if len(parts) >= 3: | ||
| major = int(parts[0]) | ||
| if major == 0: | ||
| # For 0.x.y, increment minor (0.1.0 -> 0.2.0) | ||
| minor = int(parts[1]) | ||
| next_major = f"{major}.{minor + 1}.0" | ||
| else: | ||
| # For x.y.z where x > 0, increment major (1.2.3 -> 2.0.0) | ||
| next_major = f"{major + 1}.0.0" | ||
|
rahuldevikar761 marked this conversation as resolved.
Outdated
|
||
| else: | ||
| next_major = base_version | ||
| updated_dependencies.append(f"{pkg_name} >= {base_version}, < {next_major}") | ||
| else: | ||
| # Minimum version (default): >= base_version | ||
| updated_dependencies.append(f"{pkg_name} >= {base_version}") | ||
|
rahuldevikar761 marked this conversation as resolved.
|
||
| else: | ||
| # Keep external dependencies as-is | ||
| updated_dependencies.append(dep) | ||
|
|
||
| return updated_dependencies | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.