Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] assert is_consumer --> AssertionError --> ERROR: #15900

Closed
1 task done
Peddaahh opened this issue Mar 20, 2024 · 4 comments
Closed
1 task done

[question] assert is_consumer --> AssertionError --> ERROR: #15900

Peddaahh opened this issue Mar 20, 2024 · 4 comments
Assignees
Milestone

Comments

@Peddaahh
Copy link

Peddaahh commented Mar 20, 2024

assert is_consumer --> AssertionError. Why does this happen and what does it do?

conan version

version: 2.0.17
python
  version: 3.10.11
  sys_version: 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]

OS: Windows 11 x64 23H2

I am using conan for a another programminglanguage, where dependencies are compiled libraries equivalent to DLLs. So I wrote these two conanfiles to kind of wrap such a compiled library to a conanpackage to manage it via Artifactory. Analyzing the Package build folder, everyrthing should work fine. However there is an issue when deploying it via conan install. I have attached the two conanfiles and my used commands below. The .dll gets sucessfully deployed in the directory where the install conanfile is, within the subfolder libs,
image
but during the deploy() step, I get the following error:

PS C:\_work\repos\_conantest\testinstall> conan install . --deployer-package=*

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=193
os=Windows

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=193
os=Windows


======== Computing dependency graph ========
Graph root
    conanfile.py: C:\_work\repos\_conantest\testinstall\conanfile.py
Requirements
    pkg/0.1#6528569f8b0f9387850396f49b88b66e - Cache

======== Computing necessary packages ========
Requirements
    pkg/0.1#6528569f8b0f9387850396f49b88b66e:da39a3ee5e6b4b0d3255bfef95601890afd80709#d3b1ee6374ab48b98c421d124fb0fb0a - Cache

======== Installing packages ========
pkg/0.1: Already installed! (1 of 1)

======== Finalizing install (deploy, generators) ========
pkg/0.1: Executing deploy()
ERROR: Traceback (most recent call last):
  File "C:\tools\Python310\lib\site-packages\conan\cli\cli.py", line 280, in main
    cli.run(args)
  File "C:\tools\Python310\lib\site-packages\conan\cli\cli.py", line 190, in run
    command.run(self._conan_api, args[0][1:])
  File "C:\tools\Python310\lib\site-packages\conan\cli\command.py", line 126, in run
    info = self._method(conan_api, parser, *args)
  File "C:\tools\Python310\lib\site-packages\conan\cli\commands\install.py", line 75, in install
    conan_api.install.install_consumer(deps_graph, args.generator, source_folder, output_folder,
  File "C:\tools\Python310\lib\site-packages\conan\api\subapi\install.py", line 66, in install_consumer
    do_deploys(self.conan_api, deps_graph, deploy, deploy_package, base_folder)
  File "C:\tools\Python310\lib\site-packages\conan\internal\deploy.py", line 47, in do_deploys
    if not conanfile.ref or not any(ref_matches(conanfile.ref, p, None)
  File "C:\tools\Python310\lib\site-packages\conan\internal\deploy.py", line 47, in <genexpr>
    if not conanfile.ref or not any(ref_matches(conanfile.ref, p, None)
  File "C:\tools\Python310\lib\site-packages\conans\model\recipe_ref.py", line 188, in ref_matches
    assert is_consumer
AssertionError

ERROR:
PS C:\_work\repos\_conantest\testinstall> 

Even after trying to understand what the code does where the error is happening, I could not fix the issue.

My conanfile which I execute with conan create .

from conan import ConanFile
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
from conan.tools.files import copy, download
from conan.tools.files.symlinks import absolute_to_relative_symlinks

class DLLBuild(ConanFile):
    name = "pkg"
    version = "0.1"

    def source(self):
        download(self,'http://localhost/pkg.dll', 'pkg.dll')

    def package(self):
        copy(self, "pkg.dll", src=self.source_folder, dst=self.package_folder)
        absolute_to_relative_symlinks(self, self.package_folder)

    def deploy(self):
        copy(self, "*.dll", src=self.package_folder, dst='lib')

The deploy conanfile which I execute with conan install . --deployer-package=*

from conan import ConanFile


class DLLDependencies(ConanFile):
    def requirements(self):
        self.requires("pkg/0.1")

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded memsharded self-assigned this Mar 20, 2024
@memsharded
Copy link
Member

Hi @Peddaahh

I am trying to reproduce, but this works:

def test_deploy_assert_error():
    c = TestClient()
    dep = textwrap.dedent("""
        from conan import ConanFile
        from conan.tools.files import copy, download
        from conan.tools.files.symlinks import absolute_to_relative_symlinks

        class DLLBuild(ConanFile):
            name = "pkg"
            version = "0.1"

            def source(self):
                pass # download(self,'http://localhost/pkg.dll', 'pkg.dll')

            def package(self):
                copy(self, "pkg.dll", src=self.source_folder, dst=self.package_folder)
                absolute_to_relative_symlinks(self, self.package_folder)

            def deploy(self):
                copy(self, "*.dll", src=self.package_folder, dst='lib')
            """)
    app = textwrap.dedent("""
        from conan import ConanFile

        class DLLDependencies(ConanFile):
            def requirements(self):
                self.requires("pkg/0.1")
                """)
    c.save({"dep/conanfile.py": dep,
            "app/conanfile.py": app})
    c.run("create dep")
    c.run("install app --deployer-package=*")

Checking the code, it seems that this has already been fixed in Conan 2.1. Can you please upgrade to Conan 2.1 and try again?
Thanks.

@Peddaahh
Copy link
Author

Hi @memsharded
Thanks for the reply!
Sadly the issue persists!

PS C:\_work\repos\_conantest\testinstall> conan version
version: 2.1.0
python
  version: 3.10.11
  sys_version: 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
PS C:\_work\repos\_conantest\testinstall>
PS C:\_work\repos\_conantest\testinstall> conan install . --deployer-package=*   
Migration: Successfully updated settings.yml
Migration: Successfully updated cppstd_compat.py

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=193
os=Windows

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=193
os=Windows


======== Computing dependency graph ========
Graph root
    conanfile.py: C:\_work\repos\_conantest\testinstall\conanfile.py
Requirements
    pkg/0.1#6528569f8b0f9387850396f49b88b66e - Cache

======== Computing necessary packages ========
Requirements
    pkg/0.1#6528569f8b0f9387850396f49b88b66e:da39a3ee5e6b4b0d3255bfef95601890afd80709#d3b1ee6374ab48b98c421d124fb0fb0a - Cache

======== Installing packages ========
pkg/0.1: Already installed! (1 of 1)

======== Finalizing install (deploy, generators) ========
pkg/0.1: Executing deploy()
ERROR: Traceback (most recent call last):
  File "C:\tools\Python310\lib\site-packages\conan\cli\cli.py", line 281, in main
    cli.run(args)
  File "C:\tools\Python310\lib\site-packages\conan\cli\cli.py", line 191, in run
    command.run(self._conan_api, args[0][1:])
  File "C:\tools\Python310\lib\site-packages\conan\cli\command.py", line 142, in run
    info = self._method(conan_api, parser, *args)
  File "C:\tools\Python310\lib\site-packages\conan\cli\commands\install.py", line 74, in install
    conan_api.install.install_consumer(deps_graph, args.generator, source_folder, output_folder,
  File "C:\tools\Python310\lib\site-packages\conan\api\subapi\install.py", line 73, in install_consumer
    do_deploys(self.conan_api, deps_graph, deploy, deploy_package, base_folder)
  File "C:\tools\Python310\lib\site-packages\conan\internal\deploy.py", line 47, in do_deploys
    if not conanfile.ref or not any(ref_matches(conanfile.ref, p, None)
  File "C:\tools\Python310\lib\site-packages\conan\internal\deploy.py", line 47, in <genexpr>
    if not conanfile.ref or not any(ref_matches(conanfile.ref, p, None)
  File "C:\tools\Python310\lib\site-packages\conans\model\recipe_ref.py", line 188, in ref_matches
    assert is_consumer
AssertionError

ERROR:
PS C:\_work\repos\_conantest\testinstall> pip freeze
artifactory==0.1.17
cachetools==5.3.1
certifi==2023.7.22
cfgv==3.3.1
chardet==5.2.0
charset-normalizer==3.3.0
colorama==0.4.6
colored==2.2.3
conan==2.1.0
distlib==0.3.7
et-xmlfile==1.1.0
fasteners==0.19
filelock==3.12.4
Gooey==1.0.8.1
identify==2.5.26
idna==3.4
Jinja2==3.1.3
junit-xml==1.9
KAI-Python-Tools==3.1.2+geed73e0
MarkupSafe==2.1.4
nodeenv==1.8.0
numpy==1.26.0
openpyxl==3.1.2
packaging==23.2
parse==1.19.1
patch-ng==1.17.4
pathlib==1.0.1
Pillow==10.0.1
platformdirs==3.10.0
pluggy==1.3.0
pre-commit==3.3.3
psutil==5.9.5
pygtrie==2.5.0
pyproject-api==1.6.1
python-dateutil==2.8.2
PyVISA==1.14.1
pywin32==306
PyYAML==6.0.1
requests==2.31.0
six==1.16.0
tomli==2.0.1
tox==4.11.3
typing_extensions==4.9.0
urllib3==1.26.18
vboxapi==1.0
virtualenv==20.24.6
wxPython==4.2.1
PS C:\_work\repos\_conantest\testinstall> 

@memsharded
Copy link
Member

Oh, I see you are right.

This has been fixed in #15737, that belongs to 2.2, not to 2.1.

It will be released today, so I am closing this as solved in Conan 2.2, please update when it is out and let us know if the issue persist. Thanks!

@memsharded memsharded added this to the 2.2.0 milestone Mar 20, 2024
@Peddaahh
Copy link
Author

@memsharded can confirm, seems to be fixed and working fine now.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants