Skip to content

Commit 27f4c0c

Browse files
Balandatfacebook-github-bot
authored andcommitted
Remove deprecated usage of setuptools_scm in setup.py (meta-pytorch#1292)
Summary: This removes the deprecated use of `use_setuptools_scm` in `setup.py` so that we can use newer setuptools versions. Previously we parsed the `USE_SCM_LOCAL_VERSION` env var as part of `setup.py` in order to programmatically set the `local_scheme` setting, but this kind of dynamism is not possible in the pyproject.toml configuration. Instead, we now simply use the `SETUPTOOLS_SCM_PRETEND_VERSION` env var in order to provide a specific version name without the github hash (which we strip from the full name in a bash script). What this means is that for untagged commits, `setuptools_scm` will always create a version string that includes the github hash and date (and overriding this will require to manually specifying the `SETUPTOOLS_SCM_PRETEND_VERSION` env var). Pull Request resolved: meta-pytorch#1292 Reviewed By: saitcakmak Differential Revision: D37720650 Pulled By: Balandat fbshipit-source-id: fdc92670086e9ca586da0d6260e5eb916ff90605
1 parent f5646cb commit 27f4c0c

File tree

4 files changed

+11
-20
lines changed

4 files changed

+11
-20
lines changed

.conda/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ build:
1414
requirements:
1515
host:
1616
- python>=3.7
17-
- setuptools<48 # setup_requires was deprecated in v48.0.0
17+
- setuptools
1818
- setuptools-scm
1919
run:
2020
- pytorch >=1.9

.github/workflows/nightly.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ jobs:
5353
pip install --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
5454
pip install git+https://github.com/cornellius-gp/gpytorch.git
5555
pip install .[test]
56-
pip install --upgrade setuptools wheel
56+
pip install --upgrade setuptools setuptools_scm wheel
5757
- name: Build packages (wheel and source distribution)
58-
env:
59-
SCM_NO_LOCAL_VERSION: true
6058
run: |
59+
# set a pseudo version that strips the commit hash to enable upload to pypi
60+
no_local_version=$(python -m setuptools_scm | cut -d "+" -f 1)
61+
echo "SETUPTOOLS_SCM_PRETEND_VERSION=${no_local_version}" >> $GITHUB_ENV
6162
python setup.py sdist bdist_wheel
6263
- name: Verify packages
63-
env:
64-
SCM_NO_LOCAL_VERSION: true
6564
run: |
65+
# env var SETUPTOOLS_SCM_PRETEND_VERSION persists from previous step
6666
./scripts/build_and_verify_py_packages.sh
6767
- name: Deploy to Test PyPI
6868
uses: pypa/gh-action-pypi-publish@master

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
[tool.setuptools_scm]
2-
31
[build-system]
4-
requires = ["setuptools<48", "wheel", "setuptools-scm"]
2+
requires = ["setuptools", "setuptools-scm", "wheel"]
53
build-backend = "setuptools.build_meta"
64

5+
[tool.setuptools_scm]
6+
local_scheme = "node-and-date"
7+
write_to = "./botorch/version.py"
8+
79
[tool.usort]
810
first_party_detection = false

setup.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,6 @@
7979
long_description=long_description,
8080
long_description_content_type="text/markdown",
8181
python_requires=">=3.7",
82-
setup_requires=["setuptools-scm"],
83-
use_scm_version={
84-
"root": ".",
85-
"relative_to": __file__,
86-
"write_to": os.path.join(root_dir, "botorch", "version.py"),
87-
"local_scheme": (
88-
"no-local-version"
89-
if os.environ.get("SCM_NO_LOCAL_VERSION", False)
90-
else "node-and-date"
91-
),
92-
},
9382
packages=find_packages(exclude=["test", "test.*"]),
9483
install_requires=[
9584
"torch>=1.9",

0 commit comments

Comments
 (0)