-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Introduce a dummy azpysdk #42637
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
Introduce a dummy azpysdk #42637
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dadd9d6
Add option to run uv easily if wanted
lmazuel 3f13f91
Merge branch 'main' into pyp_for_uv
scbedd a9373f2
fix tests
scbedd c9f85ac
fix dev_setup for the fact that azuresdk-tools isn't a setup.py packa…
scbedd be37761
Update eng/tools/azure-sdk-tools/pyproject.toml
scbedd 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
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
Empty file.
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,93 @@ | ||
"""azpysdk CLI | ||
|
||
A minimal command-line interface using argparse. This file provides a | ||
`main()` entrypoint so the package can be invoked as a module | ||
(e.g. `python -m azpysdk.main`) or installed as a console script. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import argparse | ||
import sys | ||
from typing import Sequence, Optional | ||
|
||
__all__ = ["main", "build_parser"] | ||
__version__ = "0.0.0" | ||
|
||
|
||
def _cmd_greet(args: argparse.Namespace) -> int: | ||
"""Simple greet command: prints a greeting.""" | ||
name = args.name or "world" | ||
print(f"Hello, {name}!") | ||
return 0 | ||
|
||
|
||
def _cmd_echo(args: argparse.Namespace) -> int: | ||
"""Echo command: prints back the provided message.""" | ||
print(args.message) | ||
return 0 | ||
|
||
|
||
def _cmd_run(args: argparse.Namespace) -> int: | ||
"""Run command: placeholder for running a task or pipeline.""" | ||
print(f"Running task: {args.task}") | ||
# TODO: implement real behaviour | ||
return 0 | ||
scbedd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
def build_parser() -> argparse.ArgumentParser: | ||
"""Create and return the top-level ArgumentParser for the CLI.""" | ||
parser = argparse.ArgumentParser( | ||
prog="azpysdk", description="Azure SDK Python tools (minimal CLI)" | ||
) | ||
parser.add_argument("-V", "--version", action="version", version=__version__) | ||
|
||
subparsers = parser.add_subparsers(title="commands", dest="command") | ||
|
||
# greet | ||
p = subparsers.add_parser("greet", help="Greet someone") | ||
p.add_argument("-n", "--name", help="Name to greet") | ||
p.set_defaults(func=_cmd_greet) | ||
|
||
# echo | ||
p = subparsers.add_parser("echo", help="Echo a message") | ||
p.add_argument("message", help="Message to echo") | ||
p.set_defaults(func=_cmd_echo) | ||
|
||
# run | ||
p = subparsers.add_parser("run", help="Run a placeholder task") | ||
scbedd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
p.add_argument("-t", "--task", default="default", help="Task name to run") | ||
p.set_defaults(func=_cmd_run) | ||
|
||
return parser | ||
|
||
|
||
def main(argv: Optional[Sequence[str]] = None) -> int: | ||
"""CLI entrypoint. | ||
|
||
Args: | ||
argv: Optional list of arguments to parse (defaults to sys.argv[1:]). | ||
|
||
Returns: | ||
Exit code to return to the OS. | ||
""" | ||
parser = build_parser() | ||
args = parser.parse_args(argv) | ||
|
||
if not hasattr(args, "func"): | ||
parser.print_help() | ||
return 1 | ||
|
||
try: | ||
result = args.func(args) | ||
return int(result or 0) | ||
except KeyboardInterrupt: | ||
print("Interrupted by user", file=sys.stderr) | ||
return 130 | ||
except Exception as exc: # pragma: no cover - simple top-level error handling | ||
print(f"Error: {exc}", file=sys.stderr) | ||
scbedd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return 2 | ||
|
||
|
||
if __name__ == "__main__": | ||
raise SystemExit(main()) |
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,3 +1,67 @@ | ||
[build-system] | ||
requires = ["setuptools>=42", "wheel"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "azure-sdk-tools" | ||
version = "0.0.0" | ||
description = "Build and test tooling for the Azure SDK for Python" | ||
readme = "README.md" | ||
authors = [ | ||
{ name = "Microsoft Corporation", email = "[email protected]" } | ||
] | ||
urls = { "Homepage" = "https://github.com/Azure/azure-sdk-for-python" } | ||
|
||
dependencies = [ | ||
"packaging", | ||
"wheel", | ||
"Jinja2", | ||
"json-delta>=2.0", | ||
"pytest-cov", | ||
"pytest>=3.5.1", | ||
"python-dotenv", | ||
"PyYAML", | ||
"urllib3", | ||
"tomli-w==1.0.0", | ||
"azure-core", | ||
"ConfigArgParse>=0.12.0", | ||
"pytest-asyncio>=0.9.0; python_version >= '3.5'", | ||
"tomli; python_version < '3.11'", | ||
] | ||
|
||
[project.scripts] | ||
generate_package = "packaging_tools.generate_package:generate_main" | ||
generate_sdk = "packaging_tools.generate_sdk:generate_main" | ||
generate_client = "packaging_tools.generate_client:generate_main" | ||
multiapi_combiner = "packaging_tools.multiapi_combiner:combine" | ||
perfstress = "devtools_testutils.perfstress_tests:run_perfstress_cmd" | ||
perfstressdebug = "devtools_testutils.perfstress_tests:run_perfstress_debug_cmd" | ||
sdk_generator = "packaging_tools.sdk_generator:generate_main" | ||
sdk_build = "ci_tools.build:build" | ||
sdk_build_package = "ci_tools.build:build_package" | ||
sdk_build_conda = "ci_tools.conda:entrypoint" | ||
sdk_set_dev_version = "ci_tools.versioning.version_set_dev:version_set_dev_main" | ||
sdk_set_version = "ci_tools.versioning.version_set:version_set_main" | ||
sdk_increment_version = "ci_tools.versioning.version_increment:version_increment_main" | ||
sdk_analyze_deps = "ci_tools.dependency_analysis:analyze_dependencies" | ||
sdk_find_invalid_versions = "ci_tools.versioning.find_invalid_versions:find_invalid_versions_main" | ||
sdk_verify_keywords = "ci_tools.keywords_verify:entrypoint" | ||
systemperf = "devtools_testutils.perfstress_tests:run_system_perfstress_tests_cmd" | ||
azpysdk = "azpysdk.main:main" | ||
|
||
[project.optional-dependencies] | ||
build = ["setuptools", "pyparsing", "certifi", "cibuildwheel", "pkginfo", "build"] | ||
conda = ["beautifulsoup4"] | ||
systemperf = ["aiohttp>=3.0", "requests>=2.0", "tornado==6.0.3", "httpx>=0.21", "azure-core"] | ||
ghtools = ["GitPython", "PyGithub>=1.59.0", "requests>=2.0"] | ||
|
||
[tool.setuptools] | ||
include-package-data = true | ||
|
||
[tool.setuptools.packages.find] | ||
where = ["."] | ||
exclude = ["tests*"] | ||
|
||
[tool.black] | ||
line-length=120 | ||
exclude="packaging_tools/templates/setup.py" |
This file was deleted.
Oops, something went wrong.
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
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.