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

Use user and channel of recipe if not specified #603

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion cpt/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from conans.client.runner import ConanRunner
from conans.model.ref import ConanFileReference
from conans.model.version import Version
from conans.errors import ConanException

from cpt import get_client_version
from cpt.auth import AuthManager
Expand Down Expand Up @@ -167,8 +168,27 @@ def __init__(self, username=None, channel=None, runner=None,

self.ci_manager = ci_manager or CIManager(self.printer)
self.remotes_manager = RemotesManager(self.conan_api, self.printer, remotes, upload)

#fix: load conan file early
self.conanfile = conanfile or os.getenv("CONAN_CONANFILE", "conanfile.py")
conanfile = load_cf_class(os.path.join(self.cwd, self.conanfile), self.conan_api)

try:
recipe_user = conanfile.user
except ConanException:
recipe_user = None

try:
recipe_channel = conanfile.channel
except ConanException:
recipe_channel = None

self.username = username or os.getenv("CONAN_USERNAME", None)

#fix: set username
if self.username is None and recipe_user:
self.username = recipe_user

self.skip_check_credentials = skip_check_credentials or get_bool_from_env("CONAN_SKIP_CHECK_CREDENTIALS")

self.auth_manager = AuthManager(self.conan_api, self.printer, login_username, password,
Expand Down Expand Up @@ -212,7 +232,10 @@ def __init__(self, username=None, channel=None, runner=None,
self.stable_channel = self.stable_channel.rstrip()
self.partial_reference = reference or os.getenv("CONAN_REFERENCE", None)
self.channel = self._get_specified_channel(channel, reference)
self.conanfile = conanfile or os.getenv("CONAN_CONANFILE", "conanfile.py")

#fix: set channel
if self.channel is None and recipe_channel:
self.channel = recipe_channel

if self.partial_reference:
if "@" in self.partial_reference:
Expand Down