docs icon indicating copy to clipboard operation
docs copied to clipboard

[bug] self.build_folder error

Open silajim opened this issue 3 years ago • 5 comments

Environment Details (include every applicable attribute)

  • Operating System+version: Ubuntu 18.04
  • Compiler+version:
  • Conan version: 1.49 and 1.48.2
  • Python version: 3.6

Steps to reproduce (Include if Applicable)

Logs (Executed commands with output) (Include/Attach if Applicable)

trying to set self.build_folder in the build method of conanfile fails, Python says, Invalid attribute. self.build_folder = os.path.join(self.build_folder,build_type) fails on 1.49 and 1.48.2 but works on 1.42.2

silajim avatar Jun 08 '22 17:06 silajim

Hi @silajim

I am afraid this is not a bug. self.build_folder has always been a read-only property or attribute, it was not documented that it was possible to set self.build_folder in the build() method (or elsewhere), and overwriting the Conan defined value can lead to undefined behavior.

The good news is that now we have defined a structured way to define this, which is the layout() method, and defining self.folders.build=xxx is possible. There are also predefined layouts like cmake_layout() that defines very useful common CMake layout, and can work very nicely with the latest improvements including CMakePresets integration. I recommend having a look to the docs for latest Conan version for this.

memsharded avatar Jun 08 '22 21:06 memsharded

Oh I see, so the bug was actually that we could write into it

silajim avatar Jun 08 '22 21:06 silajim

Yes, it was not sufficiently protected to avoid writing on it. The truth is that in general we don't do an overly "defensive" programming style, trying to keep the codebase relatively lean, but sometimes this happens. Overtime we are maturing and avoiding these, while providing better and more explicit mechanisms. As a rule of thumb, if you cannot find it explicitly in the docs, it is not supported.

memsharded avatar Jun 08 '22 21:06 memsharded

Gotcha, maybe this should be documented to avoid extra confiusion

silajim avatar Jun 09 '22 17:06 silajim

Moved to "docs" repo

memsharded avatar Jun 10 '22 08:06 memsharded