Allow third party Zig modules#500
Conversation
This commit adds support to use external Zig libraries in Ziggy Pydust by passing a list a of imports to PythonModuleOptions and calling addImport for each module in the lib and libtest.
|
I open this PR as a draft because I am getting this error when trying to use Ziggy Pydust with these modifications, take a look at the Zig error message: And I do not know how to fix that properly, maybe I forgot to add the lib somewhere? Or is it just some Zig detail I let pass (given that I am not very good with Zig)? I would appreciate some help, and would love to help implement this feature. The project I tried to build and got the error above is this one: https://github.com/ivansantiagojr/mdz/tree/using-fork-ziggy-pydust |
|
To register here (and possibly get help from the community), the compilation error described above only happens in the |
|
Workaround: I noticed that in the generated How could I make the project get this file from the installed Ziggy Pydust instead of my current project? Any ideas @jburgy @robert3005 |
|
@ivansantiagojr your issue is likely related to this discord thread (see this minimal repro if you can't access the discord thread). Note that I raised ziglang/translate-c#47 and found a work-around. Reading this reply (as well as ziglang/zig#24497), I understand now that zig has two
Let me know what you prefer and how I can help you with it. |
|
Oh, I didn't know there was a discord server. Thanks for letting me know and for the tips! I will investigate a little more and try those alternatives you listed locally, probably another PR should be open to solve that. |
|
I think if we have #526 we do not need this? |
@robert3005, we'll need both, actually. This PR allows us to use third party modules, and #526 only reverts the strategy to use C modules. In order for the code of this branch to work, we need #526 to be merged first. Sorry for not making it clearer earlier! |
|
I'm using the following workaround until the permanent fix is merged. |
# Changes Use `@cImport` because translate-c does not work with files outside of the source directory, and `pydust.build.zig` depends on it to work. The original changes were added in the commit 9fb5721, and that also removed `usingnamespace`, so I was careful I did not re-add those. # Notes Discussions about this happened in the PR #500, where I got stuck with the usage of translate-c, so @jburgy listed 2 ways to fix that in [this comment ](#500 (comment)). I decided to revert the change and use `@cImport` again because [ziglang/translate-c](https://github.com/ziglang/translate-c) does not have tagged releases and it targes latest Zig, even when unstable. It is worth keeping an eye on this library, though, we might want to use that in the future Zig releases.
|
@ivansantiagojr I have been noodling around with converting |
@jburgy I definitely think that using translate C on build.zig is better. However, this branch is already working. I managed to get a fix when reverting to |
This PR makes a suggestion of feature to allow Ziggy Pydust users to add third party modules.
To achieve this, I add a list of imports to
PythonModuleOptionsand then iterated this list callinglib.addImportfor each module. The same was made forlibtest.I also added basic docs giving an example of how to use that, so feel free to consult it and analyze if this suggestion is a good way to address the issue ziglang/zig#474 .