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

Improve the error message when trying to use a build-scripts package as a regular requirement #15366

Open
wants to merge 1 commit into
base: develop2
Choose a base branch
from

Conversation

valgur
Copy link
Contributor

@valgur valgur commented Dec 31, 2023

It currently fails on an assert with no further context provided in the stack trace. There might be a better place to do this check, though.

Also, might want to add a check for PackageType.PYTHON as well.

Changelog: Fix: Improve the error message when trying to use a build-scripts package as a regular requirement
Docs: Omit

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

…e as a regular requirement

It currently fails on an assert with no further context provided in the stack trace. There might be a better place to do this check, though. 

Also, might want to add a check for `PackageType.PYTHON` as well.
Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple of quick things:

  • Is there any scenario that this could break to users already leveraging this, even if it could be considered a bug? (I'd also like to check this with the team, labeling as look-into to discuss, it seems it makes sense, but just in case there could be some angle that I'd be missing)
  • It would be good to cover this with a test, if you need help or guidance, please ask, we can even contribute the test ourselves

@memsharded memsharded added this to the 2.1 milestone Dec 31, 2023
@@ -289,6 +289,8 @@ def transform_downstream(self, pkg_type, require, dep_pkg_type):
downstream_require = Requirement(require.ref, headers=False, libs=False, run=require.run)
elif pkg_type is PackageType.HEADER:
downstream_require = Requirement(require.ref, headers=require.headers, libs=require.libs, run=require.run)
elif pkg_type is PackageType.BUILD_SCRIPTS:
raise ConanError("build-scripts package must be used as a tool_requires(), not a regular requirement")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is about a build-script depending on a library, not really about it being used as regular requires. This might be an extra check to do, but it seems we want to do a general check over build-scripts being used only as tool-requires

@memsharded memsharded modified the milestones: 2.1, 2.2 Feb 12, 2024
@memsharded memsharded modified the milestones: 2.2.0, 2.3.0 Mar 18, 2024
@tbsuht
Copy link

tbsuht commented Apr 5, 2024

I just want to mention one case where we are currently using a build-scripts package via requires().
#15925

Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing the feedback, this is too risky, I think it needs some changes:

  • Make it a warning instead, not an error
  • Most likely better suited in DepsGraphBuilder._create_new_node

@memsharded memsharded removed this from the 2.3.0 milestone Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants