Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python-venv.py and "v{version}+brewing" errors #286

Open
magnusviri opened this issue Jan 24, 2024 · 3 comments
Open

python-venv.py and "v{version}+brewing" errors #286

magnusviri opened this issue Jan 24, 2024 · 3 comments

Comments

@magnusviri
Copy link
Contributor

magnusviri commented Jan 24, 2024

When building (bk build ...) a python project using python-venv.py, I see this output in the terminal.

DEBUG:root:+TMPDIR=/Users/u0076374/_/pkgx/repos/pantry_mag/builds/github.com__univ-of-utah-marriott-library-apple__jctl-1.1.21/dev.pkgx.python.build bin/pip install /Users/u0076374/_/pkgx/repos/pantry_mag/builds/github.com__univ-of-utah-marriott-library-apple__jctl-1.1.21 --verbose --no-clean --require-virtualenv
Using pip 23.2.1 from /opt/pkgx/github.com/univ-of-utah-marriott-library-apple/jctl/v1.1.21+brewing/venv/lib/python3.12/site-packages/pip

The activate file (/opt/pkgx/github.com/univ-of-utah-marriott-library-apple/jctl/v1.1.21+brewing/venv/bin/activate) points to the path

/opt/pkgx/github.com/univ-of-utah-marriott-library-apple/jctl/v1.1.21+brewing/venv/

But the file system path is

/opt/pkgx/github.com/univ-of-utah-marriott-library-apple/jctl/v1.1.21/venv/ (without the "+brewing").

Thus the venv never activates.

@magnusviri
Copy link
Contributor Author

It looks like "+brewing" is in all of the venv/bin files.

@jhheider
Copy link
Contributor

jhheider commented Jan 24, 2024

hm. python-venv.py might need an update (or a deprecation).

if you compare the stub python-venv.py writes with the one made by python-venv-stubber.sh, you can see it introduces a hard-dependency on the build-time $VIRTUAL_ENV.

Perhaps even better, you might want to switch to the newer bkpyvenv command. It works like this:

  - bkpyvenv stage {{prefix}} {{version}}
  - # do any install steps, pip install, poetry install, etc
  - bkpyvenv seal {{prefix}} name_of_binary

it's more flexible, and allows for finer-grained control of the python interior install processes.

edited to add:

in particular, complex problems can be more easily solved, such as in OCRmyPDF:

    - bkpyvenv stage {{prefix}} {{version}}
    - ${{prefix}}/venv/bin/pip install .
    # pikepdf libs are compiled for MACOSX_DEPLOYMENT_TARGET=12.0
    - run: '{{prefix}}/venv/bin/pip install --no-cache-dir --force-reinstall --no-binary :all: pikepdf'
      if: darwin
    - bkpyvenv seal {{prefix}} ocrmypdf

@mxcl
Copy link
Member

mxcl commented Jan 24, 2024

Yeah that script needs an update, though probs just use the new two part system since it made the reason you created the .py version obsolete since you can control the pip instantiation now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants