[Distutils] Cross-platform way to get default directory for binary files like console scripts?

Piotr Dobrogost p at google-groups-2014.dobrogost.net
Fri Feb 21 09:55:27 CET 2014


I posted (https://groups.google.com/forum/#!topic/comp.lang.python/s3vLkVy2xJk)
to comp.lang.python yesterday the following question:

Is there cross-platform way to get default directory for binary files
(console scripts for instance) the same way one can use sys.executable
to get path to the Python's interpreter in cross-platform way?

There's Python script which runs various tools like pip using
subprocess and we would like to make sure we run tools that accompany
Python's interpreter used to run this script. Please note that the
script may be run from within virtualenv which had not been activated
- ./venv/bin/python our_script.py

In replay Oscar Benjamin showed roundabout way to get this info

In [1]: from distutils.command.install import install
In [2]: from distutils.dist import Distribution
In [3]: c = install(Distribution())
In [4]: c.finalize_
c.finalize_options  c.finalize_other    c.finalize_unix
In [4]: c.finalize_options()
In [5]: c.insta
c.install_base       c.install_headers    c.install_lib
c.install_path_file  c.install_platlib    c.install_scripts
c.install_data       c.install_layout     c.install_libbase
c.install_platbase   c.install_purelib    c.install_userbase
In [5]: c.install_scripts
Out[5]: '/usr/local/bin'

Is it really that there's no API like sys.executable to get this info
and if so are there any plans to provide such API?

Best regards,
Piotr Dobrogost

More information about the Distutils-SIG mailing list