JuliaPy / JuliaPy/pyjulia

Installing pyjulia

Open
#473 8 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
893
Forks
101
PR merge metrics
No merged PRs in 30d

Description

Here is a little function that downloads julia if needed, set up an environmnt and instantiate the project.

I think something similar should be provided so that users can call it in `setup.py`

```python
def setup_pyjulia_env(path_to_project="."):
"""
A function that installs all dependencies for current environment.
This should be the same as what `juliacall` does at every import time.
* `path_to_project` is the path to the project that will be instantiated.
If `None`, no project will be instantiated. Defaults: to the current
working directory.
"""
import jill.install # noqa: autoimport
import os # noqa: autoimport
import shutil # noqa: autoimport
if shutil.which('julia') is None:
print(
"No Julia executable found, installing the latest version using `jill`")
jill.install.install_julia("stable", confirm=True)
if shutil.which('julia') is None:
print(f"Please add {os.environ['JILL_SYMLINK_DIR']} to your path")
import julia # noqa: autoimport
# the following installs dependencies for pyjulia
julia.install()
from julia.api import LibJulia # noqa: autoimport

if path_to_project is not None:
api = LibJulia.load()
api.init_julia([f"--project={path_to_project}"])

from julia import Main # noqa: autoimport

Main.eval('using Pkg')
Main.eval('Pkg.instantiate()')
```

Example from: https://github.com/00sapo/pyjulia-vs-juliacall

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.