conan: conanfile.py self.run("./configure") doesn't work with mingw - msys on Windows

Hi everyone,

I’ve just noticed that, on Windows, when placing the command self.run("./configure") in a conanfile.py and running conan test_package in mingw/msys, the error “configure - unrecognised command” is produced. This is the case anyway when using a Windows command line and executing ./configure by hand, even when MinGW has been placed in the path. But ./configure does work on Windows when executed from msys.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 20 (10 by maintainers)

Most upvoted comments

Hi! I solved my case, but I done some steps:
first, I used tools.run_in_windows_bash to solve “./configure”, after that,
I got some new errors during make command, the cause was Windows environment variables, that use \ as separator, as result, all paths were stripped by bash. As solution, I replaced all \ by /. I tried to use tools.unix_path, but it didn’t work in such case and I didn’t investigate. The complete solution is that:

def _run_cmd(self, command):
    if self.settings.os == "Windows":
            tools.run_in_windows_bash(self, tools.unix_path(command))
    else:
        self.run(command)

def build(self):
    env_build = AutoToolsBuildEnvironment(self)
    env_build.fpic = True
    # Solve Windows path on MingW
    unix_environment = {}
    for key, value in env_build.vars.items():
        unix_environment[key] = value.replace("\\", "/")
    with tools.environment_append(unix_environment):
        with tools.chdir(self.release_name):
            self._run_cmd("./configure")
            self._run_cmd("make")

As final step, I used CONAN_BASH_PATH on AppVeyor job.
You can see the complete solution here: https://github.com/uilianries/conan-libusb/blob/release/1.0.21/conanfile.py

I found 2 non-trivial points, first, is to replace all path separator for Cygwin, maybe Conan could solve this point, but I did not find any smart way to made such magic. Second, CONAN_BASH_PATH is treated by Conan and is documented on docs, but it is used by conan-package-tools and is not referenced.

Regards.