Skip to content

Commit 0ffc3e5

Browse files
committed
Use julia_project to manage Julia dependency
pick dfc1426 Use julia_project to manage Julia dependency pick ae59cf3 Set env variables in tox.ini pick 52ec1cd Fix setting environment variables
1 parent d374186 commit 0ffc3e5

File tree

14 files changed

+134
-52
lines changed

14 files changed

+134
-52
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ docs/_build/
5656

5757
# PyBuilder
5858
target/
59+
60+
**/Manifest.toml
61+
**/*.so

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
The MIT License (MIT)
33

4-
Copyright (c) 2018: Chris Rackauckas.
4+
Copyright (c) 2018, 2022: Chris Rackauckas.
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
include README.md
22
include LICENSE.md
33
include docs/*.txt
4+
include diffeqpy/sys_image/*.jl
5+
include diffeqpy/sys_image/Project.toml
6+
include diffeqpy/Project.toml
47
include diffeqpy/*.jl

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,14 @@ To install diffeqpy, use pip:
3131
pip install diffeqpy
3232
```
3333

34-
Using diffeqpy requires that Julia is installed and in the path, along
35-
with DifferentialEquations.jl and PyCall.jl. To install Julia,
36-
download a generic binary from
34+
You can either install Julia yourself, or allow diffeqpy to do this for you.
35+
To install Julia yourself, download a generic binary from
3736
[the JuliaLang site](https://julialang.org/downloads/) and add it to your path.
3837
To install Julia packages required for diffeqpy, open up Python
3938
interpreter then run:
4039

4140
```pycon
4241
>>> import diffeqpy
43-
>>> diffeqpy.install()
4442
```
4543

4644
and you're good! In addition, to improve the performance of your code it is

diffeqpy/Project.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[deps]
2+
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
3+
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
4+
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
5+
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"

diffeqpy/__init__.py

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,3 @@
1-
import os
2-
import shutil
3-
import subprocess
4-
import sys
1+
from ._julia_project import julia, compile_diffeqpy, update_diffeqpy
52

6-
from jill.install import install_julia
7-
8-
script_dir = os.path.dirname(os.path.realpath(__file__))
9-
10-
11-
def _find_julia():
12-
# TODO: this should probably fallback to query jill
13-
return shutil.which("julia")
14-
15-
16-
def install(*, confirm=False):
17-
"""
18-
Install Julia (if required) and Julia packages required for diffeqpy.
19-
"""
20-
julia = _find_julia()
21-
if not julia:
22-
print("No Julia version found. Installing Julia.")
23-
install_julia(confirm=confirm)
24-
julia = _find_julia()
25-
if not julia:
26-
raise RuntimeError(
27-
"Julia installed with jill but `julia` binary cannot be found in the path"
28-
)
29-
env = os.environ.copy()
30-
env["PYTHON"] = sys.executable
31-
subprocess.check_call([julia, os.path.join(script_dir, "install.jl")], env=env)
32-
33-
34-
def _ensure_installed(*kwargs):
35-
if not _find_julia():
36-
# TODO: this should probably ensure that packages are installed too
37-
install(*kwargs)
3+
from ._version import __version__

diffeqpy/_julia_project.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import julia
2+
import logging
3+
4+
from julia_project import JuliaProject
5+
6+
import os
7+
diffeqpy_path = os.path.dirname(os.path.abspath(__file__))
8+
9+
julia_project = JuliaProject(
10+
name="diffeqpy",
11+
package_path=diffeqpy_path,
12+
preferred_julia_versions = ['1.7', '1.6', 'latest'],
13+
env_prefix = 'DIFFEQPY_',
14+
logging_level = logging.INFO, # or logging.WARN,
15+
console_logging=False
16+
)
17+
18+
julia_project.run()
19+
20+
# logger = julia_project.logger
21+
22+
def compile_diffeqpy():
23+
"""
24+
Compile a system image for `diffeqpy` in the subdirectory `./sys_image/`. This
25+
system image will be loaded the next time you import `diffeqpy`.
26+
"""
27+
julia_project.compile_julia_project()
28+
29+
30+
def update_diffeqpy():
31+
"""
32+
Remove possible stale Manifest.toml files and compiled system image.
33+
Update Julia packages and rebuild Manifest.toml file.
34+
Before compiling, it's probably a good idea to call this method, then restart Python.
35+
"""
36+
julia_project.update()
37+
38+

diffeqpy/_version.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"""Define version number here and read it from setup.py automatically"""
2+
__version__ = "1.2.0"

diffeqpy/install.jl

Lines changed: 0 additions & 8 deletions
This file was deleted.

diffeqpy/sys_image/Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[deps]
2+
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
3+
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
4+
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
5+
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
6+
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"

0 commit comments

Comments
 (0)