-
Notifications
You must be signed in to change notification settings - Fork 5
Move packages to microsoft.teams namespace #28
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 all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d584265
Move packages to microsoft.teams namespace
heyitsaamir 59c93d9
script to create package
heyitsaamir c24378b
Fix
heyitsaamir c4dfa11
Use hyphens
heyitsaamir 73992cb
use hyphens
heyitsaamir 1abdc83
fix errors
heyitsaamir 1e0da82
fix errors
heyitsaamir 74f62e1
add no-author
heyitsaamir d6ca531
feedback
heyitsaamir 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,4 +21,4 @@ dmypy.json | |
| .DS_STORE | ||
|
|
||
| ref/ | ||
|
|
||
| py.typed | ||
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,112 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| """ | ||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
| Licensed under the MIT License. | ||
| """ | ||
|
|
||
| import argparse | ||
| import shutil | ||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
| from typing import Optional | ||
|
|
||
|
|
||
| def run_command(cmd: list[str], cwd: Optional[str] = None) -> None: | ||
| """Run a command and raise an exception if it fails.""" | ||
| result = subprocess.run(cmd, cwd=cwd, capture_output=True, text=True) | ||
| if result.returncode != 0: | ||
| print(f"Error running command: {' '.join(cmd)}") | ||
| print(f"Error output: {result.stderr}") | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| def create_package(package_name: str) -> None: | ||
| """Create a new package with the specified name.""" | ||
| # Convert package name to lowercase for directory name | ||
| package_dir = package_name.lower() | ||
| package_path = Path("packages") / package_dir | ||
| full_package_name = f"microsoft-teams-{package_name.lower()}" | ||
|
|
||
| if package_path.exists(): | ||
| print(f"Error: Package directory {package_path} already exists") | ||
| sys.exit(1) | ||
|
|
||
| # Step 1: Run uv init | ||
| print(f"Creating new package {package_name}...") | ||
| run_command(["uv", "init", "--lib", str(package_path), "--author-from", "none"]) | ||
|
|
||
| # Step 2: Move and restructure the source directory | ||
| src_dir = package_path / "src" | ||
| original_package_dir = src_dir / package_name | ||
| target_dir = src_dir / "microsoft" / "teams" / package_name.lower() | ||
|
|
||
| # Create the new directory structure | ||
| target_dir.parent.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| # Move the package directory | ||
| if original_package_dir.exists(): | ||
| shutil.move(str(original_package_dir), str(target_dir)) | ||
|
|
||
| # Step 3 & 4: Update pyproject.toml | ||
| pyproject_path = package_path / "pyproject.toml" | ||
| if pyproject_path.exists(): | ||
| with open(pyproject_path, "r") as f: | ||
| content = f.read() | ||
|
|
||
| # Update package name | ||
| content = content.replace(f'name = "{package_name}"', f'name = "{full_package_name}"') | ||
|
|
||
| # Add authors field if not present | ||
| if "authors = [" not in content: | ||
| content = content.replace( | ||
| 'description = "Add your description here"', | ||
| 'description = "Add your description here"\nauthors = [{ name = "Microsoft", email = "teams@microsoft.com" }]', # noqa: E501 | ||
| ) | ||
|
|
||
| # Add wheel build configuration | ||
| if "[tool.hatch.build.targets.wheel]" not in content: | ||
| content += '\n[tool.hatch.build.targets.wheel]\npackages = ["src/microsoft"]\n' | ||
|
|
||
| with open(pyproject_path, "w") as f: | ||
| f.write(content) | ||
|
|
||
| # Step 5: Update root pyproject.toml | ||
| root_pyproject_path = Path("pyproject.toml") | ||
| if root_pyproject_path.exists(): | ||
| with open(root_pyproject_path, "r") as f: | ||
| content = f.read() | ||
|
|
||
| # Add the new package to uv.sources if not already present | ||
| source_entry = f'"{full_package_name}" = {{ workspace = true }}' | ||
| if source_entry not in content: | ||
| # Find the [tool.uv.sources] section | ||
| if "[tool.uv.sources]" in content: | ||
| # Add the new source after the section header | ||
| content = content.replace("[tool.uv.sources]", f"[tool.uv.sources]\n{source_entry}") | ||
| else: | ||
| # Add the entire section if it doesn't exist | ||
| content += f"\n[tool.uv.sources]\n{source_entry}\n" | ||
|
|
||
| with open(root_pyproject_path, "w") as f: | ||
| f.write(content) | ||
|
|
||
| print(f"\nPackage {package_name} created successfully!") | ||
| print(f"Location: {package_path}") | ||
| print("\nNext steps:") | ||
| print("1. Add your package code in src/microsoft/teams/{package_name.lower()}") | ||
| print("2. Update the package description in pyproject.toml") | ||
| print("3. Add any required dependencies to pyproject.toml") | ||
|
|
||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser(description="Create a new package in the teams.py project") | ||
| parser.add_argument("package_name", help="Name of the package to create") | ||
| args = parser.parse_args() | ||
|
|
||
| create_package(args.package_name) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.