Skip to content

Windows-style paths #298

@ruairimoran

Description

@ruairimoran

Describe the bug

Backslash messes up things when local open is used:

[INFO] Building optimizer
error: failed to parse manifest at `D:\PycharmProjects\OpEn_Fix_107\open-codegen\opengen\my_optimizers\rosenbrock\Cargo.toml`
Caused by:
  could not parse input as TOML
Caused by:
  TOML parse error at line 19, column 35
     |
  19 | optimization_engine = {path = "D:\PycharmProjects\OpEn_Fix_107\"}
     |                                   ^
  Unexpected `P`
  While parsing escape sequence
  While parsing a Basic String
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files\JetBrains\PyCharm 2021.2.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 198, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm 2021.2.3\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:/PycharmProjects/OpEn_Fix_107/open-codegen/opengen/main.py", line 47, in <module>
    builder.build()
  File "D:\PycharmProjects\OpEn_Fix_107\venv\lib\site-packages\opengen\builder\optimizer_builder.py", line 804, in build
    self.__build_optimizer()             # build overall project
  File "D:\PycharmProjects\OpEn_Fix_107\venv\lib\site-packages\opengen\builder\optimizer_builder.py", line 570, in __build_optimizer
    raise Exception('Rust build failed')
Exception: Rust build failed

The issue has been analysed to be due to the function get_open_local_absolute_path() in main.py providing an address path incompatible with windows.

To Reproduce

Use with_open_version(local_path=...) on Windows. We need get_open_local_absolute_path() to return paths with forward slashes both on Windows and Linux/MacOS.

System information:

  • Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpythonissue related to pythonwindowsWindows

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions