예제 #1
0
파일: export.py 프로젝트: zlalanne/conan
def _capture_export_scm_data(conanfile, src_path, destination_folder, output,
                             paths, conan_ref):

    scm_src_file = paths.scm_folder(conan_ref)
    if os.path.exists(scm_src_file):
        os.unlink(scm_src_file)

    try:
        scm_data = SCMData(conanfile)
    except ConanException:
        return
    else:
        if not (scm_data.capture_origin or scm_data.capture_revision):
            return

    scm = SCM(scm_data, src_path)

    if scm_data.url == "auto":
        origin = scm.get_remote_url()
        if not origin:
            raise ConanException("Repo origin cannot be deduced by 'auto'")
        if os.path.exists(origin):
            output.warn("Repo origin looks like a local path: %s" % origin)
            origin = origin.replace("\\", "/")
        output.success("Repo origin deduced by 'auto': %s" % origin)
        scm_data.url = origin
    if scm_data.revision == "auto":
        scm_data.revision = scm.get_revision()
        output.success("Revision deduced by 'auto': %s" % scm_data.revision)

    # Generate the scm_folder.txt file pointing to the src_path
    save(scm_src_file, src_path.replace("\\", "/"))
    scm_data.replace_in_file(os.path.join(destination_folder, "conanfile.py"))
예제 #2
0
파일: export.py 프로젝트: mattgodbolt/conan
def _capture_export_scm_data(conanfile, conanfile_dir, destination_folder,
                             output, paths, conan_ref):

    scm_src_file = paths.scm_folder(conan_ref)
    if os.path.exists(scm_src_file):
        os.unlink(scm_src_file)

    scm_data = get_scm_data(conanfile)

    if not scm_data or not (scm_data.capture_origin
                            or scm_data.capture_revision):
        return

    scm = SCM(scm_data, conanfile_dir)

    if scm_data.url == "auto":
        origin = scm.get_qualified_remote_url()
        if not origin:
            raise ConanException("Repo origin cannot be deduced by 'auto'")
        if scm.is_local_repository():
            output.warn("Repo origin looks like a local path: %s" % origin)
        output.success("Repo origin deduced by 'auto': %s" % origin)
        scm_data.url = origin
    if scm_data.revision == "auto":
        if not scm.is_pristine():
            output.warn(
                "Repo status is not pristine: there might be modified files")
        scm_data.revision = scm.get_revision()
        output.success("Revision deduced by 'auto': %s" % scm_data.revision)

    # Generate the scm_folder.txt file pointing to the src_path
    src_path = scm.get_repo_root()
    save(scm_src_file, src_path.replace("\\", "/"))
    _replace_scm_data_in_conanfile(
        os.path.join(destination_folder, "conanfile.py"), scm_data)
예제 #3
0
def _capture_scm_auto_fields(conanfile, conanfile_dir, package_layout, output,
                             ignore_dirty, scm_to_conandata):
    """Deduce the values for the scm auto fields or functions assigned to 'url' or 'revision'
       and replace the conanfile.py contents.
       Returns a tuple with (scm_data, path_to_scm_local_directory)"""
    scm_data = get_scm_data(conanfile)
    if not scm_data:
        return None, None

    # Resolve SCMData in the user workspace (someone may want to access CVS or import some py)
    scm = SCM(scm_data, conanfile_dir, output)
    captured = scm_data.capture_origin or scm_data.capture_revision

    if not captured:
        # We replace not only "auto" values, also evaluated functions (e.g from a python_require)
        _replace_scm_data_in_recipe(package_layout, scm_data, scm_to_conandata)
        return scm_data, None

    if not scm.is_pristine() and not ignore_dirty:
        output.warn(
            "There are uncommitted changes, skipping the replacement of 'scm.url' and "
            "'scm.revision' auto fields. Use --ignore-dirty to force it. The 'conan "
            "upload' command will prevent uploading recipes with 'auto' values in these "
            "fields.")
        origin = scm.get_qualified_remote_url(remove_credentials=True)
        local_src_path = scm.get_local_path_to_url(origin)
        return scm_data, local_src_path

    if scm_data.url == "auto":
        origin = scm.get_qualified_remote_url(remove_credentials=True)
        if not origin:
            output.warn(
                "Repo origin cannot be deduced, 'auto' fields won't be replaced."
                " 'conan upload' command will prevent uploading recipes with 'auto'"
                " values in these fields.")
            local_src_path = scm.get_local_path_to_url(origin)
            return scm_data, local_src_path
        if scm.is_local_repository():
            output.warn("Repo origin looks like a local path: %s" % origin)
        output.success("Repo origin deduced by 'auto': %s" % origin)
        scm_data.url = origin

    if scm_data.revision == "auto":
        # If it is pristine by default we don't replace the "auto" unless forcing
        # This prevents the recipe to get uploaded pointing to an invalid commit
        scm_data.revision = scm.get_revision()
        output.success("Revision deduced by 'auto': %s" % scm_data.revision)

    local_src_path = scm.get_local_path_to_url(scm_data.url)
    _replace_scm_data_in_recipe(package_layout, scm_data, scm_to_conandata)

    return scm_data, local_src_path
예제 #4
0
def _capture_export_scm_data(conanfile, conanfile_dir, destination_folder,
                             output, scm_src_file):

    if os.path.exists(scm_src_file):
        os.unlink(scm_src_file)

    scm_data = get_scm_data(conanfile)
    if not scm_data:
        return

    # Resolve SCMData in the user workspace (someone may want to access CVS or import some py)
    scm = SCM(scm_data, conanfile_dir, output)
    captured = scm_data.capture_origin or scm_data.capture_revision

    if scm_data.url == "auto":
        origin = scm.get_qualified_remote_url(remove_credentials=True)
        if not origin:
            raise ConanException("Repo origin cannot be deduced")
        if scm.is_local_repository():
            output.warn("Repo origin looks like a local path: %s" % origin)
        output.success("Repo origin deduced by 'auto': %s" % origin)
        scm_data.url = origin

    if scm_data.revision == "auto":
        if not scm.is_pristine():
            output.warn(
                "Repo status is not pristine: there might be modified files")
        scm_data.revision = scm.get_revision()
        output.success("Revision deduced by 'auto': %s" % scm_data.revision)

    _replace_scm_data_in_conanfile(
        os.path.join(destination_folder, "conanfile.py"), scm_data)

    if captured:
        # Generate the scm_folder.txt file pointing to the src_path
        src_path = scm.get_local_path_to_url(scm_data.url)
        if src_path:
            save(scm_src_file, os.path.normpath(src_path).replace("\\", "/"))

    return scm_data