Skip to content

Commit b7f2273

Browse files
author
Patrik Gebhardt
committed
python to rust example now works on windows
1 parent c8a198c commit b7f2273

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

python-to-rust/src/main.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
from ctypes import cdll
22
from sys import platform
33

4-
if platform == "darwin":
5-
ext = "dylib"
4+
if platform == 'darwin':
5+
prefix = 'lib'
6+
ext = 'dylib'
7+
elif platform == 'win32':
8+
prefix = ''
9+
ext = 'dll'
610
else:
7-
ext = "so"
11+
prefix = 'lib'
12+
ext = 'so'
813

9-
lib = cdll.LoadLibrary('target/debug/libdouble_input.' + ext)
14+
lib = cdll.LoadLibrary('target/debug/{}double_input.{}'.format(prefix, ext))
1015
double_input = lib.double_input
1116

1217
input = 4
1318
output = double_input(input)
14-
print(str(input) + " * 2 = " + str(output))
19+
print('{} * 2 = {}'.format(input, output))

0 commit comments

Comments
 (0)