box-key / cyzil

A tool for fast and in-depth analysis of sequence generation model in Cython
Apache License 2.0
1 stars 0 forks source link

Cython Compilation #2

Closed box-key closed 4 years ago

box-key commented 4 years ago

When I run python setup.py develop or python setup.py build_ext --inplace, it generates .pyd files under the root directory. So, when I test the code, I have to import individual models rather than importing a whole package.

https://github.com/box-key/Cyzil/blob/2f7a4feabd0a4613433f8fa7528c5720ba8575f7/cyzil_test.py#L11-L12

How can I group all modules into one package so users can call api like from cyzil import bleu? Or when I list this package on PyPi, users can use a package like import cyzil?

kylebgorman commented 4 years ago

You can create a third module (probably a "package" in Python packaging parlance) which just contains an __init__.py which start-imports the other two modules and does nothing else. I have something akin to this in both perceptronix and pynini, though they just import from one extension rather than two.

On Wed, Apr 8, 2020 at 6:18 AM Kei Nemoto notifications@github.com wrote:

When I run python setup.py develop or python setup.py build_ext --inplace, it generates .pyd files under the root directory. So, when I test the code, I have to import individual models rather than importing a whole package like the following.

https://github.com/box-key/Cyzil/blob/2f7a4feabd0a4613433f8fa7528c5720ba8575f7/cyzil_test.py#L11-L12

How can I group all modules into one package so users can call api like from cyzil import bleu? Or when I list this package in PyPi, users can use package like the above?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/box-key/Cyzil/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABG4OI4FHP5FFBZOBHU4GDRLORBZANCNFSM4MDPAQZA .

box-key commented 4 years ago

Yes, this way seems to work well. Users can import package and call apis as follows.

https://github.com/box-key/Cyzil/blob/77262aff05743b4b0ab3fac94c7af5bc3cd802a1/cyzil_test.py#L11

https://github.com/box-key/Cyzil/blob/77262aff05743b4b0ab3fac94c7af5bc3cd802a1/cyzil_test.py#L25

Thank you for your advice.