-
-
Notifications
You must be signed in to change notification settings - Fork 1k
improve julia language support #3494
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
Changes from 1 commit
a7f8efa
9583b19
0c54b47
5501721
ae6f19d
f2837cf
9a04b39
1ba5581
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,41 +37,36 @@ def run_hook( | |
|
|
||
| cmd = lang_base.hook_cmd(entry, args) | ||
| script = cmd[0] if is_local else prefix.path(cmd[0]) | ||
| cmd = ('julia', script, *cmd[1:]) | ||
| cmd = ('julia', '--startup-file=no', script, *cmd[1:]) | ||
| return lang_base.run_xargs( | ||
| cmd, | ||
| file_args, | ||
| require_serial=require_serial, | ||
| color=color, | ||
| ) | ||
|
|
||
|
|
||
| def get_env_patch(target_dir: str, version: str) -> PatchesT: | ||
| return ( | ||
| patches = [ | ||
| ('JULIA_LOAD_PATH', target_dir), | ||
| # May be set, remove it to not interfer with LOAD_PATH | ||
| ('JULIA_PROJECT', UNSET), | ||
| ) | ||
|
|
||
| ] | ||
| if version not in ("system", "default"): | ||
| patches.append(('JULIAUP_CHANNEL', version)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this isn't quite right. to properly support
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, pre-commit wants an entire copy of julia installed into the hook environment directory? that's very unusual for julia, which uses content-addressed read-only files and packages to allow reuse across environments. It would also make pre-commit install much slower for julia hooks than it currently is. |
||
| return tuple(patches) | ||
|
|
||
| @contextlib.contextmanager | ||
| def in_env(prefix: Prefix, version: str) -> Generator[None]: | ||
| envdir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version) | ||
| with envcontext(get_env_patch(envdir, version)): | ||
| yield | ||
|
|
||
|
|
||
| def install_environment( | ||
| prefix: Prefix, | ||
| version: str, | ||
| additional_dependencies: Sequence[str], | ||
| ) -> None: | ||
| envdir = lang_base.environment_dir(prefix, ENVIRONMENT_DIR, version) | ||
| with in_env(prefix, version): | ||
| # TODO: Support language_version with juliaup similar to rust via | ||
| # rustup | ||
| # if version != 'system': | ||
| # ... | ||
|
|
||
| # Copy Project.toml to hook env if it exist | ||
| os.makedirs(envdir, exist_ok=True) | ||
|
|
@@ -99,6 +94,11 @@ def install_environment( | |
| shutil.copy(manifest_file, envdir) | ||
| break | ||
|
|
||
| # copy `src` files if they exist | ||
| src_dir = prefix.path("src") | ||
| if os.path.isdir(src_dir): | ||
| shutil.copytree(src_dir, os.path.join(envdir, 'src')) | ||
|
|
||
| # Julia code to instantiate the hook environment | ||
| julia_code = """ | ||
| @assert length(ARGS) > 0 | ||
|
|
@@ -127,6 +127,6 @@ def install_environment( | |
| end | ||
| """ | ||
| cmd_output_b( | ||
| 'julia', '-e', julia_code, '--', envdir, *additional_dependencies, | ||
| 'julia', '--startup-file=no', '-e', julia_code, '--', envdir, *additional_dependencies, | ||
| cwd=prefix.prefix_dir, | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.