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

zc.recipe.egg unneeddedly expands $ORIGIN-variables in rpath #225

Closed
woutervh opened this issue Jan 5, 2015 · 6 comments · Fixed by #229
Closed

zc.recipe.egg unneeddedly expands $ORIGIN-variables in rpath #225

woutervh opened this issue Jan 5, 2015 · 6 comments · Fixed by #229

Comments

@woutervh
Copy link

woutervh commented Jan 5, 2015

I'm using the rpath option in zc.recipe.egg build to compile software.
In order to make the buildout-directory relocatable (eg. deploy it in any directory in a production-machine), I'm using the special $ORIGIN-variable.

However, zc.recipe.egg thinks $ORIGIN is a relative path, and prepends the buildout-directory in front of it, while in fact it should be kept as it.

    [python-oracle-cxoracle]
    recipe = zc.recipe.egg:custom
    egg = cx_Oracle
    rpath =
    #   ${buildout:oracle-home-directory}  
        $ORIGIN/
        $ORIGIN/../../parts/python-oracle

Introspecting the compiled library-file:

> cd /apps/buildouts/test-base
>  readelf -d develop-eggs/cx_Oracle-5.1.3-py2.7-linux-x86_64.egg/cx_Oracle.so

    Dynamic section at offset 0x24030 contains 24 entries:
    Tag        Type                         Name/Value
   0x000000000000000f (RPATH)     Library rpath: [$ORIGIN/../lib:$ORIGIN/../../lib:$ORIGIN/../../../lib:$ORIGIN/../../../../lib:/apps/buildouts/test-base/$ORIGIN/:/apps/buildouts/test-base/$ORIGIN/../../parts/python-oracle]

where a correct RPATh would be

   0x000000000000000f (RPATH)     Library rpath: [$ORIGIN/../lib:$ORIGIN/:$ORIGIN/../../parts/python-oracle]
@woutervh woutervh changed the title zc.recipe.egg uneeddedly expands $ORIGIN-variables in rpath zc.recipe.egg unneeddedly expands $ORIGIN-variables in rpath Jan 5, 2015
@woutervh
Copy link
Author

woutervh commented Jan 6, 2015

The rpath specificaiton has 3 special variables:
$ORIGIN, $LIB, $PLATFORM,
${ORIGIN}, ${LIB}, ${PLATFORM}

cfr. http://man7.org/linux/man-pages/man8/ld.so.8.html

@tseaver
Copy link
Contributor

tseaver commented Jan 6, 2015

I'm not set up to test this properly. Can you try the following patch and let me know whether it works?

https://gist.github.com/tseaver/25a26a350b3b129ca4d9

@woutervh
Copy link
Author

woutervh commented Jan 7, 2015

I think there is something missing.
at line 34 (of the patch), the values are correct, but they are not used anywhere?

If the values are added to the result and options-variables,
then this is patch fixes the problem:

+ ...
+ value = options.get('rpath')
+ if value is not None:
+     values = [_prefix_non_special(v)
+                    for v in value.strip().split('\n') if v.strip()] 
+ result['rpath'] = os.pathsep.join(values)
+ options['rpath'] = os.pathsep.join(values)

@woutervh
Copy link
Author

woutervh commented Jan 8, 2015

the current applied patch is not correct

+ value = options.get('rpath')
+ if value is not None:
+     values = [_prefix_non_special(v)
+                    for v in value.strip().split('\n') if v.strip()] 
+     result['rpath'] = os.pathsep.join(value)
+     options['rpath'] = os.pathsep.join(value)
-     result['rpath'] = os.pathsep.join(value)
-     options['rpath'] = os.pathsep.join(value)
+     result['rpath'] = os.pathsep.join(values)
+     options['rpath'] = os.pathsep.join(values)

From a pdb-session:

(Pdb) p value
'$ORIGIN/\n$ORIGIN/../../parts/python-oracle'

(Pdb) print values
['$ORIGIN/', '$ORIGIN/../../parts/python-oracle']

(Pdb) os.pathsep.join(value) 
'$:O:R:I:G:I:N:/:\n:$:O:R:I:G:I:N:/:.:.:/:.:.:/:p:a:r:t:s:/:p:y:t:h:o:n:-:o:r:a:c:l:e'

(Pdb) os.pathsep.join(values)
'$ORIGIN/:$ORIGIN/../../parts/python-oracle'

@tseaver
Copy link
Contributor

tseaver commented Jan 8, 2015

I've pushed that change to #229.

@reinout
Copy link
Contributor

reinout commented Jul 1, 2015

zc.recipe.egg 2.0.2 is out! https://pypi.python.org/pypi/zc.recipe.egg/2.0.2

@buildout buildout deleted a comment from javablockef Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants