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

How to import module from .so file inside egg file without using an absolute file path? #63

Closed
Guangyi-Z opened this issue Apr 7, 2017 · 14 comments
Labels

Comments

@Guangyi-Z
Copy link
Contributor

Guangyi-Z commented Apr 7, 2017

I posted the details on SO.
Thanks all.

http://stackoverflow.com/questions/43274153/python-how-to-import-module-from-so-file-from-egg-file-without-using-an-absol

@pombredanne
Copy link
Collaborator

@janfan why do you use an Egg? eggs are over and were never tested here. You should use a wheel IMHO

@pombredanne
Copy link
Collaborator

That said, could you give a try to add zip_safe=False, in here

?
and respin your egg build?

@Guangyi-Z
Copy link
Contributor Author

Ok, I will try to figure out how wheel can fit into my job. I will return here soon. Thank for your advice.

@pombredanne
Copy link
Collaborator

pombredanne commented Apr 7, 2017

@janfan FWIW, it would be best to have a self standing ticket rather than something mostly on SO and a ticket here ;) for sanity

@Guangyi-Z
Copy link
Contributor Author

@pombredanne Hi there, I am sorry to say that zip_safe=False did not work.

@Guangyi-Z
Copy link
Contributor Author

@pombredanne I'm back. Now I review the knowledge about wheel, and it's just a distribution instead of a portable runtime, that is, you can't import from a wheel, which is what I need when I use this package on Spark cluster.

@pombredanne
Copy link
Collaborator

eggs are on the way out and supporting them is likely problematic, especially eggs with native code like here.
Perhaps you could instead explain what you are trying to achieve in more details? It could be that there are other solutions.

@Guangyi-Z
Copy link
Contributor Author

@pombredanne If it is like what you said, I am going to turn to other ways. Thanks for your help.

@pombredanne
Copy link
Collaborator

@janfan I would be happy to help, but Sparks doc seem to mention that eggs with native are not something that works with their way of importing. And they are working on supporting wheels.

@pombredanne
Copy link
Collaborator

@janfan note that you could also just unzip a wheel (or an egg) and put the .so in your path or PYTHONPATH. Then doing import ahocorasick works just fine.

@pombredanne
Copy link
Collaborator

because all of it is just a single .so ;)

@pombredanne
Copy link
Collaborator

@janfan did using the .so worked for you?

@Guangyi-Z
Copy link
Contributor Author

Guangyi-Z commented Apr 23, 2017

@pombredanne No. I modified the env PYTHON_EGG_CACHE so that the .so can be extracted and loaded. However, there is another subsequent problem- the system can not find the libpython.so.10.

I use it for PySpark tasks, and it is difficult to figure the underlying problems. It has something to do with the Spark cluster.

At last I pushed my operator to pip install pyahocorasick on every node in Spark cluster and solved it.

@pombredanne
Copy link
Collaborator

Excellent! so you can close this ticket then?

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

3 participants