Skip to content

Commit d2cf3e9

Browse files
saitcakmakfacebook-github-bot
authored andcommitted
Switch to pyproject.toml for builds (#3002)
Summary: Pull Request resolved: #3002 Replicates D79678941 for BoTorch. A key change is that `ALLOW_LATEST_GPYTORCH_LINOP` option is removed and replaced with `>=` requirements for these dependencies. Reviewed By: Balandat Differential Revision: D81728068 fbshipit-source-id: 8370307a2802c83b67f6e0b4d7523342542775f3
1 parent 7258017 commit d2cf3e9

File tree

10 files changed

+87
-156
lines changed

10 files changed

+87
-156
lines changed

.github/workflows/docs.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ jobs:
2727
with:
2828
python-version: "3.13"
2929
- name: Install dependencies
30-
env:
31-
ALLOW_LATEST_GPYTORCH_LINOP: true
3230
run: |
3331
uv pip install git+https://github.com/cornellius-gp/linear_operator.git
3432
uv pip install git+https://github.com/cornellius-gp/gpytorch.git

.github/workflows/nightly.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ jobs:
3434
with:
3535
python-version: "3.13"
3636
- name: Install dependencies
37-
env:
38-
ALLOW_LATEST_GPYTORCH_LINOP: true
3937
run: |
4038
uv pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
4139
uv pip install git+https://github.com/cornellius-gp/linear_operator.git
@@ -49,13 +47,9 @@ jobs:
4947
no_local_version=$(python -m setuptools_scm | cut -d "+" -f 1)
5048
echo "SETUPTOOLS_SCM_PRETEND_VERSION=${no_local_version}" >> $GITHUB_ENV
5149
- name: Build packages (wheel and source distribution)
52-
env:
53-
ALLOW_LATEST_GPYTORCH_LINOP: true
5450
run: |
5551
python -m build --sdist --wheel
5652
- name: Verify packages
57-
env:
58-
ALLOW_LATEST_GPYTORCH_LINOP: true
5953
run: |
6054
./scripts/verify_py_packages.sh
6155
- name: Deploy to Test PyPI

.github/workflows/publish_website.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ jobs:
5757
uv pip install git+https://github.com/cornellius-gp/linear_operator.git
5858
uv pip install git+https://github.com/cornellius-gp/gpytorch.git
5959
- name: Install dependencies
60-
env:
61-
ALLOW_LATEST_GPYTORCH_LINOP: true
6260
run: |
6361
uv pip install ."[dev, tutorials]"
6462
- if: ${{ inputs.new_version }}

.github/workflows/reusable_test.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ jobs:
3838
uv pip install .[test]
3939
- name: Install dependencies with latest PyTorch & GPyTorch
4040
if: ${{ inputs.use_latest_pytorch_gpytorch }}
41-
env:
42-
ALLOW_LATEST_GPYTORCH_LINOP: true
4341
run: |
4442
uv pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
4543
uv pip install git+https://github.com/cornellius-gp/linear_operator.git

.github/workflows/reusable_tutorials.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,13 @@ jobs:
4747
- if: ${{ inputs.use_stable_pytorch_gpytorch }}
4848
name: Install min required PyTorch, GPyTorch, and linear_operator
4949
run: |
50-
python setup.py egg_info
51-
req_txt="botorch.egg-info/requires.txt"
52-
min_torch_version=$(grep '\btorch[>=]=' ${req_txt} | sed 's/[^0-9.]//g')
53-
min_gpytorch_version=$(grep '\bgpytorch[>=]=' ${req_txt} | sed 's/[^0-9.]//g')
54-
min_linear_operator_version=$(grep '\blinear_operator[>=]=' ${req_txt} | sed 's/[^0-9.]//g')
50+
# Extract minimum versions from pyproject.toml
51+
min_torch_version=$(grep '"torch>=' pyproject.toml | sed 's/.*"torch>=\([^"]*\)".*/\1/')
52+
min_gpytorch_version=$(grep '"gpytorch>=' pyproject.toml | sed 's/.*"gpytorch>=\([^"]*\)".*/\1/')
53+
min_linear_operator_version=$(grep '"linear_operator>=' pyproject.toml | sed 's/.*"linear_operator>=\([^"]*\)".*/\1/')
5554
uv pip install "numpy<2" # Numpy >2.0 is not compatible with PyTorch <2.2.
5655
uv pip install "torch==${min_torch_version}" "gpytorch==${min_gpytorch_version}" "linear_operator==${min_linear_operator_version}" torchvision
5756
- name: Install BoTorch with tutorials dependencies
58-
env:
59-
ALLOW_LATEST_GPYTORCH_LINOP: true
6057
run: |
6158
uv pip install .[tutorials]
6259
- if: ${{ inputs.smoke_test }}

.github/workflows/test_stable.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@ jobs:
3434
python-version: ${{ matrix.python-version }}
3535
- name: Install dependencies
3636
run: |
37-
uv pip install setuptools # Needed for next line on Python 3.13.
38-
python setup.py egg_info
39-
req_txt="botorch.egg-info/requires.txt"
40-
min_torch_version=$(grep '\btorch[>=]=' ${req_txt} | sed 's/[^0-9.]//g')
37+
# Extract minimum versions from pyproject.toml
38+
min_torch_version=$(grep '"torch>=' pyproject.toml | sed 's/.*"torch>=\([^"]*\)".*/\1/')
4139
# The earliest PyTorch version on Python 3.13 available for all OS is 2.6.0.
4240
min_torch_version="$(if ${{ matrix.python-version == '3.13' }}; then echo "2.6.0"; else echo "${min_torch_version}"; fi)"
43-
min_gpytorch_version=$(grep '\bgpytorch[>=]=' ${req_txt} | sed 's/[^0-9.]//g')
44-
min_linear_operator_version=$(grep '\blinear_operator[>=]=' ${req_txt} | sed 's/[^0-9.]//g')
41+
min_gpytorch_version=$(grep '"gpytorch>=' pyproject.toml | sed 's/.*"gpytorch>=\([^"]*\)".*/\1/')
42+
min_linear_operator_version=$(grep '"linear_operator>=' pyproject.toml | sed 's/.*"linear_operator>=\([^"]*\)".*/\1/')
4543
uv pip install "numpy<2" # Numpy >2.0 is not compatible with PyTorch <2.2.
4644
uv pip install "torch==${min_torch_version}" "gpytorch==${min_gpytorch_version}" "linear_operator==${min_linear_operator_version}"
4745
uv pip install .[test]

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ Optimization simply use Ax.
5656
**Installation Requirements**
5757
- Python >= 3.10
5858
- PyTorch >= 2.0.1
59-
- gpytorch == 1.14
60-
- linear_operator == 0.6
59+
- gpytorch >= 1.14
60+
- linear_operator >= 0.6
6161
- pyro-ppl >= 1.8.4
6262
- scipy
6363
- multiple-dispatch
@@ -86,13 +86,11 @@ conda install botorch -c gpytorch -c conda-forge
8686

8787
If you would like to try our bleeding edge features (and don't mind potentially
8888
running into the occasional bug here or there), you can install the latest
89-
development version directly from GitHub. If you want to also install the
90-
current `gpytorch` and `linear_operator` development versions, you will need
91-
to ensure that the `ALLOW_LATEST_GPYTORCH_LINOP` environment variable is set:
89+
development version directly from GitHub. You may also want to install the
90+
current `gpytorch` and `linear_operator` development versions:
9291
```bash
9392
pip install --upgrade git+https://github.com/cornellius-gp/linear_operator.git
9493
pip install --upgrade git+https://github.com/cornellius-gp/gpytorch.git
95-
export ALLOW_LATEST_GPYTORCH_LINOP=true
9694
pip install --upgrade git+https://github.com/pytorch/botorch.git
9795
```
9896

@@ -117,7 +115,6 @@ pip install -e .
117115
```bash
118116
git clone https://github.com/pytorch/botorch.git
119117
cd botorch
120-
export ALLOW_BOTORCH_LATEST=true
121118
pip install -e ".[dev, tutorials]"
122119
```
123120

pyproject.toml

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,80 @@
22
requires = ["setuptools", "setuptools_scm[toml]", "wheel"]
33
build-backend = "setuptools.build_meta"
44

5+
[project]
6+
name = "botorch"
7+
description = "Bayesian Optimization in PyTorch"
8+
authors = [{name = "Meta Platforms, Inc."}]
9+
license = "MIT"
10+
license-files = ["LICENSE"]
11+
readme = "README.md"
12+
requires-python = ">=3.10"
13+
keywords = ["Bayesian optimization", "PyTorch"]
14+
classifiers = [
15+
"Development Status :: 4 - Beta",
16+
"Programming Language :: Python :: 3 :: Only",
17+
"Topic :: Scientific/Engineering",
18+
"Intended Audience :: Science/Research",
19+
"Intended Audience :: Developers",
20+
]
21+
dynamic = ["version"]
22+
23+
dependencies = [
24+
"typing_extensions",
25+
"pyre_extensions",
26+
"gpytorch>=1.14",
27+
"linear_operator>=0.6",
28+
"torch>=2.0.1",
29+
"pyro-ppl>=1.8.4",
30+
"scipy",
31+
"multipledispatch",
32+
"threadpoolctl",
33+
]
34+
35+
[project.optional-dependencies]
36+
pymoo = [
37+
"pymoo",
38+
]
39+
40+
test = [
41+
"pytest",
42+
"pytest-cov",
43+
"requests",
44+
"pymoo",
45+
]
46+
47+
dev = [
48+
"botorch[test]",
49+
"flake8",
50+
"ufmt",
51+
"flake8-docstrings",
52+
"sphinx",
53+
"sphinx-rtd-theme",
54+
]
55+
56+
tutorials = [
57+
"cma",
58+
"jupyter",
59+
"matplotlib",
60+
"memory_profiler",
61+
"papermill",
62+
"pykeops",
63+
"torchvision",
64+
"mdformat",
65+
"pandas",
66+
"lxml",
67+
"mdformat-myst",
68+
"tabulate",
69+
]
70+
71+
[project.urls]
72+
Homepage = "https://botorch.org"
73+
Documentation = "https://botorch.org"
74+
Repository = "https://github.com/pytorch/botorch"
75+
76+
[tool.setuptools.packages]
77+
find = {exclude = ["test", "test.*"]}
78+
579
[tool.setuptools_scm]
680
local_scheme = "node-and-date"
781
write_to = "./botorch/version.py"
@@ -13,4 +87,4 @@ first_party_detection = false
1387
formatter = "ruff-api"
1488

1589
[tool.coverage.report]
16-
omit = ["test/*", "setup.py"]
90+
omit = ["test/*", "test_community/*"]

requirements.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)