MaterialXUSD 0.25.05
Utilities for using MaterialX with USD
Loading...
Searching...
No Matches
mtlxdownload.py File Reference

MaterialX release downloader command for fetching releases and libraries from GitHub. More...

Go to the source code of this file.

Functions

None source.materialxusd.mtlxdownload.main ()
 Main function to parse command line arguments and execute the MaterialX release downloader.
 

Detailed Description

MaterialX release downloader command for fetching releases and libraries from GitHub.

Definition in file mtlxdownload.py.

Function Documentation

◆ main()

None source.materialxusd.mtlxdownload.main ( )

Main function to parse command line arguments and execute the MaterialX release downloader.

Returns
: None

Definition at line 14 of file mtlxdownload.py.

14def main() -> None:
15 """Main function to parse command line arguments and execute the MaterialX release downloader.
16
17 @return: None
18 """
19 parser = argparse.ArgumentParser(description="Download MaterialX releases and libraries.")
20 parser.add_argument("--version", type=str, default="", help="Specify the version of MaterialX to download. If not specified, the latest releases will be downloaded. e.g. 1.39.3")
21 parser.add_argument("--n", type=int, default=1, help="Number of latest releases to download (default: 15)")
22 parser.add_argument("--version-count", type=int, default=15, help="Number of latest releases to download (default: 15)")
23 parser.add_argument("--by-count", action='store_true', help="Download the latest N releases instead of a specific version")
24 parser.add_argument("--download-dir", type=str, default="downloaded_release_libraries", help="Directory to save downloaded files (default: 'downloaded_release_libraries')")
25 parser.add_argument("-l", "--libraries", action='store_true', help="Download the standard 'libraries' folder only from the releases")
26 parser.add_argument("-f", "--filter", type=str, nargs='*', default=["libraries"], help="Filter to specify which folders to extract from the release zip files (default: ['libraries'])")
27 parser.add_argument("-t", "--target", type=str, nargs='*', default=["Windows"], help="Target file names to filter the assets (default: ['Windows'])")
28
29 args = parser.parse_args()
30
31 downloader = MaterialXDownloader.MaterialXDownloader()
32 downloader.download_directory = args.download_dir
33 downloader.chunk_size = 65536*65536*16 # Set chunk size to 16 MB
34 downloader.version_count = args.version_count # Set the number of releases to download
35
36 if len(args.version) > 1:
37 version_parts = list(map(int, args.version.split('.')))
38 if len(version_parts) == 3:
39 downloader.version_number = version_parts
40 else:
41 raise ValueError("Version must be in the format 'major.minor.patch' e.g. 1.39.3")
42
43 #download_releases()
44 by_count = args.by_count
45 if args.libraries:
46 print("Downloading libraries only...")
47 downloader.remove_zip_after_extract = False
48 if args.filter:
49 print(f"Using folder filter: {args.filter}")
50 downloader.folder_filter = args.filter
51 downloader.download_libraries(by_count)
52 else:
53 print("Downloading full releases...")
54 if args.target:
55 downloader.target_file_names = args.target
56 downloader.folder_filter = []
57 downloader.download_releases(by_count)
58