conan icon indicating copy to clipboard operation
conan copied to clipboard

[question] installing a conanfile.py for exporting a package

Open manuelpagliuca opened this issue 1 year ago • 5 comments

What is your question?

Hello, I'm trying to build an ADK with conan, but I'm getting some troubles.

I'm using conanfile.py for doing that, and I'm executing inside a folder called build, once I launch the command conan install -v -pr macos .. it basically answer me with this error:

ERROR: Manifest folder does not exist: /Applications/Graphisoft Archicad API DevKit 27.3001/build/.conan_manifests

This actually happens only if I use the flag -v, otherwise it would look like everything was working fine.

The main problem is that it should copy some files inside this build folder (I attached the conanfile.py that shows the passages), but this doesn't happen because the build folder contains only 4 small files (conan.lock, conanbuildinfo.txt, conaninfo.txt, graph_info.json) which are almost empty.

conanfile.py

# Usage:
# archicad_adk/build$ conan install -pr <windows|macos> ..
# archicad_adk/build$ conan export-pkg [--force] .. archicad_adk/24.3009@

#WARNING: The JSON module has wrong include paths. 
#The module is linked however so you can change every failing include from #include "JSON/x.h" to #include "x.h" to make it work.
#Alternatively it may be possible to set an additional include path but this is yet to be done.

#Note: For some reason building the package on macOS doesn't work with a warning that no files were found.
#Copy by hand what package() would do otherwise

# On MacOS: remove quarantine attributes
# cd /Applications/GRAPHISOFT ARCHICAD API DevKit 24.3009/Support/Tools/OSX
# sudo xattr -d com.apple.quarantine ResConv Support/*

# MD5 hashes:
# 190911.v2019Release.3006.FULL.FIN.WIN64.DevKitAPI.tar.gz 369832331047fbf9a2976cb2ce7df759
# 200619.v2020Release.3009.FULL.FIN.WIN64.DevKitAPI.tar.gz 6cd749c0292d37bd6025200dfdcf3efb
# GRAPHISOFT ARCHICAD API DevKit 23.3006.dmg 2b55eea58387a29af4f14551796c9d34
# GRAPHISOFT ARCHICAD API DevKit 24.3009.dmg da11013aa347f56813509e044168eb11

#SHA-256 hashes:
# 210519.v2021Release.3002.FULL.FIN.WIN64.DevKitAPI.tar.gz E2366A58EE2A29AA41C3E28AB7E9C3CAAC83ECC93E25FFD4D62708134764CC42
# 220529.v2022Release.3000.FULL.FIN.WIN64.DevKitAPI.tar.gz F722C5B76ABD0B611FA77F6E8E383997EEEA4D7F50718A53BFED8724ACA7C716
# 210709.v2021Release.3006.FULL.FIN.MAC64.DevKitAPI.tar 3223DD5D2F713BCB5937B84049C28ABF1F482512EA1D55B83DE049A6E3BA90A6
# 220529.v2022Release.3000.FULL.FIN.MAC64.DevKitAPI.tar.gz 1A2299982C90433F99E5C2228692058BF22928A7F5FC1784C4592F2FE11DB9A1

from conans import ConanFile, CMake, tools

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)

        self.output.warn(src)
        self.output.warn("current wd : " + os.getcwd())

        self.copy("license.txt")
        self.copy("**/ResConv.exe", src=src, dst="bin", keep_path=False)
        self.copy("**/ResConv", src=src, dst="bin", keep_path=False)
        self.copy("*.lib", src=src, dst="lib", keep_path=False)
        self.copy("*.dll", src=src, dst="bin", keep_path=False)
        self.copy("*.so", src=src, dst="lib", keep_path=False)
        if not self.copy("Frameworks/*.dylib", src=src, dst="bin/Support", keep_path=False):
            self.copy("Tools/*.dylib", src=src, dst="bin/Support", keep_path=False)
        self.copy("*.a", src=src, dst="lib", keep_path=False)
        self.copy("Frameworks/*.framework/*", src=src, dst="lib", symlinks=True)

        include_archicad = "include/Archicad"  # for SonarCloud
        # main headers
        self.copy("*.h", src=src + "Inc", dst=include_archicad)
        self.copy("*.hpp", src=src + "Inc", dst=include_archicad)
        self.copy("*.ico", src=src + "Inc", dst=include_archicad)
        self.copy("*.icns", src=src + "Inc", dst=include_archicad)

        # module headers
        self.copy("*.h", src=src + "Modules", dst=include_archicad)
        self.copy("*.hpp", src=src + "Modules", dst=include_archicad)

Have you read the CONTRIBUTING guide?

  • [X] I've read the CONTRIBUTING guide

manuelpagliuca avatar Feb 15 '24 11:02 manuelpagliuca

Sorry I tought that the -v option was standing for "verbose", but actually it is for "verify".

manuelpagliuca avatar Feb 15 '24 11:02 manuelpagliuca

But the issue remains, I'm attempting in debugging this conanfile.py, as you can see I'm using self.output.warn(src) function, but this doesn't get printed in the stdout.

manuelpagliuca avatar Feb 15 '24 11:02 manuelpagliuca

Sorry I tought that the -v option was standing for "verbose", but actually it is for "verify".

This has been changed in 2.0, where -v, -vv, etc are for verbose levels

yes, just drop the -v, that is a legacy feature, removed in 2.0, it shouldn't be used at all anymore.

memsharded avatar Feb 15 '24 14:02 memsharded

I see, anyway nothing gets copied, this is the output:

(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

manuelpagliuca avatar Feb 15 '24 15:02 manuelpagliuca

conan install will not copy anything because it doesn't call the package() method at all.

The package()method is only called for:

  • conan create when a package with a regular build() method builds from source
  • conan export-pkg when a package is created from pre-compiled binaries in the user folders.

I recommend doing the full Conan tutorial in https://docs.conan.io/2/tutorial/creating_packages.html to understand the concepts, it has sections both for create and export-pkg (like https://docs.conan.io/2/tutorial/creating_packages/other_types_of_packages/package_prebuilt_binaries.html)

memsharded avatar Feb 15 '24 17:02 memsharded

Now everything is more clear. But I would like to ask a thing which is related to this.

I'm exporting this package as a recipe, I then want to use this in a project setted with a conanfile.py

I would like to drag the modules folder as include paths, because when I later open the project on VS the project doesn't have this include path set. I'll explain with some images (screenshots are from mac but I'm using a windows machine for running VS).

image

So this are the files which are included in the package recipe, and for example one of this files has an include which is #include "Polygon2D.hpp" that uses a module called Geoemetry

image The file is contained in this folder of the ADK image

With the current settings the solution needs to manually include the directory "Geometry" for each project settings, this is tedious and doesn't seems correct. Another solution is to set the include as #include Geoemetry\Polygon2D.hpp which actually solves the problem, but seems more like a workaround that an actual solution.

Can you please me let me know if I'm doing something wrong during the export of the package (export-pkg) or maybe I've to look in the conanfile.py?

manuelpagliuca avatar Feb 29 '24 13:02 manuelpagliuca

Sorry, it seems I don't have enough information to understand the issue, and screenshots typically are not very convenient, it is much better to paste things as text.

In order to understand what is happening, you would need to provide:

  • A minimal conanfile.py of the dependency, together with some empty header that are packaged
  • A minimal consumer conanfile.py that requires that dependency, together with a minimal CMakeLists.txt and a minimal main.cpp that does #include to what you want.
  • The commands used to create the dependency, then to conan build . the consumer to reproduce the behavior.

Many thanks!

memsharded avatar Feb 29 '24 15:02 memsharded

Closing this ticket as responded/staled, thanks.

memsharded avatar Apr 11 '24 09:04 memsharded