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

Add support for switching between non user/channel and user/channel mode #549

Open
tonka3000 opened this issue Mar 12, 2021 · 3 comments
Open
Assignees

Comments

@tonka3000
Copy link

Hey 👋 ,

I build conan center index recipes in-house, so that we get all our required build for our compilers. This works great, but one thing always occur.

The build script looks like

import os
import shutil
from cpt.packager import ConanMultiPackager
from conans import tools

def create_clean_build_folder(folder):
    if os.path.exists(folder):
        shutil.rmtree(folder)
    os.makedirs(folder)

if __name__ == "__main__":
    url = "https://github.com/conan-io/conan-center-index/archive/master.zip"
    recipe_folder = "conan-center-index-master/recipes/zlib/1.2.8"
    build_folder = "_build"
    reference="zlib/1.2.8@"

    tools.rmdir(build_folder)
    os.makedirs(build_folder)

    # download the conan index as zip and extract to a sub directory
    tools.get(
        url,
        filename="conan-index.zip",
        destination=build_folder,
        pattern=os.path.join(recipe_folder, "*"), # extract just zlib/1.2.8
        retry=2,
        retry_wait=5
    )
    conanfile = os.path.join(build_folder, recipe_folder, "conanfile.py")

    # normal cpt build, but with the downloaded conanfile
    builder = ConanMultiPackager(conanfile=conanfile, reference=reference)
    builder.add_common_builds()
    builder.run()

When we do this in the past we used channels to switch between channels. A half year ago we want to have the same reference as used in conan center index mypackage/0.1.2@ without channel and username and only upload on stable. This approach works but is not optimal for testing, because we need from time to time that the user can try out the new testing branch.

We think about using following approach in the near future:

stable branch: mypackage/0.1.2@
testing branch: mypackage/0.1.2@company/testing

We can do this in every build script and it would work but we have to do this over and over again. It would be nice when cpt would support that as well.
I've check the source code
and see that the actual impl. would not allow that because when it sees the @ in the reference it don't ask for the username/channel.

if self.partial_reference:
            if "@" in self.partial_reference:
                self.reference = ConanFileReference.loads(self.partial_reference)
            else:
                name, version = self.partial_reference.split("/")
                self.reference = ConanFileReference(name, version, self.username, self.channel)
        else:
            if not os.path.exists(os.path.join(self.cwd, self.conanfile)):
                raise Exception("Conanfile not found, specify a 'reference' "
                                "parameter with name and version")

I think with a minimal modification this could be support.

What are you thinking about that?

Greetings
Michael

@uilianries
Copy link
Member

It's not clear for me your problem... What do you propose?

@uilianries uilianries self-assigned this Mar 15, 2021
@tonka3000
Copy link
Author

Hey @uilianries ,

I want to be able to use cpt to switch between

stable branch: mypackage/0.1.2@
testing branch: mypackage/0.1.2@company/testing

by just using cpt environment variables

variables:
  CONAN_REFERENCE: "mypackage/0.1.0"
  CONAN_USERNAME: "company"
  CONAN_CHANNEL: "testing"
  CONAN_STABLE_BRANCH_PATTERN: "main"
  CONAN_STABLE_CHANNEL: "" # <= this seems not to work right now

@uilianries
Copy link
Member

@tonka3000 Now it's much clear. Thank you!

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

No branches or pull requests

2 participants