Skip to content

Cross-compilation with Python bindings: PYO3_CROSS_LIB_DIR not set #369

Description

@alphaville

Describe the bug

When compiling with

.with_target_system("rpi").with_build_python_bindings()

the following error is produced

Must provide PYO3_CROSS_LIB_DIR environment variable when cross-compiling

To Reproduce

Complete example

import sys
import os
import casadi.casadi as cs
import opengen as og

optimizers_dir = "my_optimizers"
optimizer_name = "rosenbrock"

def get_open_local_absolute_path():
    cwd = os.getcwd()
    return cwd.split('open-codegen')[0]

nu, np = 5, 2
u = cs.SX.sym("u", nu)  # decision variable (nu = 5)
p = cs.SX.sym("p", 2)  # parameter (np = 2)
phi = og.functions.rosenbrock(u, p) + 1500*cs.sum1(u)

# c_f1 = cs.vertcat(p[0] * u[0] - u[1], p[1]*u[2] - u[3] + 0.1)
c_f2 = cs.vertcat(0.2 + 1.5 * u[0] - u[1], u[2] - u[3] - 0.1)

bounds = og.constraints.Ball2(None, 1.5)
problem = og.builder.Problem(u, p, phi) \
    .with_penalty_constraints(c_f2)\
    .with_constraints(bounds)
meta = og.config.OptimizerMeta()\
    .with_optimizer_name(optimizer_name)
build_config = og.config.BuildConfiguration() \
    .with_build_directory(optimizers_dir) \
    .with_build_mode(og.config.BuildConfiguration.DEBUG_MODE) \
    .with_open_version(local_path=get_open_local_absolute_path()) \
    .with_tcp_interface_config().with_target_system("rpi").with_build_python_bindings()
solver_cfg = og.config.SolverConfiguration() \
    .with_preconditioning(True)

builder = og.builder.OpEnOptimizerBuilder(problem,
                                          meta,
                                          build_config,
                                          solver_cfg)
builder.build()

System information

Tested on Linux and MacOS

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

codegenCode generationpythonissue related to pythonraspberry piRaspberry Pi target

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions