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

Sync with system Python? #5964

Closed
b-phi opened this issue Aug 9, 2024 · 8 comments
Closed

Sync with system Python? #5964

b-phi opened this issue Aug 9, 2024 · 8 comments
Assignees
Labels
configuration Settings and such enhancement New feature or request

Comments

@b-phi
Copy link

b-phi commented Aug 9, 2024

I'm trying to use uv to synchronize environments across a cluster. This involves creating a lock file and then using it to install dependencies everywhere. As far as I can tell, uv sync only supports installing dependencies in a uv managed venv. Is there anyway to run sync against a target environment, the system Python in this case?

@b-phi
Copy link
Author

b-phi commented Aug 9, 2024

I was able to workaround this by activating the environment dynamically, but this does feel like a bit of a hack since it doesn't guarantee that the environments are actually synced. This is with a dask cluster, I'm not aware of an easy way to "switch" to the new venv if the workers are started with the system python.

import runpy

runpy.run_path('.venv/bin/activate_this.py')

@charliermarsh
Copy link
Member

Na this isn't supported yet.

@chrisrodrigue
Copy link

chrisrodrigue commented Aug 11, 2024

I think you can use uv venv --system-site-packages but uv sync is not yet aware of requirements that are already satisfied by the system/inherited environment so it still attempts to resolve and install them.

@Samuel-Therrien-Beslogic
Copy link

Samuel-Therrien-Beslogic commented Aug 14, 2024

In the mean time, I'm addind the venv's bin (or Scripts on Windows) folder to PATH as per https://github.com/jakebailey/pyright-action/tree/v2/?tab=readme-ov-file#using-pyright-from-path :

jobs:
  mypy:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: canopeum_backend
    steps:
      - uses: actions/checkout@v4
      - name: Install uv using the standalone installer
        run: curl -LsSf https://astral.sh/uv/install.sh | sh
      - run: uv sync --locked --extra dev
      - run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
      - run: mypy . --python-version=3.12

  pyright:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: canopeum_backend
    steps:
      - uses: actions/checkout@v4
      - name: Install uv using the standalone installer
        run: curl -LsSf https://astral.sh/uv/install.sh | sh
      - run: uv sync --locked --extra dev
      - run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
      - uses: jakebailey/pyright-action@v2
        with:
          version: PATH
          python-version: "3.12"
          working-directory: canopeum_backend

And making sure that my docker commands are using uv run instead of python

@seppzer0
Copy link

seppzer0 commented Aug 25, 2024

I upvote for the optional synchronization with the host system rather than with venv-only. Not only for CI/CD, but for me personally it is also occasionally preferable to install project packages into the system directly.

@hauntsaninja
Copy link
Contributor

One option is to symlink:

ln -sf $(/path/to/target/python -c 'import sys; print(sys.prefix)') .venv 
uv sync

@zanieb zanieb self-assigned this Aug 26, 2024
@zanieb zanieb added enhancement New feature or request configuration Settings and such labels Aug 26, 2024
theo-auffeuvre added a commit to BesLogic/releaf-canopeum that referenced this issue Aug 26, 2024
* Adding google maps package

* Set secret path for docker swar

* Debugging secrets

* Debugging secrets

* Debugging secrets

* Backend secret backend setted up

* Backend secret backend setted up v2

* Backend secret backend setted up v3

* Backend secret backend setted up v4

* Switch to UV for dependency and venv management

* Remove GitHub uv cache

* Missing dependencies

* powershell -> pwsh

* group tools vs stubs in dev dependencies

* sync djangorestframework-stubs higher

* Fix standalone isntaller to actually use Unix command

* try adding bin to path

* Add ref to astral-sh/uv#5964

* Remove dependency on pytz

* Edit Contact works fine

* Adding links edition , TODO add error validation

* Announcement edition OK , still TODO: error handling

* Fixing some html keys duplication

* Cardinal edit site fixed

* WIP

* Fix adress

* Error handling OK, TODO : Translation

* Translations OK

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixing lint and few build errors

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixing mypy and pyrights warns

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Line to long for ruff ><'

* Possibility to generate spec file by cli

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Rollbacking some mistakes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Ruff don't like bare exception, it is not really needed

* Build test

* Regenerating package.lock

* Revert "Possibility to generate spec file by cli"

This reverts commit 000da46.

* Update package-lock

* Update canopeum_frontend/src/components/analytics/site-modal/SiteModal.tsx

Co-authored-by: Samuel T. <samuel.therrien@beslogic.com>

* Update canopeum_frontend/src/components/analytics/site-modal/SiteModal.tsx

Co-authored-by: Samuel T. <samuel.therrien@beslogic.com>

* Update canopeum_backend/canopeum_backend/views.py

Co-authored-by: Samuel T. <samuel.therrien@beslogic.com>

* Rollback config database changes, opening another PR for these

* Removing indexing list because unecessary since dev test previously created same treetype on a single batch but shouldn't

* Simplifying things

* Lint autofix

* Mass linting

* Reason mandatory onCancel SiteModal + Bringing back StrictMode

* Update canopeum_frontend/src/components/social/AnnouncementCard.tsx

Co-authored-by: Samuel T. <samuel.therrien@beslogic.com>

* Update canopeum_frontend/src/components/social/AnnouncementCard.tsx

Co-authored-by: Samuel T. <samuel.therrien@beslogic.com>

* Rolling back to fit dprint requirements + deletion of requirement.txt

---------

Co-authored-by: Theo Auffeuvre <theo.auffeuvre@beslogic.com>
Co-authored-by: Samuel Therrien <samuel.therrien@beslogic.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@seppzer0
Copy link

seppzer0 commented Sep 5, 2024

I suppose it is a functional workaround, but having this implemented natively into uv would be a big improvement

@zanieb
Copy link
Member

zanieb commented Sep 5, 2024

This is now supported via UV_PROJECT_ENVIRONMENT (#6834) — I still don't recommend it but you don't need to do a symlink.

@zanieb zanieb closed this as completed Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Settings and such enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants