conan
conan copied to clipboard
[question] Using conan 2 for exporting a pre-built package not working
What is your question?
Hello, I'm attempting to exporting an ADK as a conan package using conanfile.py and two commands.
Steps:
- Move to ADK directory and create a
buildfolder, and move into the folder - Run the command
conan install -pr macos .. - Run the command
conan export-pkg .. archicad_adk/27.3001@
This leads me to an error, I get an empty package, this kinda of error happened some times ago but sadly I don't remember how I solved it. Could you please help me with this?
Previously when I managed to create the ADK I was using legacy conan version 1.62.0, now I've upgrade it to 2.2.2
conanfile.py (update it)
from conan import ConanFile
from conan.tools.files import copy
from conan.tools.cmake import CMake
class ArchicadAdkConan(ConanFile):
name = "archicad_adk"
license = "non-free"
homepage = "https://archicadapi.graphisoft.com/downloads/api-development-kit"
url = "https://app.asana.com/0/1199938359399354/board" # for issues
description = """With the help of this tool you can develop Add-Ons to extend Archicad’s
standard functionalities. Also this tool enables you to create I/O interfaces for
converting Archicad files to different formats."""
topics = ("CAD", "sdk", "plugin", "addon")
settings = "os", "arch"
def package(self):
src_pattern = "{}/"
if "Macos" == self.settings.os:
src_pattern = "/Applications/GRAPHISOFT ARCHICAD API DevKit {}/Support/"
elif "Windows" == self.settings.os:
src_pattern = "C:/Program Files/GRAPHISOFT/API Development Kit {}/Support/"
src = src_pattern.format(self.version)
copy(self, "license.txt", src=src, dst="/")
copy(self, "**/ResConv.exe", src=src, dst="bin", keep_path=False)
copy(self, "**/ResConv", src=src, dst="bin", keep_path=False)
copy(self, "*.lib", src=src, dst="lib", keep_path=False)
copy(self, "*.dll", src=src, dst="bin", keep_path=False)
copy(self, "*.so", src=src, dst="lib", keep_path=False)
copy(self, "Frameworks/*.dylib", src=src,
dst="bin/Support", keep_path=False)
copy(self, "Tools/*.dylib", src=src,
dst="bin/Support", keep_path=False)
copy(self, "*.a", src=src, dst="lib", keep_path=False)
copy(self, "Frameworks/*.framework/*", src=src, dst="lib")
include_archicad = "include/Archicad" # for SonarCloud
# main headers
copy(self, "*.h", src=src + "Inc", dst=include_archicad)
copy(self, "*.hpp", src=src + "Inc", dst=include_archicad)
copy(self, "*.ico", src=src + "Inc", dst=include_archicad)
copy(self, "*.icns", src=src + "Inc", dst=include_archicad)
# module headers
copy(self, "*.h", src=src + "Modules",
dst=include_archicad, keep_path=True)
copy(self, "*.hpp", src=src + "Modules",
dst=include_archicad, keep_path=True)
The output that I get:
(pythonConanEnv) manuel@MacBook-Pro-di-Manuel build % sudo conan export-pkg .. archicad_adk/27.3001@ -f
Password:
Exporting package recipe
archicad_adk/27.3001: The stored package has not changed
archicad_adk/27.3001: Exported revision: 858fc649a205400c96639345223e865a
archicad_adk/27.3001: Forced build from source
Packaging to 46f53f156846659bf39ad6675fa0ee8156e859fe
archicad_adk/27.3001: Generating the package
archicad_adk/27.3001: Package folder /Users/manuel/.conan/data/archicad_adk/27.3001/_/_/package/46f53f156846659bf39ad6675fa0ee8156e859fe
archicad_adk/27.3001: Calling package()
archicad_adk/27.3001: Copied 1 file: ResConv
archicad_adk/27.3001: Copied 1 '.dylib' file: libXL.dylib
archicad_adk/27.3001: Copied 40 '.dylib' files
archicad_adk/27.3001: Copied 1 '.a' file: libACAP_STAT.a
archicad_adk/27.3001: Copied 453 files
archicad_adk/27.3001: Copied 152 '.plist' files
archicad_adk/27.3001: Copied 1156 '.tif' files
archicad_adk/27.3001: Copied 528 '.rsrd' files
archicad_adk/27.3001: Copied 15 '.strings' files
archicad_adk/27.3001: Copied 1 '.metallib' file: default.metallib
archicad_adk/27.3001: Copied 1 '.jpg' file: transitionmask.jpg
archicad_adk/27.3001: Copied 10 '.png' files
archicad_adk/27.3001: Copied 1 '.tiff' file: restrictedshine.tiff
archicad_adk/27.3001: Copied 35 '.h' files
archicad_adk/27.3001: Copied 8 '.hpp' files
archicad_adk/27.3001: Copied 1 '.icns' file: ArchiCADPlugin.icns
archicad_adk/27.3001: Copied 164 '.h' files
archicad_adk/27.3001: Copied 1956 '.hpp' files
archicad_adk/27.3001 package(): WARN: No files in this package!
archicad_adk/27.3001: Package '46f53f156846659bf39ad6675fa0ee8156e859fe' created
archicad_adk/27.3001: Created package revision a4fc02a1e79613c182918ede17eae4a4
I've to use sudo otherwise it complains me with privilege errors, as you can see there is a warning "No files in this package", I don't get why this happens.
include_archicad = "include/Archicad" # for SonarCloud
This is incorrrect.
The dst path must be absolute, please check the https://docs.conan.io/2/reference/conanfile/methods/package.html docs
Yeah I saw, but this also applies to all the previous copy calls right?
copy(self, "license.txt", src=src, dst="/")
copy(self, "**/ResConv.exe", src=src, dst="bin", keep_path=False)
copy(self, "**/ResConv", src=src, dst="bin", keep_path=False)
copy(self, "*.lib", src=src, dst="lib", keep_path=False)
copy(self, "*.dll", src=src, dst="bin", keep_path=False)
copy(self, "*.so", src=src, dst="lib", keep_path=False)
copy(self, "Frameworks/*.dylib", src=src,
dst="bin/Support", keep_path=False)
copy(self, "Tools/*.dylib", src=src,
dst="bin/Support", keep_path=False)
copy(self, "*.a", src=src, dst="lib", keep_path=False)
copy(self, "Frameworks/*.framework/*", src=src, dst="lib")
Yes, all of them must be absolute.
I update it as the following:
class ArchicadAdkConan(ConanFile):
name = "archicad_adk"
license = "non-free"
homepage = "https://archicadapi.graphisoft.com/downloads/api-development-kit"
url = "https://app.asana.com/0/1199938359399354/board" # for issues
description = """With the help of this tool you can develop Add-Ons to extend Archicad’s
standard functionalities. Also this tool enables you to create I/O interfaces for
converting Archicad files to different formats."""
topics = ("CAD", "sdk", "plugin", "addon")
settings = "os", "arch"
def package(self):
src_pattern = "{}/"
if "Macos" == self.settings.os:
src_pattern = "/Applications/GRAPHISOFT ARCHICAD API DevKit {}/Support/"
elif "Windows" == self.settings.os:
src_pattern = "C:/Program Files/GRAPHISOFT/API Development Kit {}/Support/"
src = src_pattern.format(self.version)
dst_bin = self.package_folder + "bin"
dst_bin_support = self.package_folder + "bin/Support"
dst_lib = self.package_folder + "lib"
dst_include_archicad = self.package_folder + "include/Archicad" # for SonarCloud
copy(self, "license.txt", src=src, dst=self.package_folder)
copy(self, "**/ResConv.exe", src=src, dst=dst_bin, keep_path=False)
copy(self, "**/ResConv", src=src, dst=dst_bin, keep_path=False)
copy(self, "*.lib", src=src, dst=dst_lib, keep_path=False)
copy(self, "*.dll", src=src, dst=dst_bin, keep_path=False)
copy(self, "*.so", src=src, dst=dst_lib, keep_path=False)
copy(self, "Frameworks/*.dylib", src=src,
dst=dst_bin_support, keep_path=False)
copy(self, "Tools/*.dylib", src=src,
dst=dst_bin_support, keep_path=False)
copy(self, "*.a", src=src, dst=dst_lib, keep_path=False)
copy(self, "Frameworks/*.framework/*", src=src, dst=dst_lib)
# main headers
copy(self, "*.h", src=src + "Inc", dst=dst_include_archicad)
copy(self, "*.hpp", src=src + "Inc", dst=dst_include_archicad)
copy(self, "*.ico", src=src + "Inc", dst=dst_include_archicad)
copy(self, "*.icns", src=src + "Inc", dst=dst_include_archicad)
# module headers
copy(self, "*.h", src=src + "Modules",
dst=dst_include_archicad, keep_path=True)
copy(self, "*.hpp", src=src + "Modules",
dst=dst_include_archicad, keep_path=True)
But I'm still getting the same error.
One thing that I forget to show you was the output after the conan install command:
(pythonConanEnv) manuel@MacBook-Pro-di-Manuel build % conan install .. -pr macos
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=MinSizeRel
compiler=apple-clang
compiler.cppstd=17
compiler.libcxx=libc++
compiler.version=14.0
os=Macos
os.version=10.13
os_build=Macos
archicad_adk:os.version=None
cmake:build_type=Release
ninja:build_type=Release
openssl:build_type=Release
[options]
[build_requires]
[env]
MACOSX_DEPLOYMENT_TARGET=10.13
conanfile.py (archicad_adk/None): Installing package
Requirements
Packages
Cross-build from 'Macos:armv8' to 'Macos:x86_64'
Installing (downloading, building) binaries...
conanfile.py (archicad_adk/None): Generator txt created conanbuildinfo.txt
conanfile.py (archicad_adk/None): Aggregating env generators
conanfile.py (archicad_adk/None): Generated conaninfo.txt
conanfile.py (archicad_adk/None): Generated graphinfo
dst_bin = self.package_folder + "bin"
This might be incorrect, this is not the right way to concatenate paths, better use os.path.join()
conan install .. -pr macos
conan install won't call package(), I guess you want to use export-pkg?
I use them both, and sequentially, I tought that it may need the profile for doing this operation.
Now the export-pkg seems to work.
(pythonConanEnv) manuel@MacBook-Pro-di-Manuel build % sudo conan export-pkg .. archicad_adk/27.3001@ -f
Password:
+Exporting package recipe
archicad_adk/27.3001: A new conanfile.py version was exported
archicad_adk/27.3001: Folder: /Users/manuel/.conan/data/archicad_adk/27.3001/_/_/export
archicad_adk/27.3001: Exported revision: afeb66b1ef109edb9dd8cfa50526a227
archicad_adk/27.3001: Forced build from source
Packaging to 46f53f156846659bf39ad6675fa0ee8156e859fe
archicad_adk/27.3001: Generating the package
archicad_adk/27.3001: Package folder /Users/manuel/.conan/data/archicad_adk/27.3001/_/_/package/46f53f156846659bf39ad6675fa0ee8156e859fe
archicad_adk/27.3001: Calling package()
archicad_adk/27.3001: Copied 1 file: ResConv
archicad_adk/27.3001: Copied 1 '.dylib' file: libXL.dylib
archicad_adk/27.3001: Copied 40 '.dylib' files
archicad_adk/27.3001: Copied 1 '.a' file: libACAP_STAT.a
archicad_adk/27.3001: Copied 453 files
archicad_adk/27.3001: Copied 152 '.plist' files
archicad_adk/27.3001: Copied 1156 '.tif' files
archicad_adk/27.3001: Copied 528 '.rsrd' files
archicad_adk/27.3001: Copied 15 '.strings' files
archicad_adk/27.3001: Copied 1 '.metallib' file: default.metallib
archicad_adk/27.3001: Copied 1 '.jpg' file: transitionmask.jpg
archicad_adk/27.3001: Copied 10 '.png' files
archicad_adk/27.3001: Copied 1 '.tiff' file: restrictedshine.tiff
archicad_adk/27.3001: Copied 35 '.h' files
archicad_adk/27.3001: Copied 8 '.hpp' files
archicad_adk/27.3001: Copied 1 '.icns' file: ArchiCADPlugin.icns
archicad_adk/27.3001: Copied 164 '.h' files
archicad_adk/27.3001: Copied 1956 '.hpp' files
archicad_adk/27.3001 package(): Packaged 454 files
archicad_adk/27.3001 package(): Packaged 41 '.dylib' files
archicad_adk/27.3001 package(): Packaged 199 '.h' files
archicad_adk/27.3001 package(): Packaged 1964 '.hpp' files
archicad_adk/27.3001 package(): Packaged 1 '.icns' file: ArchiCADPlugin.icns
archicad_adk/27.3001 package(): Packaged 1 '.a' file: libACAP_STAT.a
archicad_adk/27.3001 package(): Packaged 152 '.plist' files
archicad_adk/27.3001 package(): Packaged 1156 '.tif' files
archicad_adk/27.3001 package(): Packaged 528 '.rsrd' files
archicad_adk/27.3001 package(): Packaged 15 '.strings' files
archicad_adk/27.3001 package(): Packaged 1 '.metallib' file: default.metallib
archicad_adk/27.3001 package(): Packaged 1 '.jpg' file: transitionmask.jpg
archicad_adk/27.3001 package(): Packaged 10 '.png' files
archicad_adk/27.3001 package(): Packaged 1 '.tiff' file: restrictedshine.tiff
archicad_adk/27.3001: Package '46f53f156846659bf39ad6675fa0ee8156e859fe' created
archicad_adk/27.3001: Created package revision 2f7a4ac6e1d30453996d728fe468b652
I realised I made a mistake, I was using the wrong virtual environment, I was using conan legacy instead of 2.2.2
I get an error with the correct environment:
(pythonConanEnv2) manuel@MacBook-Pro-di-Manuel build % conan export-pkg .. archicad_adk/27.3001@
usage: conan export-pkg [-h] [-v [V]] [-cc CORE_CONF] [-f FORMAT] [-of OUTPUT_FOLDER] [--build-require] [-tf TEST_FOLDER] [-sb] [-r REMOTE | -nr]
[--name NAME] [--version VERSION] [--user USER] [--channel CHANNEL] [-l LOCKFILE] [--lockfile-partial]
[--lockfile-out LOCKFILE_OUT] [--lockfile-clean] [--lockfile-overrides LOCKFILE_OVERRIDES] [-pr PROFILE] [-pr:b PROFILE_BUILD]
[-pr:h PROFILE_HOST] [-pr:a PROFILE_ALL] [-o OPTIONS] [-o:b OPTIONS_BUILD] [-o:h OPTIONS_HOST] [-o:a OPTIONS_ALL] [-s SETTINGS]
[-s:b SETTINGS_BUILD] [-s:h SETTINGS_HOST] [-s:a SETTINGS_ALL] [-c CONF] [-c:b CONF_BUILD] [-c:h CONF_HOST] [-c:a CONF_ALL]
path
conan export-pkg: error: unrecognized arguments: archicad_adk/27.3001@
ERROR: Exiting with code: 2
Even trying the most basic command for exporting I get the following:
(pythonConanEnv2) manuel@MacBook-Pro-di-Manuel Graphisoft Archicad API DevKit 27.3001 % conan export-pkg archicad_adk/27.3001@
ERROR: Conanfile not found at /Applications/Graphisoft Archicad API DevKit 27.3001/archicad_adk/27.3001@
I see that Conan2 needs name and version arguments to be explicitely declared in the command
conan export-pkg . --name archicad_adk --version 27.3001 generates a package.
conan export-pkg . --name archicad_adk --version 27.3001 generates a package.
They can also be declared as name = "myname" and version = "myversion" class attributes in the conanfile.py recipe
conan export-pkg . --name archicad_adk --version 27.3001 generates a package.
They can also be declared as
name = "myname"andversion = "myversion"class attributes in theconanfile.pyrecipe
I saw it, but I need them to be in command line (thanks :)).
This is from the build workflow I'm currently using.
*********************************************************
Recipe 'archicad_adk/27.3001' seems broken.
It is possible that this recipe is not Conan 2.0 ready
If the recipe comes from ConanCenter, report it at https://github.com/conan-io/conan-center-index/issues
If it is your recipe, check if it is updated to 2.0
*********************************************************
ERROR: Package 'archicad_adk/27.3001' not resolved: archicad_adk/27.3001: Cannot load recipe.
Error loading conanfile at '/Users/runner/.conan2/p/archie66f95f960a6a/e/conanfile.py': Unable to load conanfile in /Users/runner/.conan2/p/archie66f95f960a6a/e/conanfile.py
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/Users/runner/.conan2/p/archie66f95f960a6a/e/conanfile.py", line 28, in <module>
from conans import ConanFile, CMake, tools
ImportError: cannot import name 'ConanFile' from 'conans' (/Users/runner/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/conans/__init__.py)
.
Error: Process completed with exit code 1.
from conans import ConanFile, CMake, tools
This is from legacy Conan 1.X, not supported anymore in Conan 2, please check the migration guide: https://docs.conan.io/1/migrating_to_2.0/recipes.html#python-import-statements
Maybe I get this error because I've to update the caching key (GH wf), for some reasons seems it is fetching from the old artifactory remote, even if I've changed the remote.json content to make it pointing to the new remote.
Edit: I realised I didn't push that change on the repository, my bad.
Marking this as staled, if there are any further question, please provide full updated details about it. If not, this ticket will be closed soon.