[bug] package_folder not set in when calling `conan build`
See original GitHub issueEnvironment Details
- Linux Ubuntu 22.04.1
- Clang 14.0.6
- Conan 1.53.0:
- Python 3.10.6:
Steps to reproduce (Include if Applicable)
main.cpp
int main(){}
CMakeLists.txt
project(ProjectName)
add_executable(demo main.cpp)
install(TARGETS demo RUNTIME DESTINATION bin)
conanfile.py
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
required_conan_version = ">=1.35.0"
class Pkg(ConanFile):
name="Foo"
settings = "os", "compiler", "build_type", "arch"
def layout(self):
cmake_layout(self)
def generate(self):
tc = CMakeToolchain(self)
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
try:
print("package_folder is", cmake._conanfile.package_folder)
print("package_folder is", self.package_folder)
cmake.install()
except Exception:
import traceback
print(traceback.format_exc())
doIt.sh
export CXX=clang++
rm -f ./profile
conan profile new --detect ./profile
conan profile update settings.compiler.libcxx=libc++ ./profile
conan profile update settings.compiler.cppstd=20 ./profile
conan install --build missing -if build -pr ./profile .
conan build -if build .
Logs (Executed commands with output) (Include/Attach if Applicable)
$ ./doIt.sh
CC and CXX: clang, clang++
Found clang 14.0
clang>=8, using the major as version
Profile created with detected settings: /home/me/conan_issue/profile
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=clang
compiler.cppstd=20
compiler.libcxx=libc++
compiler.version=14
os=Linux
os_build=Linux
[options]
[build_requires]
[env]
conanfile.py (Foo/None): Installing package
Requirements
Packages
Installing (downloading, building) binaries...
conanfile.py (Foo/None): Generator txt created conanbuildinfo.txt
conanfile.py (Foo/None): Calling generate()
conanfile.py (Foo/None): WARN: Using the new toolchains and generators without specifying a build profile (e.g: -pr:b=default) is discouraged and might cause failures and unexpected behavior
conanfile.py (Foo/None): Preset 'release' added to CMakePresets.json. Invoke it manually using 'cmake --preset release'
conanfile.py (Foo/None): If your CMake version is not compatible with CMakePresets (<3.19) call cmake like: 'cmake <path> -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/home/me/conan_issue/build/generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release'
conanfile.py (Foo/None): WARN: Using the new toolchains and generators without specifying a build profile (e.g: -pr:b=default) is discouraged and might cause failures and unexpected behavior
conanfile.py (Foo/None): Aggregating env generators
conanfile.py (Foo/None): Generated conaninfo.txt
conanfile.py (Foo/None): Generated graphinfo
Using lockfile: '/home/me/conan_issue/build/conan.lock'
Using cached profile from lockfile
conanfile.py (Foo/None): Calling build()
conanfile.py (Foo/None): CMake command: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/me/conan_issue/build/generators/conan_toolchain.cmake" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/me/conan_issue/."
-- Using Conan toolchain: /home/me/conan_issue/build/generators/conan_toolchain.cmake
-- Conan toolchain: C++ Standard 20 with extensions OFF
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.22)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/me/conan_issue/build/Release
conanfile.py (Foo/None): CMake command: cmake --build "/home/me/conan_issue/build/Release" '--' '-j24'
Consolidate compiler generated dependencies of target demo
[100%] Built target demo
package_folder is None
package_folder is None
Traceback (most recent call last):
File "/home/me/conan_issue/conanfile.py", line 26, in build
cmake.install()
File "/home/me/.pyenv/versions/3.10.6/lib/python3.10/site-packages/conan/tools/cmake/cmake.py", line 133, in install
mkdir(self._conanfile, self._conanfile.package_folder)
File "/home/me/.pyenv/versions/3.10.6/lib/python3.10/site-packages/conan/tools/files/files.py", line 62, in mkdir
if os.path.exists(path):
File "/home/me/.pyenv/versions/3.10.6/lib/python3.10/genericpath.py", line 19, in exists
os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
Issue Analytics
- State:
- Created a year ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Package layout — conan 1.55.0 documentation
When we call conan create , this is a simplified description of what happens: ... and build folders (libraries and executables) to a...
Read more >Package development flow — conan 1.46.2 documentation
Using the package-folder argument (incompatible with the above 2), will not use the package() method, it will create an exact copy of the...
Read more >Methods — conan 1.44.1 documentation
This method copies files from build/source folder to the package folder ... no_copy_source is defined, every self.copy() is internally called twice: One ...
Read more >conan build — conan 1.36.0 documentation
If you are using a build helper, like CMake(), the –package-folder will be configured as the ... When specified, configure/build/install won't run unless ......
Read more >conan create — conan 1.55.0 documentation
Builds a binary package for a recipe (conanfile.py). Uses the specified configuration in a profile or in -s settings, -o options, etc.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, the only argument that remains in Conan 2.0 is
-of OUTPUT_FOLDER, --output-folder OUTPUT_FOLDER
.Note that also, in general, the need for
conan build
should be less, as the flowconan install
+cmake ....
using directly cmake would be the recommended way for developers in many cases. Once you callcmake
yourself, you have full control on that.Hi @memsharded,
I believe I have encountered a related issue in trying to port the openssl recipe to Conan 2.0. In this instance openssl uses a baroque version of Configure (menagerie of Perl scripts). The issue is that the Configure --prefix option is needed prior to the build method being invoked. At that time self.package_folder is, as you note above, not set correctly for the ultimate installation into the Conan cache during the export-pkg phase. I’ve worked around this by passing “/” as the --prefix option and then passing self.packge_folder as the value of DESTDIR as a Makefile command line option, but this feels somewhat clumsy/fragile. While it worked on Linux, It exposed a secondary issue on Windows where Configure translates “/” to "", which nmake then misinterprets as an EOL continuation character. Thus, I am wondering if you have any suggestions or whether it would not be possible for Conan 2 to compute and set self.package_folder prior to the build method being invoked? Thanks