Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: [OT++] Seeking Win32 Python Wisdom

by stevieb (Canon)
on Mar 16, 2017 at 14:11 UTC ( [id://1184881]=note: print w/replies, xml ) Need Help??


in reply to [OT++] Seeking Win32 Python Wisdom

"Alternatively, is there a file somewhere inside my existing python-2.7 distro that I could hack such that those backslashes are replaced by forward slashes ?"
>>> import site >>> site.getsitepackages() ['/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-pa +ckages']
locate sysconfig.py /usr/lib/python2.7/sysconfig.py /usr/lib/python2.7/sysconfig.pyc /usr/lib/python2.7/dist-packages/distlib/_backport/sysconfig.py /usr/lib/python2.7/dist-packages/distlib/_backport/sysconfig.pyc /usr/lib/python2.7/distutils/sysconfig.py /usr/lib/python2.7/distutils/sysconfig.pyc /usr/lib/python3.4/sysconfig.py /usr/lib/python3.4/distutils/sysconfig.py

That's on Linux, but the premise is the same for Windows. Briefly looking at the _getuserbase() code within the /usr/lib/python2.7/sysconfig.py file, the result may be coming from somewhere in the os.path method (os.py file), and I suspect that hacking it to do what you want will take quite some effort to make it consistent, while not breaking other stuff.

As mentioned already by thanos1983, modifying the result as it is returned to you, or overriding the method may be your best and/or safest bet.

Replies are listed 'Best First'.
Re^2: [OT++] Seeking Win32 Python Wisdom
by syphilis (Archbishop) on Mar 16, 2017 at 23:51 UTC
    As mentioned already by thanos1983, modifying the result as it is returned to you, or overriding the method may be your best and/or safest bet

    I'm dealing with an autotools (./configure) build, and the libtool script that's reporting the error is itself autogenerated during the build.

    I suppose it might be possible to make the correction in that script and then reset the script's timestamp to it's original setting.
    Line 5999 of the libtool script is:
    absdir=`cd "$dir" && pwd`
    I could try preceding that line of code with the shell scripting of $dir =~ s/\\/\//g
    What would that shell scripting equivalent of that perl code look like ? (I know as much about sh as I do about python ;-)

    It would be much better if Python just delivered a forward-slashed path.
    I'm guessing that there's a python command that's handing over python's equivalent of something like $Config{prefix}.
    C:\>perl -V:prefix prefix='c:\MinGW\perl524_64int';
    In perl I could easily hack a solution such that perl -V:prefix returned a forward-slashed rendition of that path.
    I was hoping that python might also lend itself to such hacking.

    looking at the _getuserbase() code within the /usr/lib/python2.7/sysconfig.py file, the result may be coming from somewhere in the os.path method (os.py file),

    Hmmm ... altering os.sep might (or might not) be all that's needed.
    How would I change that setting ?
    Is there a simple python command (or script) that will tell me the current setting of os.sep ?

    Cheers,
    Rob

      I've got a lot of Python dev systems at work, so I will have a closer look throughout the course of today :)

        I've eventually discovered that MSYS2 pacman can deliver Win32 binaries of the very packages I was struggling to build.
        (This is probably something that many others would have known ... but not those of us who are still living in the 1990's ;-)

        So I'll settle for that for now.
        Thanks for the feedback, and sorry for the noise. (I actually did learn quite a lot from this.)

        Cheers,
        Rob
Re^2: [OT++] Seeking Win32 Python Wisdom - duplicate (or close to) - please reap
by syphilis (Archbishop) on Mar 16, 2017 at 23:51 UTC
    As mentioned already by thanos1983, modifying the result as it is returned to you, or overriding the method may be your best and/or safest bet

    I'm dealing with an autotools (./configure) build, and the libtool script that's reporting the error is itself autogenerated during the build.

    I suppose it might be possible to make the correction in that script and then reset the script's timestamp to it's original setting.
    Line 5999 of the libtool script is:
    absdir=`cd "$dir" && pwd`
    I could try preceding that line of code with the shell scripting of $dir =~ s/\\/\//g
    What would that shell scripting equivalent of that perl code look like ? (I know as much about sh as I do about python ;-)

    It would be much better if Python just handed a forward-slashed path.
    I'm guessing that there's a python command that's handing over python's equivalent of something like $Config{prefix}.
    C:\>perl -V:prefix prefix='c:\MinGW\perl524_64int';
    In perl I could easily hack a solution such that perl -V:prefix returned a forward-slashed rendition of that path.
    I was hoping that python might also lend itself to such hacking.

    looking at the _getuserbase() code within the /usr/lib/python2.7/sysconfig.py file, the result may be coming from somewhere in the os.path method (os.py file),

    Hmmm ... altering os.sep might (or might not) be all that's needed.
    How would I change that setting ?
    Is there a simple python command (or script) that will tell me the current setting of os.sep ?

    Cheers,
    Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1184881]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-24 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found