Re: open question on python ...

2018-05-11 Thread Ralph Seichter
On 11.05.18 21:45, Frederic Dubois wrote:

> is it equivalent to use port to manage "python + module" and port to
> manage "python" and pip to manage "module" ?

Both 'port' for Python modules and 'pip' change the contents of your
site-packages, so I consider them competitors for the same job. Don't
get me wrong, I love MacPorts and appreciate all the work put into it,
but when it comes to Python, I would only use port if a Python package
was unavailable via PyPI--which has not happened to me yet.

I can heartily recommend you only install the "Python core" (i.e. with
sudo port install python36) via MacPorts. For your projects, best use
discrete virtual environments. The Python 3 'venv' module will install
pip and setuptools, which then let you install your project requirements
in a fashion that isolates projects from each other and from your
system- or user-level Python libraries.

I happily let pip allocate a few extra MB of disk space in exchange for
greatly reduced headaches.

-Ralph


Re: open question on python ...

2018-05-11 Thread Joshua Root
Frederic Dubois wrote:
> Hi, 
> 
> This is an open question concerning the "good" way to manage python 
> "modules". 
> As you probably know python proposes various builtin "module" managers (such 
> as pip). 
> 
> A first question : is it equivalent to use port to manage "python + module" 
> and port to manage "python" and pip to manage "module" ? 
> Since now I tough that the first solution was the best since module 
> compilation is adapted to macos. Am I right ? Any comment ? 

We have ports of python modules for two main reasons: so they can be
used as dependencies of other ports, and so they can use other ports as
dependencies. We don't attempt to provide all modules on PyPI as ports.
So a big difference is that the set of available modules is not the same.

You can install some modules as ports and others with pip. However it's
very much not recommended to use 'sudo pip ...' with the default
installation path, as that will install modules to the same place as the
corresponding ports and will cause conflicts. Running pip as a normal
user and installing to somewhere else like your home directory is fine.

> A second question : python3 proposes builtin virtual environments management 
> (venv) which is deeply related to pip. 
> In case of using port to manage "python + module" how to do it ? 
> 
> I hope I am clear and thanks in advance for your answers. 

Using pip in a virtualenv is fine, and can be very useful if you need a
stable set of modules at specific versions for a project.

- Josh