Last active
March 2, 2019 21:22
-
-
Save tkf/7a1b24ae13d01f417d616293db164b31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: run | |
export JULIA_PROJECT = $(PWD) | |
JULIA = julia | |
JULIAC_PATH = $(shell $(JULIA) --startup-file=no -E 'normpath(Base.find_package("PackageCompiler"), "..", "..", "juliac.jl")') | |
RUN_JULIAC = $(JULIA) $(JULIAC_PATH) | |
run: builddir/test.so | |
python test.py | |
builddir/test.so: test.jl | |
$(JULIA) --color=yes -e "using Pkg; Pkg.instantiate()" | |
$(RUN_JULIAC) -vas $< |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[ArgParse]] | |
deps = ["Compat", "Test", "TextWrap"] | |
git-tree-sha1 = "37159c768f28ae52ef9af1e70669d25a68ba7d61" | |
uuid = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" | |
version = "0.6.1" | |
[[Base64]] | |
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" | |
[[BinDeps]] | |
deps = ["Compat", "Libdl", "SHA", "URIParser"] | |
git-tree-sha1 = "12093ca6cdd0ee547c39b1870e0c9c3f154d9ca9" | |
uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee" | |
version = "0.8.10" | |
[[BinaryProvider]] | |
deps = ["Libdl", "Pkg", "SHA", "Test"] | |
git-tree-sha1 = "9930c1a6cd49d9fcd7218df6be417e6ae4f1468a" | |
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" | |
version = "0.5.2" | |
[[BufferedStreams]] | |
deps = ["Compat", "Test"] | |
git-tree-sha1 = "5d55b9486590fdda5905c275bb21ce1f0754020f" | |
uuid = "e1450e63-4bb3-523b-b2a4-4ffa8c0fd77d" | |
version = "1.0.0" | |
[[Compat]] | |
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] | |
git-tree-sha1 = "2d9e14d19bad3f9ad5cc5e4cffabc3cfa59de825" | |
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" | |
version = "1.3.0" | |
[[Dates]] | |
deps = ["Printf"] | |
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" | |
[[DelimitedFiles]] | |
deps = ["Mmap"] | |
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" | |
[[Distributed]] | |
deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"] | |
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" | |
[[HTTPClient]] | |
deps = ["Compat", "LibCURL"] | |
git-tree-sha1 = "161d5776ae8e585ac0b8c20fb81f17ab755b3671" | |
uuid = "0862f596-cf2d-50af-8ef4-f2be67dfa83f" | |
version = "0.2.1" | |
[[InteractiveUtils]] | |
deps = ["LinearAlgebra", "Markdown"] | |
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" | |
[[LibCURL]] | |
deps = ["BinaryProvider", "Compat", "Libdl", "Printf"] | |
git-tree-sha1 = "6339c87cb76923a3cf947fcd213cbc364355c9c9" | |
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" | |
version = "0.4.1" | |
[[LibExpat]] | |
deps = ["Compat"] | |
git-tree-sha1 = "fde352ec13479e2f90e57939da2440fb78c5e388" | |
uuid = "522f3ed2-3f36-55e3-b6df-e94fee9b0c07" | |
version = "0.5.0" | |
[[LibGit2]] | |
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" | |
[[Libdl]] | |
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" | |
[[Libz]] | |
deps = ["BufferedStreams", "Random", "Test"] | |
git-tree-sha1 = "d405194ffc0293c3519d4f7251ce51baac9cc871" | |
uuid = "2ec943e9-cfe8-584d-b93d-64dcb6d567b7" | |
version = "1.0.0" | |
[[LinearAlgebra]] | |
deps = ["Libdl"] | |
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | |
[[Logging]] | |
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" | |
[[Markdown]] | |
deps = ["Base64"] | |
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" | |
[[Mmap]] | |
uuid = "a63ad114-7e13-5084-954f-fe012c677804" | |
[[PackageCompiler]] | |
deps = ["ArgParse", "Libdl", "Pkg", "Serialization", "SnoopCompile", "Test", "WinRPM"] | |
git-tree-sha1 = "58ae9646b6a25bb2ebd1ed1e74e22aa02375c3a7" | |
uuid = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d" | |
version = "0.5.0" | |
[[Pkg]] | |
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] | |
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | |
[[Printf]] | |
deps = ["Unicode"] | |
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" | |
[[REPL]] | |
deps = ["InteractiveUtils", "Markdown", "Sockets"] | |
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" | |
[[Random]] | |
deps = ["Serialization"] | |
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | |
[[SHA]] | |
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" | |
[[Serialization]] | |
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" | |
[[SharedArrays]] | |
deps = ["Distributed", "Mmap", "Random", "Serialization"] | |
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" | |
[[SnoopCompile]] | |
deps = ["Pkg", "Serialization", "Test"] | |
git-tree-sha1 = "bf278fd3d9ec1d8183dcf81291c1994561b66c93" | |
uuid = "aa65fe97-06da-5843-b5b1-d5d13cad87d2" | |
version = "0.3.1" | |
[[Sockets]] | |
uuid = "6462fe0b-24de-5631-8697-dd941f90decc" | |
[[SparseArrays]] | |
deps = ["LinearAlgebra", "Random"] | |
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" | |
[[Statistics]] | |
deps = ["LinearAlgebra", "SparseArrays"] | |
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | |
[[Test]] | |
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] | |
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | |
[[TextWrap]] | |
deps = ["Compat", "Test"] | |
git-tree-sha1 = "8355cc559e85469cd4dbe927c375f61d3750e002" | |
uuid = "b718987f-49a8-5099-9789-dcd902bef87d" | |
version = "0.3.0" | |
[[URIParser]] | |
deps = ["Test", "Unicode"] | |
git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69" | |
uuid = "30578b45-9adc-5946-b283-645ec420af67" | |
version = "0.4.0" | |
[[UUIDs]] | |
deps = ["Random"] | |
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" | |
[[Unicode]] | |
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" | |
[[WinRPM]] | |
deps = ["BinDeps", "Compat", "HTTPClient", "LibExpat", "Libdl", "Libz", "URIParser"] | |
git-tree-sha1 = "2a889d320f3b77d17c037f295859fe570133cfbf" | |
uuid = "c17dfb99-b4f7-5aad-8812-456da1ad7187" | |
version = "0.4.2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[deps] | |
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" | |
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Base.@ccallable function func0()::Cdouble | |
return sum([1.34, .7]) | |
end | |
Base.@ccallable function func1()::Cdouble | |
return (1.2 + .1) / 2.0 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import ctypes | |
libpath = Path(__file__).resolve().parent.joinpath("builddir", "test.so") | |
dll = ctypes.CDLL(libpath, ctypes.RTLD_GLOBAL) | |
dll.func0.restype = ctypes.c_double | |
dll.func1.restype = ctypes.c_double | |
try: | |
jl_init_with_image = dll.jl_init_with_image | |
except AttributeError: | |
jl_init_with_image = dll.jl_init_with_image__threading | |
jl_init_with_image.argtypes = [ctypes.c_char_p, ctypes.c_char_p] | |
if __name__ == "__main__": | |
jl_init_with_image(None, str(libpath).encode("utf-8")) | |
print("func1 =", dll.func1()) | |
print("func0 =", dll.func0()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment