Skip to content

Commit

Permalink
Merge pull request #238 from ai4co/update-build-system
Browse files Browse the repository at this point in the history
[Feat] Update build system
  • Loading branch information
fedebotu authored Jan 14, 2025
2 parents 2d916ba + b76de4f commit eebb618
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 106 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ wandb/
# poetry
poetry.lock

# uv
uv.lock

# idea
.idea

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2024 AI4CO
Copyright (c) 2025 AI4CO

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<a href="https://pytorchlightning.ai/"><img alt="Lightning" src="https://img.shields.io/badge/-Lightning-792ee5?logo=pytorchlightning&logoColor=white"></a>
<a href="https://github.com/pytorch/rl"><img alt="base: TorchRL" src="https://img.shields.io/badge/base-TorchRL-red"></a>
<a href="https://hydra.cc/"><img alt="config: Hydra" src="https://img.shields.io/badge/config-Hydra-89b8cd"></a>
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
<a href="https://join.slack.com/t/rl4co/shared_invite/zt-1ytz2c1v4-0IkQ8NQH4TRXIX8PrRmDhQ"><img alt="Slack" src="https://img.shields.io/badge/slack-chat-611f69.svg?logo=slack"></a>
<a href="https://opensource.org/licenses/MIT"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-red.svg"></a>
<a href="https://colab.research.google.com/github/ai4co/rl4co/blob/main/examples/1-quickstart.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a>
Expand Down Expand Up @@ -89,7 +89,7 @@ git clone https://github.com/ai4co/rl4co && cd rl4co
pip install -e .
```

We recommend using a virtual environment such as `conda` to install `rl4co` locally.
We recommend installing in virtual environments with a package manager such as the blazing-fast [`uv`](https://docs.astral.sh/uv/), [`poetry`](https://python-poetry.org/), or [`conda`](https://docs.conda.io/en/latest/); instruction are available in the [documentation](https://rl4.co/docs/content/start/installation/).



Expand Down Expand Up @@ -174,14 +174,7 @@ pytest tests

### Known Bugs


#### Bugs installing PyTorch Geometric (PyG)

Installing `PyG` via `Conda` seems to update Torch itself. We have found that this update introduces some bugs with `torchrl`. At this moment, we recommend installing `PyG` with `Pip`:
```bash
pip install torch_geometric
```

You may check out the [issues](https://github.com/ai4co/rl4co/issues) and [discussions](https://github.com/ai4co/rl4co/discussions). We will also periodically post updates on the [FAQ section](https://rl4.co/docs/content/general/faq/).

## Contributing

Expand Down
58 changes: 56 additions & 2 deletions docs/content/start/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,68 @@ pip install rl4co
```

## Local install and development
If you want to develop RL4CO or access the latest builds, we recommend you to install it locally with `pip` in editable mode:
If you want to develop RL4CO or access the latest builds, you may install it locally after downloading the repo:

```bash
git clone https://github.com/ai4co/rl4co && cd rl4co
```

The simplest way is via `pip` in editable mode with
```bash
pip install -e .
```

> Note: `conda` is also a good candidate for hassle-free installation of PyTorch: check out the [PyTorch website](https://pytorch.org/get-started/locally/) for more details.
To install optional dependencies, you may specify them as follows `pip install -e ".[dev,graph,routing,docs]"`.

We recommend installing in virtual environments with a package manager such as the blazing-fast [`uv`](https://docs.astral.sh/uv/), [`poetry`](https://python-poetry.org/), or [`conda`](https://docs.conda.io/en/latest/), with quickstart commands below:

<details>
<summary>Install with `uv`</summary>

You first need to install `uv`, i.e., with `pip`:
```bash
pip install uv
```

Then, you can create a virtual environment locally and activate it:
```bash
uv sync --frozen
source .venv/bin/activate
```

Note that `uv` directly generates the `.venv` folder in the current directory.


To install (all) extras, you may use `uv sync --frozen --all-extras` or specify them individually with `uv sync --frozen --extra dev --extra graph --extra routing --extra docs`.

</details>


<details>
<summary>Install with `poetry`</summary>

Make sure that you have `poetry` installed from the [official website](https://python-poetry.org/docs/).

Then, you can create a virtual environment locally:
```bash
poetry install
poetry env activate # poetry shell removed in poetry 2.0.0
```

Note: you need to upgrade `poetry` to the latest version with `poetry self update` to versions >=2.0.0 (see [blog post](https://python-poetry.org/blog/announcing-poetry-2.0.0/)). This is also the reason why we don't need a special `pyproject.toml` anymore.

</details>


<details>
<summary>Install with `conda`</summary>

After [installing `conda`](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html), you can create a virtual environment locally with:
```bash
conda create -n rl4co python=3.12
conda activate rl4co
```
</details>


## Minimalistic Example
Expand Down
177 changes: 84 additions & 93 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
[tool.poetry]
[project]
name = "rl4co"
version = "0.5.1"
version = "0.5.2dev0"
description = "RL4CO: an Extensive Reinforcement Learning for Combinatorial Optimization Benchmark"
authors = [
"Federico Berto <[email protected]>",
"Chuanbo Hua <[email protected]>",
"Junyoung Park <[email protected]>",
"Laurin Luttmann <[email protected]>",
"Yining Ma",
"Fanchen Bu",
"Jiarui Wang",
"Haoran Ye",
"Minsu Kim",
"Sanghyeok Choi",
"Zepeda Gast",
"Andre Hottung",
"Jianan Zhou",
"Jieyi Bi",
"Yu Hu",
"Fei Liu",
"Hyeonah Kim",
"Jiwoo Son",
"Haeyeon Kim",
"Davide Angioni",
"Wouter Kool",
"Zhiguang Cao",
"Jie Zhang",
"Kijung Shin",
"Cathy Wu",
"Sungsoo Ahn",
"Guojie Song",
"Changhyun Kwon",
"Lin Xie",
"Jinkyoo Park",
"AI4CO",
{ name = "Federico Berto", email = "[email protected]" },
{ name = "Chuanbo Hua", email = "[email protected]" },
{ name = "Junyoung Park", email = "[email protected]" },
{ name = "Laurin Luttmann", email = "[email protected]" },
{ name = "Yining Ma" },
{ name = "Fanchen Bu" },
{ name = "Jiarui Wang" },
{ name = "Haoran Ye" },
{ name = "Minsu Kim" },
{ name = "Sanghyeok Choi" },
{ name = "Zepeda Gast" },
{ name = "Andre Hottung" },
{ name = "Jianan Zhou" },
{ name = "Jieyi Bi" },
{ name = "Yu Hu" },
{ name = "Fei Liu" },
{ name = "Hyeonah Kim" },
{ name = "Jiwoo Son" },
{ name = "Haeyeon Kim" },
{ name = "Davide Angioni" },
{ name = "Wouter Kool" },
{ name = "Zhiguang Cao" },
{ name = "Jie Zhang" },
{ name = "Kijung Shin" },
{ name = "Cathy Wu" },
{ name = "Sungsoo Ahn" },
{ name = "Guojie Song" },
{ name = "Changhyun Kwon" },
{ name = "Lin Xie" },
{ name = "Jinkyoo Park" },
{ name = "AI4CO" },
]
requires-python = ">=3.9"
readme = "README.md"
license = "MIT"
homepage = "https://rl4.co"
repository = "https://github.com/ai4co/rl4co"
documentation = "https://rl4co.readthedocs.io"
keywords = ["reinforcement learning", "combinatorial optimization", "benchmark"]
packages = [{ include = "rl4co" }]
keywords = [
"reinforcement learning",
"combinatorial optimization",
"benchmark",
]
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
Expand All @@ -54,59 +55,37 @@ classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Artificial Intelligence"
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
dependencies = [
"einops",
"hydra-core",
"hydra-colorlog",
"lightning>=2.1.0",
"matplotlib",
"omegaconf",
"pyrootutils",
"rich",
"robust-downloader",
"scipy",
"tensordict>=0.6.0",
"torchrl>=0.6.0",
"wandb",
]

[tool.poetry.urls]
"Tracker" = "https://github.com/ai4co/rl4co/issues"

[tool.poetry.dependencies]
# Required dependencies
python = ">=3.9"
einops = "*"
hydra-core = "*"
hydra-colorlog = "*"
lightning = ">=2.1.0"
matplotlib = "*"
omegaconf = "*"
pyrootutils = "*"
rich = "*"
robust-downloader = "*"
scipy = "*"
tensordict = ">=0.6.0"
torchrl = ">=0.6.0"
wandb = "*"
# Dev dependencies
black = { version = "*", optional = true }
pre-commit = { version = ">=3.3.3", optional = true }
ruff = { version = "*", optional = true }
pytest = { version = "*", optional = true }
pytest-cov = { version = "*", optional = true }
# Graph
torch_geometric = { version = "*", optional = true }
# Routing
numba = { version = ">=0.58.1", optional = true }
pyvrp = { version = ">=0.9.0", optional = true, python = "<4.0" }
# Docs
mkdocs = { version = "*", optional = true }
mkdocs-material = { version = "*", optional = true }
mkdocstrings-python = { version = "*", optional = true }
mike = { version = "*", optional = true }
mkdocs-jupyter = { version = "*", optional = true }
mkdocs-redirects = { version = "*", optional = true }
mkdocs-autolinks-plugin = { version = "*", optional = true }
griffe-typingdoc = { version = "*", optional = true }
griffe-inherited-docstrings = { version = "*", optional = true }
griffe = { version = "*", optional = true }
mkdocs-same-dir = { version = "*", optional = true }
mdx-breakless-lists = { version = "*", optional = true }
mdx-truly-sane-lists = { version = "*", optional = true }
markdown-gfm-admonition = { version = "*", optional = true }

[tool.poetry.extras]
dev = ["black", "pre-commit", "ruff", "pytest", "pytest-cov"]
[project.optional-dependencies]
dev = [
"black",
"pre-commit>=3.3.3",
"ruff",
"pytest",
"pytest-cov",
]
graph = ["torch_geometric"]
routing = ["numba", "pyvrp"]
routing = [
"numba>=0.58.1",
"pyvrp>=0.9.0 ; python_version < '4.0'",
]
docs = [
"mkdocs",
"mkdocs-material",
Expand All @@ -118,13 +97,29 @@ docs = [
"griffe-typingdoc",
"griffe-inherited-docstrings",
"griffe",
"black", # for formatting docstrings
"black",
"mkdocs-same-dir",
"mdx-breakless-lists",
"mdx-truly-sane-lists",
"markdown-gfm-admonition",
]

[project.urls]
Homepage = "https://rl4.co"
Repository = "https://github.com/ai4co/rl4co"
Documentation = "https://rl4co.readthedocs.io"
Tracker = "https://github.com/ai4co/rl4co/issues"

[tool.hatch.build.targets.sdist]
include = ["rl4co"]

[tool.hatch.build.targets.wheel]
include = ["rl4co"]

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

[tool.black]
line-length = 90
target-version = ["py311"]
Expand Down Expand Up @@ -180,7 +175,3 @@ exclude_lines = [
"pragma: no cover",
"if __name__ == .__main__.:",
]

[build-system]
requires = ["poetry"]
build-backend = "poetry.core.masonry.api"

0 comments on commit eebb618

Please sign in to comment.