ai4co / rl4co

A PyTorch library for all things Reinforcement Learning (RL) for Combinatorial Optimization (CO)
https://rl4.co
MIT License
421 stars 79 forks source link

[BugFix] python version #204

Closed ShuN6211 closed 2 months ago

ShuN6211 commented 2 months ago

Enable to run "poetry install".

Description

Update pyproject.toml to be enable to run poetry install and install rl4co project by poetry tool. At current project, running poetry install may causes following errors.

The current project's Python requirement (>=3.8) is not compatible with some of the required packages Python requirement:
  - pyvrp requires Python <4.0,>=3.9, so it will not be satisfied for Python >=3.8,<3.9 || >=4.0
  - pyvrp requires Python <4.0,>=3.9, so it will not be satisfied for Python >=3.8,<3.9 || >=4.0
  - pyvrp requires Python <4.0,>=3.9, so it will not be satisfied for Python >=3.8,<3.9 || >=4.0
Because no versions of pyvrp match >0.8.2,<0.9.0 || >0.9.0,<0.9.1 || >0.9.1
 and pyvrp (0.8.2) requires Python <4.0,>=3.9, pyvrp is forbidden.
And because pyvrp (0.9.0) requires Python <4.0,>=3.9, pyvrp is forbidden.
So, because pyvrp (0.9.1) requires Python <4.0,>=3.9
 and rl4co depends on pyvrp (>=0.8.2), version solving failed.
  • Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties
    For pyvrp, a possible solution would be to set the `python` property to ">=3.9,<4.0"
    For pyvrp, a possible solution would be to set the `python` property to ">=3.9,<4.0"
    For pyvrp, a possible solution would be to set the `python` property to ">=3.9,<4.0"

Motivation and Context

Types of changes

What types of changes does your code introduce? Remove all that do not apply:

Checklist

Go over all the following points, and put an x in all the boxes that apply. If you are unsure about any of these, don't hesitate to ask. We are here to help!

fedebotu commented 2 months ago

Hi @ShuN6211 , thanks for reporting this!

How about this instead:

pyvrp = { version = ">=0.8.2", optional = true, python = ">=3.9,<4.0" }

in the dependencies. This is because pyvrp is optional, and we would like not to constrain rl4co too much based on such dependencies. I tried poetry install, and it works ~

ShuN6211 commented 2 months ago

Hi @fedebotu , thanks for commenting!! It's a good idea to specify python version "<4.0" not in dependencies but in optional scope. 😃 However, only changing a line regarding "pyvrp" still causes another error in my environment. It seems numba(optional) and lightning requires the numpy that requires python = ">=3.9" I tried following chunk and it works.

⭕️ Works

[tool.poetry.dependencies]
# Required dependencies
python = ">=3.9"
# Routing
pyvrp = { version = ">=0.8.2", optional = true, python = "<4.0" }

❌ Doesn't work , still causes another error

[tool.poetry.dependencies]
# Required dependencies
python = ">=3.8"
# Routing
pyvrp = { version = ">=0.8.2", optional = true, python = ">=3.9,<4.0" }

Procedure

Side notes

fedebotu commented 2 months ago

I see! This is better, in my opinion, since we may want to restrict a lower version of Python rather than the upper one (Python 3.8 is pretty old anyway). To be honest, though, I'm not a fan of restricting the main Python version because of some optional dependency, so if there was another way, I'd rather go for that :)

Thoughts @cbhua @LTluttmann?

fedebotu commented 2 months ago

Update: the newest PyTorch Lightning version has been released, and dropped support for Python 3.8 too: https://github.com/Lightning-AI/pytorch-lightning/releases/tag/2.4.0

Given this seems to be standard practice by now, I'd say let's remove official support for 3.8 altogether and follow @ShuN6211 's suggestion

ShuN6211 commented 2 months ago

@fedebotu
Thanks for sharing the dropping support for python 3.8 in the newest PyTorch Lightning. I added the revert commit and a new one that reflects conversation between us. If you don't prefer revert, I would reopen new PR.

cbhua commented 2 months ago

@ShuN6211 Thanks for reporting the bug about the Python version!

Considering the status of Python versions from the official release cycle that Python 3.8's end-of-life day is 2024-10, I agree that let's stop the support for Python 3.8.