Skip to content

[QUESTION] Is it possible to use external Zig dependencies? #474

@ivansantiagojr

Description

@ivansantiagojr

How can I use external Zig dependencies in Ziggy Pydust projects?

For example, if I have a build.zig like in the docs:

const std = @import("std");
const py = @import("./pydust.build.zig");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    // Each Python module consists of a library_step and a test_step
    const module = pydust.addPythonModule(.{
        .name = "example.hello",
        .root_source_file = .{ .path = "example/hello.zig" },
        .target = target,
        .optimize = optimize,
    });
    module.library_step.addModule(..., ...);
    module.test_step.addModule(..., ...);
}

And I dowloaded a Zig library with:

zig fetch --save git+https://github.com/zigimg/zigimg.git

where would the following setup go in my build.zig?

const zigimg_dependency = b.dependency("zigimg", .{
    .target = target,
    .optimize = optimize,
});

exe.root_module.addImport("zigimg", zigimg_dependency.module("zigimg"));

I see that in the example we have module.library_step.addModule(..., ...);, but it does not seem like this still exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions