astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.6k stars 466 forks source link

Rye (uv) cannot resolve dependency when install Cirq #1102

Closed kaihsin closed 4 months ago

kaihsin commented 4 months ago

Steps to Reproduce

The issue occurs after 0.34.0 update (where the default backend changed to uv). Note that the pip-tool can successfully resolve and add cirq as dependency

  1. rye init
  2. rye sync
  3. rye add cirq

Expected Result

should be able to resolve the dependency for cirq package

Actual Result

Added cirq>=1.3.0 as regular dependency
Reusing already existing virtualenv
Generating production lockfile: /home/kaihsinwu/tmp_test/requirements.lock
  × No solution found when resolving dependencies:
  ╰─▶ Because only the following versions of qcs-api-client are available:
          qcs-api-client<0.20.13
          qcs-api-client>=0.21.0
      and only the following versions of qcs-api-client are available:
          qcs-api-client<0.21.0
          qcs-api-client>=0.22.0
      we can conclude that qcs-api-client>=0.20.13,<0.22.0 cannot be used.
      And because any of:
          pyquil>=3.2.0,<=3.2.1
          pyquil>=3.3.0,<=3.3.1
      depends on qcs-api-client>=0.20.13,<0.22.0, we can conclude that any of:
          pyquil>=3.2.0,<=3.2.1
          pyquil>=3.3.0,<=3.3.1
       cannot be used. (1)

      Because only the following versions of qcs-api-client are available:
          qcs-api-client<0.21.0
          qcs-api-client>=0.22.0
      and any of:
          pyquil>=3.3.2,<=3.4.1
          pyquil>=3.5.0,<=3.5.4
      depends on qcs-api-client>=0.21.0,<0.22.0, we can conclude that any of:
          pyquil>=3.3.2,<=3.4.1
          pyquil>=3.5.0,<=3.5.4
       cannot be used.
      And because we know from (1) that any of:
          pyquil>=3.2.0,<=3.2.1
          pyquil>=3.3.0,<=3.3.1
       cannot be used, we can conclude that any of:
          pyquil>=3.2.0,<=3.2.1
          pyquil>=3.3.0,<=3.4.1
          pyquil>=3.5.0,<=3.5.4
       cannot be used.
      And because only the following versions of pyquil are available:
          pyquil<=3.2.1
          pyquil>=3.3.0,<=3.4.1
          pyquil>=3.5.0
      we can conclude that pyquil>=3.2.0,<4.0.0 cannot be used.
      And because cirq-rigetti==1.3.0 depends on pyquil>=3.2.0,<4.0.0 and cirq==1.3.0 depends on
      cirq-rigetti==1.3.0, we can conclude that cirq==1.3.0 cannot be used.
      And because only cirq<=1.3.0 is available and you require cirq>=1.3.0, we can conclude that the
      requirements are unsatisfiable.

      hint: Pre-releases are available for cirq in the requested range (e.g., 1.4.0.dev20240518010119), but
      pre-releases weren't enabled (try: `--prerelease=allow`)

      hint: Pre-releases are available for pyquil in the requested range (e.g., 3.5.0rc0), but pre-releases
      weren't enabled (try: `--prerelease=allow`)
error: could not write production lockfile for project

Caused by:
    Failed to run uv compile /tmp/.tmpdn87l5/requirements.txt. uv exited with status: exit status: 1

Version Info

rye 0.34.0 commit: 0.34.0 (d31340178 2024-05-20) platform: linux (x86_64) self-python: cpython@3.12.1 symlink support: true uv enabled: true

Stacktrace

No response

charliermarsh commented 4 months ago

Did you attempt with --pre?

kaihsin commented 4 months ago

Yes. I tried rye add cirq --pre:

Added cirq>=1.4.0.dev20240518010119 as regular dependency
Reusing already existing virtualenv
Generating production lockfile: /home/kaihsinwu/tmp_test/requirements.lock
  × No solution found when resolving dependencies:
  ╰─▶ Because there is no version of cirq-aqt==1.4.0.dev20240518010119 and cirq==1.4.0.dev20240518010119 depends
      on cirq-aqt==1.4.0.dev20240518010119, we can conclude that cirq==1.4.0.dev20240518010119 cannot be used.
      And because only cirq<=1.4.0.dev20240518010119 is available and you require cirq>=1.4.0.dev20240518010119,
      we can conclude that the requirements are unsatisfiable.

      hint: cirq-aqt was requested with a pre-release marker (e.g., cirq-aqt==1.4.0.dev20240518010119), but
      pre-releases weren't enabled (try: `--prerelease=allow`)
error: could not write production lockfile for project

Caused by:
    Failed to run uv compile /tmp/.tmp401ecZ/requirements.txt. uv exited with status: exit status: 1
ischaojie commented 4 months ago

As a temporary solution, you can set the UV_PRERELEASE environment variable:

➜  ttt git:(main) ✗ export UV_PRERELEASE=allow
➜  ttt git:(main) ✗ rye add cirq --pre
Added cirq>=1.4.0.dev20240518010119 as regular dependency
Reusing already existing virtualenv
Generating production lockfile: /Users/zhezhezhu/projects/test/ttt/requirements.lock
Generating dev lockfile: /Users/zhezhezhu/projects/test/ttt/requirements-dev.lock
Installing dependencies
   Built file:///Users/zhezhezhu/projects/test/ttt                                                                                           Built 1 editable in 167ms
Resolved 73 packages in 23ms
   Built rpcq==3.11.0
   Built lark==0.11.3                                                                                                                        Downloaded 73 packages in 3.32s
Installed 75 packages in 261ms
 + anyio==4.3.0
 + attrs==21.4.0
 + cachetools==5.3.3
 ......
Done!
charliermarsh commented 4 months ago

I thought UV_PRERELEASE=allow was the same as --pre?

ischaojie commented 4 months ago

But using --pre directly does not work, there may be a bug~

➜  ttt git:(main) ✗ rye add cirq --pre
Initializing new virtualenv in /Users/zhezhezhu/projects/test/ttt/.venv
Python version: cpython@3.12.0
Added cirq>=1.4.0.dev20240518010119 as regular dependency
Reusing already existing virtualenv
Generating production lockfile: /Users/zhezhezhu/projects/test/ttt/requirements.lock
  × No solution found when resolving dependencies:
  ╰─▶ Because there is no version of cirq-aqt==1.4.0.dev20240518010119 and cirq==1.4.0.dev20240518010119 depends on
      cirq-aqt==1.4.0.dev20240518010119, we can conclude that cirq==1.4.0.dev20240518010119 cannot be used.
      And because only cirq<=1.4.0.dev20240518010119 is available and you require cirq>=1.4.0.dev20240518010119, we can conclude that the
      requirements are unsatisfiable.

      hint: cirq-aqt was requested with a pre-release marker (e.g., cirq-aqt==1.4.0.dev20240518010119), but pre-releases weren't enabled
      (try: `--prerelease=allow`)
error: could not write production lockfile for project

Caused by:
    Failed to run uv compile /var/folders/6t/rml6nn4d0q99nrqv8wmwz2t80000gn/T/.tmp14bFMO/requirements.txt. uv exited with status: exit status: 1
charliermarsh commented 4 months ago

Will take a look, maybe a bug there.

patrick-egenlauf commented 3 weeks ago

I have a similar issue. One package (jax) can not be resolved when rye sync is executed inside a GitHub workflow. However, on my local machine it works perfectly.

Workflow

name: CI
on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]
jobs:
  build_and_test:
    name: Build and Test
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]

    steps:
      - uses: actions/checkout@v4

      - name: Rye
        uses: eifinger/setup-rye@v4
        with:
          version: 'latest'
          enable-cache: false

      - name: Sync dependencies
        run: rye sync

      - name: Type-Check
        run: rye run ci

Output of the failed step

> Run rye sync
Initializing new virtualenv in /Users/runner/work/project/project/.venv
Python version: cpython@3.12.5
Generating production lockfile: /Users/runner/work/project/project/requirements.lock
  × No solution found when resolving dependencies:
  ╰─▶ Because jax-cuda12-plugin[with-cuda]==0.4.31 has no wheels
      with a matching Python ABI tag and jax[cuda12]==0.4.31 depends
      on jax-cuda12-plugin[with-cuda]==0.4.31, we can conclude that
      jax[cuda12]==0.4.31 cannot be used.
      And because only jax[cuda12]<=0.4.31 is available and you require
      jax[cuda12]>=0.4.31, we can conclude that your requirements are
      unsatisfiable.
error: could not write production lockfile for project

Caused by:
    Failed to run uv compile /var/folders/m4/5dz5h26x329cqq4fx333f8gm0000gn/T/.tmp1asOAq/requirements.txt. uv exited with status: exit status: 1

Part of my pyproject.toml file

dependencies = [
    "matplotlib>=3.9.2",
    "jax[cuda12]>=0.4.31",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.rye]
managed = true
dev-dependencies = [
    "pytest>=8.3.2",
    "coverage>=7.6.1",
]

[tool.rye.scripts]
ci = { chain = [
    "ci:lint",
    "ci:format",
    "ci:coverage",
    "ci:coverage_xml",
    "ci:print_coverage_report",
] }
"ci:lint" = "rye lint"
"ci:format" = "rye format --check"
"ci:coverage" = "rye run coverage run -m pytest"
"ci:coverage_xml" = "rye run coverage xml"
"ci:print_coverage_report" = "rye run coverage report -m"

requirements.lock file

# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
#   pre: true
#   features: []
#   all-features: false
#   with-sources: false
#   generate-hashes: false
#   universal: false

-e file:.
contourpy==1.3.0
    # via matplotlib
cycler==0.12.1
    # via matplotlib
fonttools==4.53.1
    # via matplotlib
jax==0.4.31
    # via physysim
jax-cuda12-pjrt==0.4.31
    # via jax-cuda12-plugin
jax-cuda12-plugin==0.4.31
    # via jax
jaxlib==0.4.31
    # via jax
kiwisolver==1.4.7
    # via matplotlib
matplotlib==3.9.2
    # via physysim
ml-dtypes==0.4.0
    # via jax
    # via jaxlib
numpy==2.1.1
    # via contourpy
    # via jax
    # via jaxlib
    # via matplotlib
    # via ml-dtypes
    # via opt-einsum
    # via scipy
nvidia-cublas-cu12==12.6.1.4
    # via jax-cuda12-plugin
    # via nvidia-cudnn-cu12
    # via nvidia-cusolver-cu12
nvidia-cuda-cupti-cu12==12.6.68
    # via jax-cuda12-plugin
nvidia-cuda-nvcc-cu12==12.6.68
    # via jax-cuda12-plugin
nvidia-cuda-runtime-cu12==12.6.68
    # via jax-cuda12-plugin
nvidia-cudnn-cu12==9.3.0.75
    # via jax-cuda12-plugin
nvidia-cufft-cu12==11.2.6.59
    # via jax-cuda12-plugin
nvidia-cusolver-cu12==11.6.4.69
    # via jax-cuda12-plugin
nvidia-cusparse-cu12==12.5.3.3
    # via jax-cuda12-plugin
    # via nvidia-cusolver-cu12
nvidia-nccl-cu12==2.22.3
    # via jax-cuda12-plugin
nvidia-nvjitlink-cu12==12.6.68
    # via jax-cuda12-plugin
    # via nvidia-cufft-cu12
    # via nvidia-cusolver-cu12
    # via nvidia-cusparse-cu12
opt-einsum==3.3.0
    # via jax
packaging==24.1
    # via matplotlib
pillow==10.4.0
    # via matplotlib
pyparsing==3.1.4
    # via matplotlib
python-dateutil==2.9.0.post0
    # via matplotlib
scipy==1.14.1
    # via jax
    # via jaxlib
six==1.16.0
    # via python-dateutil