-
-
Notifications
You must be signed in to change notification settings - Fork 29
Add ConanVersionRange class and test #102
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
Merged
Merged
Changes from 118 commits
Commits
Show all changes
119 commits
Select commit
Hold shift + click to select a range
6eacfa1
Initial commit
lasote c7862b5
Python 3 support and CI
lasote 1d8e4b1
Versin compare fix
lasote ab3e41e
Reverted version check
lasote faca806
Fixed output testing issues and improved version detection
lasote 190a028
Merge branch 'release/0.9.0'
lasote fa1f2a7
capturing traceback for offending line report
memsharded 961939a
Merge branch 'release/0.11.1'
lasote 9d22c14
Merge tag '0.11.1' into develop
lasote 0056863
Merge branch 'release/0.12.0'
lasote 65448f9
Merge tag '0.12.0' into develop
lasote b2ec8ae
fixing migrations with no settings.yml. Fixing Version parsing and co…
memsharded d529ee1
Better version compare in order to allow a 0.12.1-dev0 client operate…
lasote 9d4d9fd
Merge branch 'release/0.13.0'
lasote 705af5c
Merge tag '0.13.0' into develop
lasote 3467748
Feature/better upload (#795)
lasote 43f96b3
Moved retry to uploader_downloader, removed UploadException, changed …
lasote 5296756
Release/0.18 better retries and exception handling (#828)
lasote 175d4a3
Merge branch 'release/0.18' of github.com:conan-io/conan into release…
lasote 00c14a3
Merge tag '0.18.0' into develop
lasote d58ef71
Feature/improve semver (#927)
memsharded c46f3b4
Merge branch 'release/0.19.0'
lasote f5e5471
Merge tag '0.19.0' into develop
lasote c5e05b2
added new version modes, fixed string versions (#1108)
memsharded 2395801
Merge branch 'release/0.21.0'
lasote eeb9764
Merge tag '0.21.0' into develop
lasote fb69ace
Merge branch 'release/0.22.0'
lasote 6e4ba95
Merge tag '0.22.0' into develop
lasote 628c471
Feature/exception messages (#1301)
lasote d0c3fdb
Merge branch 'release/0.23.0'
lasote ec59d46
minor style fixes (#1698)
memsharded 52d16cc
Feature/full traceback (#1703)
lasote 8e54ad0
Better catches
lasote ce6b5b2
improved messages, fix manifest exceptions (#2665)
memsharded aa3ea86
Feature/refactor get package (#2722)
memsharded e3aea90
Feature/improve output (#2728)
lasote 429da79
Fix version class for greater than comparison (#2927)
danimtb 636886c
Fixed build property in Version class (#3219)
danimtb 22e143d
Add ConanInvalidConfiguration exception and handle error codes. (#3517)
jgsogo 524251d
v2 refactor (#4512)
lasote d8f5b23
[CLI] Accept a PackageReference in the command 'get' (preferred) (#4494)
jgsogo 1dd75f1
fix develop (#4560)
memsharded ef577a4
Fail nicely without revisions and only_v2 (#4663)
lasote b3c9ad7
Merge branch 'release/1.13.0'
lasote 2bb8ca8
Merge tag '1.13.0' into develop
lasote 560eae1
Merge branch 'release/1.14.0'
lasote b05f806
Merge tag '1.14.0' into develop
lasote 20f770a
print a message for unknown errors building the API (#4869)
jgsogo 86bd2c5
Merge branch 'release/1.14.1'
lasote 6ad9bea
Merge tag '1.14.1' into develop
lasote 0fbc897
Some docstrings for version class (#4274)
danimtb 044bbe9
Merge branch 'release/1.15.0'
lasote 1a18827
Merge tag '1.15.0' into develop
lasote 5353291
Merge branch 'release/1.16.0'
lasote 8dc9d51
Better ref representation (#5509)
lasote 9d9f5cd
Optional user/channel (#5381)
lasote df25942
Fix print stderr on failure at `check_output` tool. (#5548)
lasote 3a7c417
Merge branch 'release/1.18.0'
lasote 03cac1d
Merge tag '1.18.0' into develop
lasote 8c9fcd2
Merge branch 'release/1.19.0'
lasote e52842f
Merge tag '1.19.0' into develop
lasote 9d5161d
Requirement override using build metadata (#5903)
lasote cd197be
Merge branch 'release/1.19.2'
lasote ab0fd41
Merged 1.19.2
lasote b2cdeac
Merge pull request #1 from conan-io/develop
nicememory 2c5eae4
Merge branch 'release/1.20.0'
lasote 559f576
Merge tag '1.20.0' into develop
lasote 3629cdf
Merge pull request #6037 from nicememory/improving_error_message
memsharded 8c675e5
Merge branch 'release/1.21.0'
lasote 5f7d7b2
Add 'CONAN_V2_MODE' to start testing Conan v2 deprecated features (#6…
memsharded dab7e05
Merge branch 'release/1.23.0'
czoido 7ec660e
Remove disabled_revisions mode from 2.0: Remove support api v1 (#8412)
czoido 01a0e0e
Remove disabled_revisions mode from 2.0: Clean enabled_revisions (#8428)
czoido 1720db1
Introducing ConanErrorConfiguration exception (#9268)
memsharded 90a5097
Implement --update flows for revisions in conan cache 2.0 (#9191)
czoido 8730046
Remove CppInfo and update to NewCppInfo (#9657)
czoido 77c20f7
Add return code 7 (Invalid system requirements) (#9905)
n-bes b4aa374
merged develop
memsharded 553c652
removing python 2 legacy (#9927)
memsharded f5555f8
Removed PackageReference in favor of PkgReference (#9933)
lasote 4a81db5
some new Version improvements for build and pre-releases (#9930)
memsharded c769b3a
RecipeReference + Interfaces renaming and improving (#9982)
lasote 1edbc9c
Remove legacy activation of environment (#10007)
memsharded 83d76db
introducing new version_range model (#9970)
memsharded f5fd9e6
fixing version equality (#10036)
memsharded 3c9c947
Fixing some comparisons in new Version model (#10051)
memsharded 523433f
remove legacy Version classes, use new one (#10052)
memsharded 6a778d3
[develop2] remove dep to node-semver (#10058)
memsharded eef8bf3
minor cleanings and refactors (#10135)
memsharded 5a44eec
fix version ranges pre-releases (#10149)
memsharded 6edc7d8
checking tilde with prerelease excluded too (#10151)
memsharded e251243
moving _compilers to tools.build.flags and other minor cleanings (#10…
memsharded 4c7f417
[develop2] minor refactors and cleaning BinaryInstaller (#10577)
memsharded 5719b0f
remove conanfile attrs improvements (#10844)
memsharded d49a589
fix tools.scm.Version construction from non-str (#11119)
memsharded e6b2509
merged develop
memsharded b61525b
removed CalledProcessError exception (#11195)
memsharded 28d17d3
[develop2] Try to revert ``check_min_cppstd`` to use ``self.settings`…
memsharded b02d902
Add better error UX when spaces are found in required_conan_version (…
AbrilRBS 4b7c5d3
[develop2] display tracebacks in test errors (#12928)
memsharded 6b6add3
[bugfix] `Version` int comparison (#12934)
franramirez688 a471260
merged develop
memsharded 50ed1a7
[develop2] Improve error messages for wrong methods (#12962)
memsharded 5e5846d
[develop2] Fix MesonToolchain wrong cppstd in apple-clang (#13172)
memsharded e5c842f
Add ConanVersionRange class and test #101
johnmhoran 570f4ad
Fix import formatting #101
johnmhoran d71d003
Change scheme from conan to conan1 #101
johnmhoran 0c3283b
Add test and fix failing tests #101
johnmhoran 231039b
Fix 'gitlab_scheme'-related test failures #101
johnmhoran f6dda4c
verbose tracebacks (#13226)
memsharded c3d57ce
Change references from 'conan1' to 'conan' #101
johnmhoran ad674bf
Restructure conan version and tests
TG1999 d0edd52
Reuse conan code from https://github.com/conan-io/conan
TG1999 308d645
Modify imports according to restructured code
TG1999 ce76f0e
Fix formatting errors
TG1999 2290ed2
Adjust conan code according to univers #101
johnmhoran 48dc602
Use conan 2.0 as default conan version
TG1999 1e56074
Add .ABOUT, .NOTICE files #101
johnmhoran 01ff53e
Add .ABOUT, .NOTICE files for Conan test files #101
johnmhoran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,252 @@ | ||
| # | ||
| # Copyright (c) 2019 JFrog LTD | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # Visit https://aboutcode.org and https://github.com/nexB/univers for support and download. | ||
|
|
||
| """ | ||
| Exceptions raised and handled in Conan | ||
| These exceptions are mapped between server (as an HTTP response) and client | ||
| through the REST API. When an error happens in server its translated to an HTTP | ||
| error code that its sent to client. Client reads the server code and raise the | ||
| matching exception. | ||
|
|
||
| see return_plugin.py | ||
|
|
||
| """ | ||
| from contextlib import contextmanager | ||
|
|
||
|
|
||
| @contextmanager | ||
| def conanfile_remove_attr(conanfile, names, method): | ||
| """remove some self.xxxx attribute from the class, so it raises an exception if used | ||
| within a given conanfile method | ||
| """ | ||
| original_class = type(conanfile) | ||
|
|
||
| def _prop(attr_name): | ||
| def _m(_): | ||
| raise ConanException(f"'self.{attr_name}' access in '{method}()' method is forbidden") | ||
|
|
||
| return property(_m) | ||
|
|
||
| try: | ||
| new_class = type(original_class.__name__, (original_class,), {}) | ||
| conanfile.__class__ = new_class | ||
| for name in names: | ||
| setattr(new_class, name, _prop(name)) | ||
| yield | ||
| finally: | ||
| conanfile.__class__ = original_class | ||
|
|
||
|
|
||
| @contextmanager | ||
| def conanfile_exception_formatter(conanfile_name, func_name): | ||
| """ | ||
| Decorator to throw an exception formatted with the line of the conanfile where the error ocurrs. | ||
| """ | ||
|
|
||
| def _raise_conanfile_exc(e): | ||
| m = _format_conanfile_exception(conanfile_name, func_name, e) | ||
| raise ConanExceptionInUserConanfileMethod(m) | ||
|
|
||
| try: | ||
| yield | ||
| # TODO: Move ConanInvalidConfiguration from here? | ||
| except ConanInvalidConfiguration as exc: | ||
| msg = "{}: Invalid configuration: {}".format(str(conanfile_name), exc) | ||
| raise ConanInvalidConfiguration(msg) | ||
| except AttributeError as exc: | ||
| list_methods = [m for m in dir(list) if not m.startswith("__")] | ||
| if ( | ||
| "NoneType" in str(exc) | ||
| and func_name in ["layout", "package_info"] | ||
| and any(method in str(exc) for method in list_methods) | ||
| ): | ||
| raise ConanException( | ||
| "{}: {}. No default values are set for components. You are probably " | ||
| "trying to manipulate a component attribute in the '{}' method " | ||
| "without defining it previously".format(str(conanfile_name), exc, func_name) | ||
| ) | ||
| else: | ||
| _raise_conanfile_exc(exc) | ||
| except Exception as exc: | ||
| _raise_conanfile_exc(exc) | ||
|
|
||
|
|
||
| def _format_conanfile_exception(scope, method, exception): | ||
| """ | ||
| It will iterate the traceback lines, when it finds that the source code is inside the users | ||
| conanfile it "start recording" the messages, when the trace exits the conanfile we return | ||
| the traces. | ||
| """ | ||
| import sys | ||
| import traceback | ||
|
|
||
| try: | ||
| conanfile_reached = False | ||
| tb = sys.exc_info()[2] | ||
| index = 0 | ||
| content_lines = [] | ||
|
|
||
| while True: # If out of index will raise and will be captured later | ||
| # 40 levels of nested functions max, get the latest | ||
| filepath, line, name, contents = traceback.extract_tb(tb, 40)[index] | ||
| if "conanfile.py" not in filepath: # Avoid show trace from internal conan source code | ||
| if conanfile_reached: # The error goes to internal code, exit print | ||
| break | ||
| else: | ||
| if not conanfile_reached: # First line | ||
| msg = "%s: Error in %s() method" % (scope, method) | ||
| msg += ", line %d\n\t%s" % (line, contents) | ||
| else: | ||
| msg = ( | ||
| "while calling '%s', line %d\n\t%s" % (name, line, contents) | ||
| if line | ||
| else "\n\t%s" % contents | ||
| ) | ||
| content_lines.append(msg) | ||
| conanfile_reached = True | ||
| index += 1 | ||
| except Exception: | ||
| pass | ||
| ret = "\n".join(content_lines) | ||
| ret += "\n\t%s: %s" % (exception.__class__.__name__, str(exception)) | ||
| return ret | ||
|
|
||
|
|
||
| class ConanException(Exception): | ||
| """ | ||
| Generic conans exception | ||
| """ | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| self.info = None | ||
| self.remote = kwargs.pop("remote", None) | ||
| super(ConanException, self).__init__(*args, **kwargs) | ||
|
|
||
| def remote_message(self): | ||
| if self.remote: | ||
| return " [Remote: {}]".format(self.remote.name) | ||
| return "" | ||
|
|
||
| def __str__(self): | ||
|
|
||
| msg = super(ConanException, self).__str__() | ||
|
|
||
| try: | ||
| msg = str(msg) | ||
| except Exception: | ||
| msg = repr(msg) | ||
|
|
||
| if self.remote: | ||
| return "{}.{}".format(msg, self.remote_message()) | ||
|
|
||
| return msg | ||
|
|
||
|
|
||
| class ConanReferenceDoesNotExistInDB(ConanException): | ||
| """Reference does not exist in cache db""" | ||
|
|
||
| pass | ||
|
|
||
|
|
||
| class ConanReferenceAlreadyExistsInDB(ConanException): | ||
| """Reference already exists in cache db""" | ||
|
|
||
| pass | ||
|
|
||
|
|
||
| class NoRemoteAvailable(ConanException): | ||
| """No default remote configured or the specified remote do not exists""" | ||
|
|
||
| pass | ||
|
|
||
|
|
||
| class InvalidNameException(ConanException): | ||
| pass | ||
|
|
||
|
|
||
| class ConanConnectionError(ConanException): | ||
| pass | ||
|
|
||
|
|
||
| class ConanOutdatedClient(ConanException): | ||
| pass | ||
|
|
||
|
|
||
| class ConanExceptionInUserConanfileMethod(ConanException): | ||
| pass | ||
|
|
||
|
|
||
| class ConanInvalidConfiguration(ConanExceptionInUserConanfileMethod): | ||
| """ | ||
| This binary, for the requested configuration and package-id cannot be built | ||
| """ | ||
|
|
||
| pass | ||
|
|
||
|
|
||
| class ConanMigrationError(ConanException): | ||
| pass | ||
|
|
||
|
|
||
| # Remote exceptions # | ||
| class InternalErrorException(ConanException): | ||
| """ | ||
| Generic 500 error | ||
| """ | ||
|
|
||
| pass | ||
|
|
||
|
|
||
| class RequestErrorException(ConanException): | ||
| """ | ||
| Generic 400 error | ||
| """ | ||
|
|
||
| pass | ||
|
|
||
|
|
||
| class AuthenticationException(ConanException): # 401 | ||
| """ | ||
| 401 error | ||
| """ | ||
|
|
||
| pass | ||
|
|
||
|
|
||
| class ForbiddenException(ConanException): # 403 | ||
| """ | ||
| 403 error | ||
| """ | ||
|
|
||
| pass | ||
|
|
||
|
|
||
| class NotFoundException(ConanException): # 404 | ||
| """ | ||
| 404 error | ||
| """ | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| self.remote = kwargs.pop("remote", None) | ||
| super(NotFoundException, self).__init__(*args, **kwargs) | ||
|
|
||
|
|
||
| class UserInterfaceErrorException(RequestErrorException): | ||
| """ | ||
| 420 error | ||
| """ | ||
|
|
||
| pass | ||
|
|
||
|
|
||
| EXCEPTION_CODE_MAPPING = { | ||
| InternalErrorException: 500, | ||
| RequestErrorException: 400, | ||
| AuthenticationException: 401, | ||
| ForbiddenException: 403, | ||
| NotFoundException: 404, | ||
| UserInterfaceErrorException: 420, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| about_resource: errors.py | ||
| package_url: pkg:pypi/conan@2.0.0 | ||
| copyright: | | ||
| Copyright (c) 2019 JFrog LTD | ||
| download_url: https://github.com/conan-io/conan/blob/release/2.0/conans/errors.py | ||
| license_expression: MIT | ||
| homepage_url: https://github.com/conan-io/conan | ||
| notice_file: errors.py.NOTICE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| The MIT License (MIT) | ||
|
|
||
| Copyright (c) 2019 JFrog LTD | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in | ||
| all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| THE SOFTWARE. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.