-
-
Notifications
You must be signed in to change notification settings - Fork 876
ICU-23333 Create equivalent build.py scripts for all ant tasks #3912
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
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
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 |
|---|---|---|
|
|
@@ -8,3 +8,4 @@ | |
|
|
||
| # Do not display transfer progress when downloading or uploading | ||
| --no-transfer-progress | ||
| -Dfile.encoding=UTF-8 | ||
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,155 @@ | ||
| #!/usr/bin/env python3 -B | ||
| # | ||
| # Copyright (C) 2026 and later: Unicode, Inc. and others. | ||
| # License & terms of use: http://www.unicode.org/copyright.html | ||
| """Generates data in cldr-staging/production from the cldr main repo""" | ||
|
|
||
| import argparse | ||
| import os | ||
| import sys | ||
| import datetime | ||
| import subprocess | ||
|
|
||
| try: | ||
| from libs import icudirs | ||
| from libs import icufs | ||
| from libs import iculog | ||
| from libs import icuproc | ||
| except (ModuleNotFoundError, ImportError) as e: | ||
| print("Make sure you define PYTHONPATH pointing to the ICU modules:") | ||
| print(" export PYTHONPATH=<icu_root>/tools/py") | ||
| print("On Windows:") | ||
| print(" set PYTHONPATH=<icu_root>\\tools\\py") | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| basedir = "." | ||
| cldr_tmp_dir = None | ||
| cldr_prod_dir = None | ||
| cldrtools_jar = None | ||
| cldr_tmp_dir = None | ||
| notes_dir: str = "./notes" | ||
|
|
||
|
|
||
| def _init(): | ||
| """Initialization. Check folders existence, cldr-code.jar exists, etc.""" | ||
| iculog.subtitle("init()") | ||
| iculog.info(str(datetime.datetime.now())) | ||
|
|
||
| cldr_dir = icudirs.cldr_dir() | ||
|
|
||
| cldrtools_dir = os.path.join(cldr_dir, "tools") | ||
| iculog.info(f"cldr_dir:{cldr_dir}") | ||
| iculog.info(f"cldrtools_dir:{cldrtools_dir}") | ||
| if not os.path.isdir(cldrtools_dir): | ||
| iculog.failure( | ||
| "Please make sure that the CLDR tools directory" | ||
| " is checked out into CLDR_DIR" | ||
| ) | ||
|
|
||
| dir_to_check = f"{cldrtools_dir}/cldr-code/target/classes" | ||
| if not os.path.isdir(dir_to_check): | ||
| iculog.failure(f"Can't find {dir_to_check}. Please build cldr-code.jar.") | ||
|
|
||
| global cldrtools_jar | ||
| cldrtools_jar = f"{cldrtools_dir}/cldr-code/target/cldr-code.jar" | ||
| if not os.path.isfile(cldrtools_jar): | ||
| iculog.failure( | ||
| f"CLDR classes not found in {cldrtools_dir}/cldr-code/target/classes." | ||
| " Please build cldr-code.jar." | ||
| ) | ||
|
|
||
| global cldr_tmp_dir | ||
| cldr_tmp_dir = icudirs.cldr_prod_dir() | ||
| global cldr_prod_dir | ||
| cldr_prod_dir = f"{cldr_tmp_dir}/production/" | ||
|
|
||
| global notes_dir | ||
| notes_dir = os.environ.get("NOTES", "./notes") | ||
|
|
||
| subprocess.run("mvn -version", encoding="utf-8", shell=True, check=True) | ||
| iculog.info(f"cldr tools dir: {cldrtools_dir}") | ||
| iculog.info(f"cldr tools jar: {cldrtools_jar}") | ||
| iculog.info(f"CLDR_TMP_DIR: {cldr_tmp_dir} ") | ||
| iculog.info(f"cldr.prod_dir (production data): {cldr_prod_dir}") | ||
| iculog.info(f"notes_dir: {notes_dir}") | ||
|
|
||
|
|
||
| def cleanprod(): | ||
| """Remove the data in cldr-staging/production""" | ||
| iculog.title("cleanprod()") | ||
| icufs.rmdir(f"{cldr_prod_dir}/common") | ||
| icufs.rmdir(f"{cldr_prod_dir}/keyboards") | ||
|
|
||
|
|
||
| def restoreprod(): | ||
| """Restore the git version of data in cldr-staging/production""" | ||
| iculog.title("restoreprod()") | ||
| if not cldr_prod_dir: | ||
| iculog.failure("cldr_prod_dir not configured") | ||
| return | ||
| old_dir = icufs.pushd(cldr_prod_dir) | ||
| icufs.rmdir("common") | ||
| icuproc.run_with_logging( | ||
| "git checkout -- common", | ||
| logfile=os.path.join(notes_dir, "cldr-newData-restorecommonLog.txt"), | ||
| ) | ||
| icufs.rmdir("keyboards") | ||
| icuproc.run_with_logging( | ||
| "git checkout -- keyboards", | ||
| logfile=os.path.join(notes_dir, "cldr-newData-restorekeyboardsLog.txt"), | ||
| ) | ||
| icufs.popd(old_dir) | ||
|
|
||
|
|
||
| def proddata(): | ||
| """Generates data in cldr-staging/production""" | ||
| cleanprod() | ||
| iculog.title("proddata()") | ||
| iculog.info(f"Rebuilding {cldr_prod_dir} - takes a while!") | ||
| # setup prod data | ||
| icuproc.run_with_logging( | ||
| "java" | ||
| f" -cp {cldrtools_jar}" | ||
| " org.unicode.cldr.tool.GenerateProductionData" | ||
| " -v", | ||
| logfile=os.path.join(notes_dir, "cldr-newData-proddataLog.txt"), | ||
| ) | ||
|
|
||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument( | ||
| "-c", "--cleanprod", help="remove all build targets", action="store_true" | ||
| ) | ||
| parser.add_argument( | ||
| "-p", | ||
| "--proddata", | ||
| help="Rebuilds files in cldr-staging/production", | ||
| action="store_true", | ||
| ) | ||
| parser.add_argument( | ||
| "-r", | ||
| "--restore", | ||
| help="Restore (from git) the filed removed by cleanprod", | ||
| action="store_true", | ||
| ) | ||
| cmd = parser.parse_args() | ||
|
|
||
| if cmd.cleanprod: | ||
| _init() | ||
| cleanprod() | ||
| elif cmd.proddata: | ||
| _init() | ||
| proddata() | ||
| elif cmd.restore: | ||
| _init() | ||
| restoreprod() | ||
| else: | ||
| parser.print_help() | ||
|
|
||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(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
Oops, something went wrong.
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.