docker's a heavyweight solution. Use Python's virtualenv. Then you can pip install whatever and not corrupt your macports install.
On Tue, Dec 6, 2022 at 7:27 AM David Herron <da...@davidherron.com> wrote: > Let me recommend Docker. You can use the Python base image, to select > your preferred Python version, and then run pip or pip3 (as appropriate) in > the Dockerfile. This way installed dependencies are neatly encapsulated, > they do not pollute your host environment, and you have documentation of > how the Python environment is configured. > > I demonstrate this in a blog post about OpenADR development using > OpenLEADR: > https://techsparx.com/energy-system/openadr/openleadr-docker.html > > A simplified Dockerfile would be: > > FROM python:3 > VOLUME /setup > VOLUME /app > RUN apt-get update && \ > apt-get upgrade -y && \ > apt-get install -y build-essential curl locales > COPY requirements.txt /setup/requirements.txt > RUN pip3 install -r /setup/requirements.txt > python3 /app/app.py > > > Then, to build it > > docker build --tag your-name/your-application-name:latest . > > Then it can be launched using a Docker Compose file > > services: > app: > image: your-name/your-application-name:latest > volumes: > - ./app-source-directory:/app/ > networks: > - adrnet > environment: > - PYTHONPATH=... other directories ...:/app > ports: > - 8080:8080 > > > And executed with the command: > > docker compose up > > On your terminal will be logging output. You can install more services > like databases in the Docker Compose file and manage them all this way. > The source code is dynamically mounted into the running container. That > means you can edit as you wish. My blog post demonstrates using Nodemon to > watch the source directory and to automatically restart Python if files > change. > > + David Herron > > > > On Tue, Dec 6, 2022 at 6:53 AM Thomas Gederberg <tgederb...@sbcglobal.net> > wrote: > >> It appears that you can either install Python modules (py310-matplotlib, >> py310-numpy, etc) either directly from MacPorts or you can install pip (for >> example py30-pip) with MacPorts and then use pip to install the modules. >> >> Is there a recommendation on which way to go? >> >> Tom Gederberg >> >