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

Using PythonCall within Julia modules #57

Closed
haberdashPI opened this issue Oct 4, 2021 · 3 comments
Closed

Using PythonCall within Julia modules #57

haberdashPI opened this issue Oct 4, 2021 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@haberdashPI
Copy link
Contributor

haberdashPI commented Oct 4, 2021

First of all, thanks for working on this, I really appreciate these improvements from PyCall.

Seems like calling pyimport from the top level of a module in precompiled code would create issues.

In PyCall, the following approach is recommended:

const scipy_opt = PyNULL()

function __init__()
    copy!(scipy_opt, pyimport_conda("scipy.optimize", "scipy"))
end

end

I think the equivalent in PythonCall would be

const scipy_opt = pynew()

function __init__()
   pycopy!(scipy_opt, pyimport("scipy.optimize"))
end

It would be worth documenting this somewhere. Obviously a lot of folks are going to be coming from PyCall (and will know to be mindful of this) but it would be better to make this fact explicit, or indicate that this isn't required.

@cjdoris
Copy link
Collaborator

cjdoris commented Oct 4, 2021

Technically it's documented here: https://cjdoris.github.io/PythonCall.jl/dev/pythoncall/#PythonCall.pycopy!

But that's definitely buried!

The documentation could definitely do with a section on writing modules. And a section on coming from PyCall. I'll put it on my to-do list but feel free to contribute a PR.

@cjdoris cjdoris added the documentation Improvements or additions to documentation label Oct 4, 2021
@stevengj
Copy link
Member

I think this is covered in the manual now?

@cjdoris
Copy link
Collaborator

cjdoris commented Apr 20, 2022

Indeed it is.

@cjdoris cjdoris closed this as completed Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants