Skip to content

Commit dfc1426

Browse files
committed
Use julia_project to manage Julia dependency
1 parent 29fda0f commit dfc1426

File tree

14 files changed

+134
-25
lines changed

14 files changed

+134
-25
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
@@ -32,16 +32,14 @@ To install diffeqpy, use pip:
3232
pip install diffeqpy
3333
```
3434

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

4241
```pycon
4342
>>> import diffeqpy
44-
>>> diffeqpy.install()
4543
```
4644

4745
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 & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
import os
2-
import subprocess
1+
from ._julia_project import julia, compile_diffeqpy, update_diffeqpy
32

4-
script_dir = os.path.dirname(os.path.realpath(__file__))
5-
6-
7-
def install():
8-
"""
9-
Install Julia packages required for diffeqpy.
10-
"""
11-
subprocess.check_call(['julia', os.path.join(script_dir, 'install.jl')])
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 & 7 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)