Skip to content

documentation/migration guide needed for breaking change in 0.26.0 #2851

Description

@KrisThielemans

#2829 moved included files (and I don't know what else). Of course, this code is still v0.x, but we depend on it nevertheless. Can someone give some advice on how to update our code?

Activity

  1. ThisIsFineTM commented on May 14, 2025

    @ThisIsFineTM
    Contributor

    @KrisThielemans
    I ended up just throwing together a little regex find-replace script that did the job. Feel free to use/modify as you see fit. You can dump this in your top level repo directory and run it from there. Just update the path in the script and it should "just work".

    The main change in 0.26.0 is the include directory structure refactor. This script will update the include paths in a git repo you run it from to the new xtensor include structure.

    https://gist.github.com/ThisIsFineTM/0058dc85cbd4df9977c459762ae2415b

    #!/bin/sh
    
    # Author: github.com/ThisIsFineTM
    # Date: 2025-May-14
    #
    # Licence: The Unlicense
    # This is free and unencumbered software released into the public domain.
    # 
    # Anyone is free to copy, modify, publish, use, compile, sell, or distribute 
    # this software, either in source code form or as a compiled binary, for any
    # purpose, commercial or non-commercial, and by any means.
    # 
    # In jurisdictions that recognize copyright laws, the author or authors of
    # this software dedicate any and all copyright interest in the software to
    # the public domain. We make this dedication for the benefit of the public
    # at large and to the detriment of our heirs and successors. We intend this
    # dedication to be an overt act of relinquishment in perpetuity of all
    # present and future rights to this software under copyright law.
    # 
    # 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 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.
    # 
    # For more information, please refer to <https://unlicense.org/>
    
    XTENSOR_INCLUDE_DIR="/path/to/xtensor/include"
    
    # search for each hpp file in the new xtensor/include directory
    # and trim the excess path characters, and for each hpp file that is found
    for NEW_PATH in $(find "${XTENSOR_INCLUDE_DIR}" -name "*.hpp" | sed 's/.*\(xtensor\/[[:alpha:]]\+\/.*\.hpp\)/\1/') ; do
    
      # reconstruct the old path from the new one
      OLD_PATH=$(echo "${NEW_PATH}" | awk -F '/' '{printf "%s/%s", $1, $3}')
      
      # git grep to list tracked files in your repo that have the
      # individual "#include" strings present. Then pipe to sed to
      # remove the color codes because git-grep's --no-color 
      # misbehaves around files with a `-` in the name. 
      for MY_FILE in $(git grep --no-color -l "#include <${OLD_PATH}>" | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g') ; do
        
        # the first character after the 's' in a sed command specifies the escape character,
        # so use @ as the escape so the slashes in the path don't confuse it
        sed -i "s@#include <${OLD_PATH}>@#include <${NEW_PATH}>@" "${MY_FILE}"
        
      done
    
    done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions