Code Monkey home page Code Monkey logo

Comments (4)

jsiwek avatar jsiwek commented on August 18, 2024

If you use --prefix, Broker defaults to the "home scheme" type of python module installation and I think that's the intended location for that. It looks like you can use --python-prefix to override that and install in the location that you want?

from broker.

mavam avatar mavam commented on August 18, 2024

I've tried to read up on the notion of "home scheme" that says the modules go in ${BROKER_PYTHON_HOME}/lib/python, but could not find such reference. I've encountered only the other scheme in stackoverflow posts and official docs ${BROKER_PYTHON_PREFIX}/lib/python${pyver}/site-packages).

This workaround solves the problem, actually:

export PYTHONPATH="$PREFIX/lib/python"

But I wonder if we can avoid it, given that installing Broker in a Python venv should ideally not require setting this path manually.

from broker.

jsiwek avatar jsiwek commented on August 18, 2024

I've tried to read up on the notion of "home scheme" that says the modules go in ${BROKER_PYTHON_HOME}/lib/python, but could not find such reference.

https://docs.python.org/3.7/install/#alternate-installation-the-home-scheme

It's using this install location just because you gave an explicit --prefix. That can be an ambiguous situation since the typical install location for python modules in site-packages/ can live outside the --prefix that was given, so instead it just defaults to using the "home scheme" installation inside the prefix that you asked for.

This workaround solves the problem, actually:

export PYTHONPATH="$PREFIX/lib/python"
But I wonder if we can avoid it, given that installing Broker in a Python venv should ideally not require setting this path manually.

If you don't specify --prefix, then I expect it installs things in a location where you don't need to set PYTHONPATH.

There's also the --python-prefix option I mentioned that I think can be used in combination with --prefix if you actually want the python install prefix to differ from the typical install prefix.

I'm not quite sure there's a good way to automatically disambiguate what the user wanted in this case case, but if you come up with something feel free to submit a PR, else let me know if --python-prefix actually doesn't work how you expect.

from broker.

mavam avatar mavam commented on August 18, 2024

https://docs.python.org/3.7/install/#alternate-installation-the-home-scheme

Thanks, that link cleared up things for me.

My goal is that a user doesn't have to specify PYTHONPATH because I'm dealing with a virtual env that should be self-contained. To make this work, I needed to add a tiny script sitecustomize.py to $PREFIX/lib/pythonX.Y/site-packages:

import os
import site
import sys

home = os.path.join(sys.prefix, 'lib', 'python')
site.addsitedir(home)

It adds the Broker prefix $PREFIX/lib/python to sys.path such that setting PYTHONPATH is no longer needed.

from broker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.