-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Owen
committed
Oct 12, 2023
1 parent
9a8a5d9
commit e14549a
Showing
4 changed files
with
97 additions
and
36 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Require a single string argument, the new package name | ||
# Example: python change_package_name.py com.example.newname | ||
|
||
from datetime import datetime | ||
from os import linesep | ||
from pathlib import Path | ||
|
||
|
||
def main() -> None: | ||
epoch_timestring = datetime.now().strftime("%s") | ||
|
||
this_file_path = Path(__file__).parent.resolve() | ||
path_to_pyproject = this_file_path / ".." / "pyproject.toml" | ||
path_to_version = this_file_path / ".." / "version.txt" | ||
|
||
try: | ||
assert path_to_pyproject.exists() | ||
except AssertionError: | ||
print("No pyproject.toml found.") | ||
exit(1) | ||
|
||
lines = path_to_pyproject.read_text().splitlines() | ||
lines_to_write = [] | ||
|
||
for line in lines: | ||
if line.startswith("name ="): | ||
lines_to_write.append('name = "darwin-nightly"\n') | ||
elif line.startswith("version ="): | ||
version = line.split("=")[1].strip() | ||
path_to_version.write_text(version) | ||
lines_to_write.append(f'version = "{epoch_timestring}"\n') | ||
else: | ||
lines_to_write.append(line) | ||
|
||
path_to_pyproject.write_text(linesep.join(lines_to_write)) | ||
|
||
print(f"Set build to a nightly in pyproject.toml - darwin-nightly@{epoch_timestring}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,41 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
from datetime import datetime | ||
from os import path | ||
from pathlib import Path | ||
|
||
|
||
def main() -> None: | ||
new_package_name = "darwin-py" | ||
|
||
this_file_path = Path(__file__).parent.resolve() | ||
path_to_pyproject = this_file_path / ".." / "pyproject.toml" | ||
path_to_version = this_file_path / ".." / "version.txt" | ||
|
||
try: | ||
assert path_to_pyproject.exists() | ||
assert path_to_version.exists() | ||
except AssertionError: | ||
print("No nightly build in place to revert") | ||
exit(1) | ||
|
||
lines = path_to_pyproject.read_text().splitlines() | ||
new_version = path_to_version.read_text().strip() | ||
|
||
lines_to_write = [] | ||
|
||
for line in lines: | ||
if line.startswith("name ="): | ||
line = f'name = "{new_package_name}"\n' | ||
if line.startswith("version ="): | ||
line = f'version = {new_version}\n' | ||
lines_to_write.append(line) | ||
|
||
path_to_pyproject.write_text("\n".join(lines_to_write)) | ||
|
||
print(f"Changed package name to {new_package_name}@{new_version} in pyproject.toml") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |