-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: update to the 2023-09 job template schema
The job template schema is being updated for service release. With it, the implementation library is being updated in a breaking way and so this code needs to be updated to that revision. This includes a rename of the job template's specification name from the codename openjobio to Open Job Description. Signed-off-by: Daniel Neilson <neilsd@amazon.com>
- Loading branch information
Showing
14 changed files
with
101 additions
and
217 deletions.
There are no files selected for viewing
This file contains 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 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 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,47 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
import os | ||
import shutil | ||
|
||
from hatchling.builders.hooks.plugin.interface import BuildHookInterface | ||
from typing import Any | ||
|
||
|
||
class HatchCustomBuildHook(BuildHookInterface): | ||
""" | ||
This class implements Hatch's [custom build hook] (https://hatch.pypa.io/1.6/plugins/build-hook/custom/) | ||
for a copy_version_py operation that copies the _version.py file generated by the hatch-vcs build hook into | ||
specified destination directories. See the `[[tool.hatch.build.hooks.custom]]` section in `pyproject.toml`. | ||
""" | ||
|
||
def _validate_config(self): | ||
if sorted(self.config) != ["copy_version_py", "path"] or list( | ||
self.config["copy_version_py"] | ||
) != ["destinations"]: | ||
raise RuntimeError( | ||
"Configuration of the custom build hook must be like { 'copy_version_py': {'destinations': ['path1', ...]}}." | ||
+ f" Received:\n{self.config}" | ||
) | ||
|
||
def initialize(self, version: str, build_data: dict[str, Any]) -> None: | ||
self._validate_config() | ||
|
||
for destination in self.config["copy_version_py"]["destinations"]: | ||
print(f"Copying _version.py to {destination}") | ||
shutil.copy( | ||
os.path.join(self.root, "_version.py"), | ||
os.path.join(self.root, destination), | ||
) | ||
|
||
def clean(self, versions: list[str]) -> None: | ||
self._validate_config() | ||
|
||
cleaned_count = 0 | ||
for destination in self.config["copy_version_py"]["destinations"]: | ||
print(f"Cleaning _version.py from {destination}") | ||
clean_path = os.path.join(self.root, destination, "_version.py") | ||
try: | ||
os.remove(clean_path) | ||
cleaned_count += 1 | ||
except FileNotFoundError: | ||
pass | ||
print(f"Cleaned {cleaned_count} items") |
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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 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
Oops, something went wrong.