Skip to content

Commit 62c9ff6

Browse files
Merge pull request #119 from finch-tensor/wma/develop-script
Wma/develop script
2 parents d6497b5 + b82babd commit 62c9ff6

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ poetry install --with test
2626
```
2727
to install the current project and dev dependencies.
2828

29+
### Working with a local copy of Finch.jl
30+
The `develop.py ` script can be used to set up a local copy of Finch.jl for development.
31+
32+
```
33+
Usage:
34+
develop.py [--restore] [--path <path>]
35+
36+
Options:
37+
--restore Restore the original juliapkg.json file.
38+
--path Path to the local copy of Finch.jl [default: ../Finch.jl].
39+
```
40+
2941
### Publishing
3042

3143
The "Publish" GitHub Action is a manual workflow for publishing Python packages to PyPI using Poetry. It handles the version management based on the `pyproject.toml` file and automates tagging and creating GitHub releases.

develop.py

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

src/finch/julia.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import juliapkg
22
#To change the version of Finch used, see the documentation for pyjuliapkg here: https://github.com/JuliaPy/pyjuliapkg
33
#Use pyjuliapkg to modify the `juliapkg.json` file in the root of this repo.
4+
#You can also run `develop.py` to quickly use a local copy of Finch.jl.
45
#An example development json is found in `juliapkg_dev.json`
56
import juliacall as jc # noqa
67

0 commit comments

Comments
 (0)