Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to import pimport library from photon. (FFI Support) #112

Closed
matheusjohannaraujo opened this issue Oct 25, 2021 · 3 comments
Closed
Labels

Comments

@matheusjohannaraujo
Copy link
Contributor

matheusjohannaraujo commented Oct 25, 2021

https://www.youtube.com/watch?v=Q8shKuNPP2o&t=3815s

File: main.w

def compute():
    print("ok")

File: ffi_example.py

from photon import pimport
main = pimport("main")
main.compute()

To generate the shared constructor file (main.so or main.dll) you need to use the command:

photon --build shared # Currently, it only works if the file is called `main.w`
python ffi_example.py
@HashLDash
Copy link
Owner

The name photon already exists in pypi ;/
We need a good library name.
I'll also change the syntax to something like this:

import photon_magic #library name
import photon_module
import other as renamed

photon_module.compute()
renamed.compute()

@matheusjohannaraujo
Copy link
Contributor Author

matheusjohannaraujo commented Oct 25, 2021

pip install photon_lang

Manually import each shared builder

from photon_lang import ffi
photon_module = ffi("photon_module")
renamed = ffi("other")

photon_module.compute()
renamed.compute()

Automatic import of shared builders

import photon_lang
import photon_module
import other as renamed

photon_module.compute()
renamed.compute()

@HashLDash
Copy link
Owner

Implemented first photon import!

Just install the photon-lang package

pip install photon-lang

import it and you should be able to import any modules in the current directory

import photon_lang
import test

print(test.compute())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants