conan-io / conan-package-tools

Conan Package Tools. Helps with massive package creation and CI integration (Travis CI, Appveyor...)
MIT License
166 stars 71 forks source link

Relative profile path handling problem #225

Open db4 opened 6 years ago

db4 commented 6 years ago

I expected that according to conan docs builder.run("./my_profile) would search for my_profile in the current directory. That's not the case:

 >> **************************************************

 >> Using specified default base profile: ./my_profile

 >> **************************************************
Traceback (most recent call last):
  File "build.py", line 13, in <module>
    builder.run("./my_profile")
  File "C:\Python36\lib\site-packages\cpt\packager.py", line 328, in run
    self.run_builds(base_profile_name=base_profile_name)
  File "C:\Python36\lib\site-packages\cpt\packager.py", line 392, in run_builds
    base_profile_name)
  File "C:\Python36\lib\site-packages\cpt\profiles.py", line 14, in get_profiles
    base_profile_text = tools.load(base_profile_path)
  File "C:\Python36\lib\site-packages\conans\util\files.py", line 166, in load
    with open(path, 'rb') as handle:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\dbely\\.conan\\profiles\\./my_profile'

Should it be considered as a bug?

BTW, is there any other way to pass a package option to the builder? python build.py -o package:option=value ... doesn't work as well as builder.run(args="-o package:option=value ...")

lasote commented 6 years ago

Yes. Looks like a bug. About passing options, no, you have to iterate/modify or create your builds with the wanted options:

builder = ConanMultiPackager(username="myusername")
builder.add(settings={"arch": "x86", "build_type": "Debug"},
                    options={}, env_vars={}, build_requires={})
lasote commented 6 years ago

I've been checking it and it is not really a bug, currently it admits only a profile name (not a path) that has to be in the profiles folder of the local cache. It will require some time to make it work.

solvingj commented 6 years ago

While it was slightly inconvenient for me to get profiles and CPT figured out in an enterprise environment, I found it crucial to minimize the mingling between host OS and the docker container. Still, it does seem sub-optimal to have the container profiles come directly from the hostOS. I don't have a suggestion for how it SHOULD work though.

The strategy that ended up working well for us was the following, but this doesn't feel like a "permanent" solution.

By adding the below to build.py, the docker containers get all the profiles from git each time they run.

    os.environ["CONAN_DOCKER_ENTRY_SCRIPT"] = ("conan config install " 
                                               "http://our_scm_server"
                                               "/our_git_repository_for_profiles"
                                               "/archive?format=zip")
solvingj commented 6 years ago

Ok, now I also want to be able to pass: ./my_relative_profile

As a workaround in our CI, since it's always windows, i'm doing %CD%/my_relative_profile