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

"python-config --includes" returns a wrong path (double prefix) #66338

Closed
MichaelDussere mannequin opened this issue Aug 5, 2014 · 7 comments
Closed

"python-config --includes" returns a wrong path (double prefix) #66338

MichaelDussere mannequin opened this issue Aug 5, 2014 · 7 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes build The build process and cross-build type-bug An unexpected behavior, bug, or error

Comments

@MichaelDussere
Copy link
Mannequin

MichaelDussere mannequin commented Aug 5, 2014

BPO 22140
Nosy @benjaminp, @mgorny, @serhiy-storchaka
PRs
  • bpo-22140: Prevent double substitution of prefix in python-config.sh #3769
  • [3.6] closes bpo-22140: Prevent double substitution of prefix in python-config.sh (GH-3769) #3793
  • Files
  • patch_python_sym_links.txt
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2017-09-27.05:45:08.196>
    created_at = <Date 2014-08-05.13:28:32.622>
    labels = ['3.8', 'type-bug', '3.7', 'build']
    title = '"python-config --includes" returns a wrong path (double prefix)'
    updated_at = <Date 2017-09-28.03:27:44.092>
    user = 'https://bugs.python.org/MichaelDussere'

    bugs.python.org fields:

    activity = <Date 2017-09-28.03:27:44.092>
    actor = 'benjamin.peterson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-09-27.05:45:08.196>
    closer = 'benjamin.peterson'
    components = ['Build']
    creation = <Date 2014-08-05.13:28:32.622>
    creator = 'Michael.Dussere'
    dependencies = []
    files = ['39978']
    hgrepos = []
    issue_num = 22140
    keywords = ['patch']
    message_count = 7.0
    messages = ['224825', '231307', '247108', '249003', '303045', '303096', '303188']
    nosy_count = 6.0
    nosy_names = ['benjamin.peterson', 'mgorny', 'animus', 'serhiy.storchaka', 'Michael.Dussere', 'rdossin']
    pr_nums = ['3769', '3793']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue22140'
    versions = ['Python 3.4', 'Python 3.5', 'Python 3.6', 'Python 3.7', 'Python 3.8']

    @MichaelDussere
    Copy link
    Mannequin Author

    MichaelDussere mannequin commented Aug 5, 2014

    Our python is installed on a shared directory that is accessed through a symbolic link.
    $ which python3.4-config
    /Produits/publics/x86_64.Linux.RH6/python/3.4.1/bin/python3.4-config

    $ ls -al /Produits
    lrwxrwxrwx 1 root root 13 Oct 31  2013 /Produits -> /nfs/Produits

    With this configuration python-config returns a wrong path (it gives a double /nfs prefix)

    $ python3.4-config --includes
    -I/nfs/nfs/Produits/publics/x86_64.Linux.RH6/python/3.4.1/include/python3.4m -I/nfs/nfs/Produits/publics/x86_64.Linux.RH6/python/3.4.1/include/python3.4m

    The problem is due to a double string replacement in the script

    prefix_build="/Produits/publics/x86_64.Linux.RH6/python/3.4.1"
    prefix_real=$(installed_prefix "$0")

    # Use sed to fix paths from their built-to locations to their installed-to
    # locations.
    prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#")
    exec_prefix_build="${prefix}"
    exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#")
    includedir=$(echo "${prefix}/include" | sed "s#$prefix_build#$prefix_real#")

    for $includedir the replacement of $prefix_build by $prefix_real is applyed twice and since the $prefix_real contains $prefix_build it produce a wrong result.

    In addition I think it is strange to have lines like the following
    prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#")

    @MichaelDussere MichaelDussere mannequin added the type-bug An unexpected behavior, bug, or error label Aug 5, 2014
    @serhiy-storchaka
    Copy link
    Member

    Do you want to provide a patch?

    @serhiy-storchaka serhiy-storchaka added the build The build process and cross-build label Nov 18, 2014
    @rdossin
    Copy link
    Mannequin

    rdossin mannequin commented Jul 22, 2015

    I stumbled across the exact same problem and I have made a fix that is working, at least for the usage I have...

    @animus
    Copy link
    Mannequin

    animus mannequin commented Aug 23, 2015

    I don't understand: Why python-config needs to seek "realpath"? Why python-config is trying to be smarter than one who starts ./configure script?

    As so, the right thing to this, is remove "smart" parts from python-config. But as for fast hack in to this is replace line 'prefix_real=$(installed_prefix "$0")' with 'prefix_real=$prefix_build'.

    @mgorny
    Copy link
    Mannequin

    mgorny mannequin commented Sep 26, 2017

    I've submitted a pull request with another fix. I've tried to keep the changes at minimal but I couldn't stand keeping meaningless 'echo $x | sed -e s/$x/$y/' ;-).

    I have to point out that the attached patch is wrong since it does readlink on CFLAGS &c.

    @mgorny mgorny mannequin added 3.7 (EOL) end of life 3.8 only security fixes labels Sep 26, 2017
    @benjaminp
    Copy link
    Contributor

    New changeset 14086cf by Benjamin Peterson (Michał Górny) in branch 'master':
    closes bpo-22140: Prevent double substitution of prefix in python-config.sh (bpo-3769)
    14086cf

    @benjaminp
    Copy link
    Contributor

    New changeset 68b131d by Benjamin Peterson in branch '3.6':
    [3.6] closes bpo-22140: Prevent double substitution of prefix in python-config.sh (GH-3769) (bpo-3793)
    68b131d

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes build The build process and cross-build type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants