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

Setup a default virtual environment and unconditionally enter it #26015

Closed
jdstrand opened this issue Feb 13, 2025 · 1 comment
Closed

Setup a default virtual environment and unconditionally enter it #26015

jdstrand opened this issue Feb 13, 2025 · 1 comment
Assignees
Labels

Comments

@jdstrand
Copy link
Contributor

jdstrand commented Feb 13, 2025

#25969 (comment) says: "This (ed. having influxdb create a default python virtual environment and enter it on start) would be my preference. Many plugins are going to have dependencies that require a venv. And we already have a CLI & API to tell the server to load them. I think it would be a better UX to have everything included so they can just create a trigger and go".

This should be straightforward once #26012 is fixed. Specifically:

  1. determine a standard location on the file system for the virtual environment and use it (IMPORTANT: this breaks the "diskless architecture" to a degree
  2. see if the default venv exists and if not, have influxdb run /path/to/standalone/bin/python -m venv /path/to/location/of/default/venv
  3. source the activate script in /path/to/location/of/default/venv/bin/activate (\path\to\location\of\default\venv\Scripts\activate) and any other setup to enter the venv
  4. provide instructions for how users can update the venv manually. Ie:
$ source /path/to/location/of/default/venv/bin/activate
(influxdb3-default)$ pip install foo
...
(influxdb3-default)$ deactivate
  1. in the fullness of time, support improved user experiences of setting up the venv (requirements.txt, wrapper commands, etc).

UPDATE: TIL about influxdb3 install package foo so '3' is likely a documentation issue for advanced users.

Other considerations:

  • how to keep the venv up to date, if at all
  • how to deal with python-build-standalone minor version upgrades (we should be free to upgrade micro versions (eg, 3.11.10 -> 3.11.11 should be presumed safe; but 3.11.11 -> 3.12.x should not). Recall that symlinks/configuration in a venv point back to the runtime that was used to create it. I suspect it is brittle to change the runtime to a new minor version without recreating the venv (would need investigation). One way to handle this is to read the python minor version from the pyvenv.cfg in the venv, compare to the current python used by influxdb and then log a warning. Would need to provide a way to conveniently recreate the environment
  • we should be very conservative on pre-installing anything in the venv because users will invariably want different versions of things. Perhaps unconditionally adding uv is worthwhile, but I wonder if we need to support it at all ourselves? (see Consider integrating uv with standalone python builds #26016)
  • be cognizant of venv drift in Enterprise (eg, the venvs themselves are drifting due to user changes/etc or the python standalones are drifting because different Enterprise nodes are running different influxdb versions)

Tentatively assigning @jacksonrnewhouse (please adjust as needed).

@jdstrand jdstrand added the v3 label Feb 13, 2025
@jdstrand jdstrand changed the title setup a default virtual environment and unconditionally enter it Setup a default virtual environment and unconditionally enter it Feb 13, 2025
@jdstrand
Copy link
Contributor Author

jdstrand commented Feb 14, 2025

@jacksonrnewhouse - now that I see that this is already implemented, worked with previous Docker builds and now works on non-Windows with updated PATH to address #26012, I'm going to close this.

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

No branches or pull requests

2 participants