-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated the build system to do a better job of getting files where th…
…ey need to go. Also added a command-line wrapper and incremented the version number
- Loading branch information
Showing
5 changed files
with
109 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os | ||
import pty | ||
import subprocess | ||
import sys | ||
|
||
|
||
def main(binary_name="CTEM"): | ||
"""Executes the binary located in the package root, passing along any command-line arguments, and streams the output to the terminal in real-time, handling progress bars correctly by using a pseudo-terminal.""" | ||
|
||
# Determine the path to the binary relative to this script | ||
package_root = os.path.dirname(os.path.abspath(__file__)) | ||
binary_path = os.path.join(package_root, binary_name) | ||
|
||
# sys.argv[1:] contains all the arguments passed to the script, excluding the script name itself | ||
args = [binary_path] + sys.argv[1:] | ||
|
||
# Use pty to spawn the process and create a pseudo-terminal | ||
main_fd, subordinate_fd = pty.openpty() | ||
|
||
# Spawn the subprocess | ||
proc = subprocess.Popen(args, stdin=subordinate_fd, stdout=subordinate_fd, stderr=subordinate_fd, close_fds=True) | ||
|
||
# Close the subordinate file descriptor in the parent process | ||
os.close(subordinate_fd) | ||
|
||
# Read the output from the main file descriptor | ||
while True: | ||
try: | ||
output = os.read(main_fd, 1024).decode() | ||
if output: | ||
sys.stdout.write(output) | ||
sys.stdout.flush() | ||
else: | ||
break | ||
except OSError: | ||
break | ||
|
||
# Wait for the subprocess to finish | ||
proc.wait() | ||
|
||
return | ||
|
||
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
2024.2.0 | ||
2024.6.0 |