conda-forge / pandas-feedstock

A conda-smithy repository for pandas.
BSD 3-Clause "New" or "Revised" License
8 stars 35 forks source link

Add run_constrained for optional dependencies #187

Open duncanmmacleod opened 10 months ago

duncanmmacleod commented 10 months ago

Comment:

Currently, installing pandas doesn't constrain the versions of any of the 'optional-dependencies' specified in the project's metadata. This means its easy to find yourself in situations where importing pandas results in warnings being emitted (slightly contrived example):

$ mamba create -n test pandas numexpr=2.7
$ conda activate test
$ python3 -c "import pandas"
/home/duncan/opt/mambaforge/envs/test/lib/python3.10/site-packages/numexpr/expressions.py:21: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  _np_version_forbids_neg_powint = LooseVersion(numpy.__version__) >= LooseVersion('1.12.0b1')
/home/duncan/opt/mambaforge/envs/test/lib/python3.10/site-packages/pandas/core/computation/expressions.py:21: UserWarning: Pandas requires version '2.8.0' or newer of 'numexpr' (version '2.7.3' currently installed).
  from pandas.core.computation.check import NUMEXPR_INSTALLED

Is it reasonable to add requirements/run_constrained to this recipe to map the version constraints for the optional dependencies?

I worry about the scope of this, given that there are ~35 optional dependencies, all with version constraints, and I don't want to burden the maintainers of this feedstock with more grunt work.

rootsmusic commented 7 months ago

Pandas requires version '2.8.0' or newer of 'numexpr' (version '2.7.3' currently installed).

This UserWarning is correct, because you specified numexpr=2.7. Version constraints doesn't apply when installing optional dependencies individually. For example, pip install "pandas[performance]" would constrain numexpr>=2.8.4 (as specified starting on line 65 in pyproject.toml).

duncanmmacleod commented 7 months ago

@rootsmusic, I (think I) understand the reason for the warning, what I'm asking here is if it's reasonable to modify the conda package to avoid the warning (basically to prevent the user from being able to build an environment that would emit a warning).

jefsayshi commented 1 month ago

@rootsmusic It looks like conda-main added the constraints. It would be helpful if conda-forge did as well. My particular use case is sqlalchemy=1.4 and pandas. Using conda-forge:

mamba create -n test-pandas python=3.10 sqlalchemy=1.4 pandas -c conda-forge --override-channels

pandas               2.2.2
sqlalchemy          1.4.49

Using conda-main:

mamba create -n test-pandas python=3.10 sqlalchemy=1.4 pandas -c conda-main --override-channels

pandas                 2.1.4
sqlalchemy            1.4.51

As pandas deprecated support for sqlalchemy 1.4 with pandas 2.2.0, only the conda-main solve results in a working environment. https://pandas.pydata.org/docs/dev/whatsnew/v2.2.0.html#increased-minimum-versions-for-dependencies

rootsmusic commented 1 month ago

@jefsayshi Will #211 resolve this issue?

jefsayshi commented 1 month ago

@rootsmusic It doesn't appear that any run_constrained were added to meta.yml so it is unlikely to resolve the issue