Python 3.x - How to get the directory where user installed package
<p>Suppose that I am building a Python package with the following folder tree:</p>

<pre><code>main
|-- setup.py
|-- the_package
     |--globar_vars.py
     |--the_main_script.py
</code></pre>

<p>When the user performs anyway to install it, like:</p>

<pre><code>sudo python setup.py install
python setup.py install --user
python setup.py install --prefix=/usr/local
</code></pre>

<p>Or well, using PIP:</p>

<pre><code>pip install 'SomeProject'
</code></pre>

<p>I want that the folder where the package was installed be saved on the <code>global_vars.py</code>, in any variable, Eg:</p>

<pre><code>globarl_vars.py
#!/usr/bin/env python3

user_installed_pkg = '/some/path/where/the/package/was/installed'
</code></pre>

<p>There is someway to get it? Thanks in advance.</p>

<pre><code>import wtv_module
print(wtv_module.__file__)

import os
print(os.path.dirname(wtv_module.__file__))
</code></pre>

python installation packages