Re: Installation location for python code, tools, etc.

2022-01-02 Thread Forrest Aldrich
Thanks for the quick replies.  I understand installing these in /opt may 
cause problems.   Looks like I will need to redo my Macports 
installation soon (grin).   I could try venv, or perhaps just set a 
separate PATH that my third-party stuff gets installed into -- once I 
figure out how to set that option.


Thanks!



Re: Installation location for python code, tools, etc.

2022-01-02 Thread Joshua Root

I'm not very experienced with Python, yet, but with regard to MacPorts,
I'm trying to understand why when I do a pip3 install, or a direct
install from a project tree ie: "python setup.py install" the tool(s)
end up in this directory instead of /opt/local/bin|sbin etc:

/opt/local/Library/Frameworks/Python.framework/Versions/3.9/bin/


Python is typically built as a framework on macOS, so that's where the 
modules go. See 
.


% python3.9
Python 3.9.9 (main, Nov 16 2021, 17:57:38)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.prefix
'/opt/local/Library/Frameworks/Python.framework/Versions/3.9'

Pip has a number of options controlling where things are installed: 



I strongly recommend not installing modules into the MacPorts prefix 
with pip (or manually), because modules installed in other ways will 
conflict with modules installed by MacPorts. Install in a venv, or use 
pip's --user option or some completely separate prefix.


- Josh



Re: Installation location for python code, tools, etc.

2022-01-02 Thread Bill Cole

On 2022-01-02 at 16:23:34 UTC-0500 (Sun, 2 Jan 2022 16:23:34 -0500)
Forrest Aldrich 
is rumored to have said:

I'm not very experienced with Python, yet, but with regard to 
MacPorts, I'm trying to understand why when I do a pip3 install, or a 
direct install from a project tree ie: "python setup.py install" the 
tool(s) end up in this directory instead of /opt/local/bin|sbin etc:


/opt/local/Library/Frameworks/Python.framework/Versions/3.9/bin/


This is how MacPorts supports simultaneous installs of different Python 
versions. You may note that there are versioned python symlinks in 
/opt/local/bin pointing to that path and possibly an additional bunch of 
symlinks making 'python' and 'python3' go there. If you install the 
python_select and python3_select ports, they will create links in 
/opt/local/bin if you run 'port select python' or 'port select python3' 
that ultimately resolve to that versioned path.


When you install a Python module outside of MacPorts, its installer is 
almost certain to not know to create those links.



I'm suspecting an environment variable.


I believe that *in theory* you should get binaries into 
/opt/local/(s)bin/ if you set the PYTHONHOME environment variable to 
'/opt/local/Library/Frameworks/Python.framework/Versions/3.9:/opt/local' 
when running setup.py or pip.



--
Bill Cole
b...@scconsult.com or billc...@apache.org
(AKA @grumpybozo and many *@billmail.scconsult.com addresses)
Not Currently Available For Hire


Installation location for python code, tools, etc.

2022-01-02 Thread Forrest Aldrich
I'm not very experienced with Python, yet, but with regard to MacPorts, 
I'm trying to understand why when I do a pip3 install, or a direct 
install from a project tree ie: "python setup.py install" the tool(s) 
end up in this directory instead of /opt/local/bin|sbin etc:


/opt/local/Library/Frameworks/Python.framework/Versions/3.9/bin/

I'm suspecting an environment variable.


Thanks.