-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdevelop.py
executable file
·50 lines (41 loc) · 1.74 KB
/
develop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env poetry run python
import shutil
import juliapkg
import argparse
import os
script_dir = os.path.dirname(os.path.abspath(__file__))
source_file = os.path.join(script_dir, 'src/finch/juliapkg.json')
backup_file = os.path.join(script_dir, 'src/finch/juliapkg.json.orig')
# Parse command-line arguments
usage = """
Usage:
develop.py [--restore] [--path <path>]
Options:
--restore Restore the original juliapkg.json file.
--path Path to the local copy of Finch.jl [default: ../Finch.jl].
"""
parser = argparse.ArgumentParser(description="Development script for Finch. This script allows you to specify the location of a local copy of Finch.jl.", usage=usage)
parser.add_argument("--path", default=os.path.join(script_dir, "../Finch.jl"), help="Path to the Finch.jl package.")
parser.add_argument("--restore", action="store_true", help="Restore the original juliapkg.json file.")
args = parser.parse_args()
# Handle the --restore flag
if args.restore:
try:
shutil.copy(backup_file, source_file)
print("Restored src/finch/juliapkg.json from backup.")
except FileNotFoundError:
print("Error: Backup file src/finch/juliapkg.json.orig does not exist.")
except Exception as e:
print(f"An error occurred: {e}")
exit()
# Set the Finch path
finch_path = os.path.abspath(args.path)
# Define source and destination file paths and copy the file
try:
if not os.path.exists(backup_file):
shutil.copy(source_file, backup_file)
except Exception as e:
print(f"An error occurred: {e}")
#Checkout Finch for development
juliapkg.rm("Finch", target='src/finch/juliapkg.json')
juliapkg.add("Finch", "9177782c-1635-4eb9-9bfb-d9dfa25e6bce", dev=True, path=finch_path, target='src/finch/juliapkg.json')