Skip to content

Commit cc6f1f8

Browse files
ahornbyfacebook-github-bot
authored andcommitted
sapling getdeps cli build and test support for python 3.12 (#964)
Summary: Ubuntu 24.04 and Fedora 40 are both python 3.12 based. Update sapling's OSS getdeps build to allow build/run/test on python 3.12 while keeping 3.10 support. * distutils is deprecated in python 3.12 stdlib, but fortunately setuptools is pretty similar and includes a vendored distutils, so: * added a manifest so we get python3-setuptools installed. * setup.py: removed deprecated usage like `find_executable` in favor of `shutil.which()`, also removed some super old xcode 4/5.1 detection I found * util.py makedate(): datetime.utcfromtimestamp is deprecated in 3.12, so updated to use non-deprecated methods. Tested with test-command-template.t which shows tz offset. * Makefile: disabled test-eager-exchange.t on 3.12 where updating the expectation to run on 3.12 and 3.10 is tricky (debug output differs) * tests modified to run on 3.12 and 3.10: * test-import-eol.t: updated for invalid escape sequence warnings * test-install.t: updated to filter out message that appears in different order on 3.12 vs earlier versions * test-merge-driver2.t: match different debug output in 3.12, remove check for mercurial package * test-sign-commit.t: updated to add --yes for newer gpg that python 3.12 using distros have * found some tests needed bunzip2, so update manifest for sapling and bz2 to install it Pull Request resolved: #964 X-link: facebook/openzl#1005 Test Plan: sync the code somewhere visible to toolbox: enter ubuntu 24.04 toolbox: `toolbox enter ubuntu-toolbox-24.04 ` make sure system packages are installed `./build/fbcode_builder/getdeps.py install-system-deps --recursive sapling` build sapling getdeps `./build/fbcode_builder/getdeps.py build --allow-system-packages --no-facebook-internal --src-dir=. sapling --project-install-prefix sapling:/` run the tests locally to validate python 3.12 operation: ``` ./build/fbcode_builder/getdeps.py --allow-system-packages test --src-dir=. sapling --num-jobs=64 --project-install-prefix sapling:/ --------------------------------------------------------------------- Skipped 2 tests (missing feature: Mononoke server available): test-fb-ext-remotefilelog-log.t test-fb-ext-remotefilelog-worker.t Skipped 3 tests (missing feature: running tests with fsmonitor): test-fsmonitor-filemerge.t test-fsmonitor-nonutf8-path.t test-rust-hgevents.t Skipped 48 tests (skipped): test-atexit-epipe.t test-casefolding.t test-check-clang-format.t test-check-code.t test-check-fix-code.t test-check-help.t test-checkserverbookmark.t test-chg.t test-commitcloud-sync-omission.t test-committer-date.t test-debugbacktrace.t test-debugshell-namespace.t test-eden-clone.t test-eden-commands.t test-eden-du.t test-eden-glob.t test-eden-sparse.t test-eden-watchman-edenapi-glob.t test-eden-watchman-noedenapi-glob.t test-fb-ext-fbconduit.t test-fb-ext-scm-prompt-compat.t test-fb-ext-scm-prompt-git.t test-fb-ext-tweakdefaults-grep.t test-fsmonitor-casefolding.t test-fsmonitor-fallback.t test-fsmonitor-metadata.t test-fsmonitor-refreshclock.t test-fsmonitor-status.t test-fsmonitor-warn-fresh.t test-histedit-reorder.t test-matcher-expand-globs.t test-mutation-infinitepush.t test-non-working-symlink.t test-progress-rust-renderer.t test-progressfile.t test-purge-fsmonitor.t test-remotenames-journal.t test-runlog.t test-rust-status-in-transaction.t test-sparse-track-ignored.t test-status-case-insensitive.t test-status-fresh-instance.t test-status-root-ignored-py.t test-status-watchman.t test-symlink-migration.t test-tracing-under-chg.t test-treestate-fresh-instance.t test-treestate-trackignore.t # Ran 727 tests, 53 skipped, 0 failed. passed on try 0 ``` generate github actions CI to pick up python3-setuptools ``` ./build/fbcode_builder/getdeps.py --allow-system-packages generate-github-actions --free-up-disk --os-type=linux --src-dir=. --output-dir=.github/workflows --job-name "Sapling CLI Getdeps " --job-file-prefix=sapling-cli-getdeps_ sapling --num-jobs=16 --project-install-prefix sapling:/ ``` github CI Reviewed By: quark-zju, singhsrb Differential Revision: D63958742 Pulled By: ahornby fbshipit-source-id: 460c42eb1315f2e1631c74d356e4976469104c1b
1 parent c97e67f commit cc6f1f8

File tree

14 files changed

+103
-135
lines changed

14 files changed

+103
-135
lines changed

.github/workflows/sapling-cli-getdeps_linux.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ jobs:
7070
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests snappy
7171
- name: Fetch zlib
7272
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests zlib
73+
- name: Fetch python-setuptools
74+
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests python-setuptools
7375
- name: Fetch openssl
7476
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests openssl
7577
- name: Fetch liboqs
@@ -142,6 +144,8 @@ jobs:
142144
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests snappy
143145
- name: Build zlib
144146
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests zlib
147+
- name: Build python-setuptools
148+
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests python-setuptools
145149
- name: Build openssl
146150
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests openssl
147151
- name: Build liboqs

build/fbcode_builder/manifests/bz2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ name = bz2
33

44
[debs]
55
libbz2-dev
6+
bzip2
67

78
[homebrew]
89
bzip2
910

1011
[rpms]
1112
bzip2-devel
13+
bzip2
1214

1315
[download]
1416
url = https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz

build/fbcode_builder/manifests/python-setuptools

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,12 @@ sha256 = 02fa291a0471b3a18b2b2481ed902af520c69e8ae0919c13da936542754b4c56
77

88
[build]
99
builder = python-wheel
10+
11+
[rpms]
12+
python3-setuptools
13+
14+
[homebrew]
15+
python-setuptools
16+
17+
[debs]
18+
python3-setuptools

build/fbcode_builder/manifests/sapling

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ hexdump
6565

6666
[dependencies.not(os=windows)]
6767
python
68+
python-setuptools
6869

6970
# We use the system openssl on linux
7071
[dependencies.not(os=linux)]

eden/integration/lib/find_executables.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
# pyre-strict
1313

14-
import distutils.spawn
1514
import logging
1615
import os
16+
import shutil
1717
import sys
1818
from pathlib import Path
1919
from typing import Any, Callable, Dict, Generic, List, Optional, Tuple, Type, TypeVar
@@ -192,9 +192,7 @@ def DROP_PRIVS(self) -> str:
192192

193193
@cached_property
194194
def GIT(self) -> str:
195-
git = distutils.spawn.find_executable(
196-
"git.real"
197-
) or distutils.spawn.find_executable("git")
195+
git = shutil.which("git.real") or shutil.which("git")
198196
if git is None:
199197
raise Exception("unable to find git binary")
200198
return git
@@ -224,7 +222,7 @@ def _find_hg(self) -> str:
224222
if hg_bin:
225223
return hg_bin
226224

227-
hg_real_bin = distutils.spawn.find_executable("hg")
225+
hg_real_bin = shutil.which("hg")
228226
if hg_real_bin:
229227
return hg_real_bin
230228

@@ -238,11 +236,11 @@ def _find_hg_real(self) -> str:
238236
if hg_real_bin:
239237
return hg_real_bin
240238

241-
hg_real_bin = distutils.spawn.find_executable("hg.real")
239+
hg_real_bin = shutil.which("hg.real")
242240
if hg_real_bin:
243241
return hg_real_bin
244242

245-
hg_real_bin = distutils.spawn.find_executable("hg")
243+
hg_real_bin = shutil.which("hg")
246244
if hg_real_bin:
247245
return hg_real_bin
248246

eden/scm/Makefile

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ PYTHON := python
2121
endif
2222
PYTHON3 := python3
2323

24+
PYTHON_SYS_EXECUTABLE=$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3))
25+
2426
BUCK_BUILD_MODE = @fbcode//mode/opt
2527
ifeq ($(OS),Windows_NT)
2628
BUCK_BUILD_MODE := @fbcode//mode/opt-win
@@ -31,7 +33,7 @@ else
3133
endif
3234
endif
3335

34-
PYTHON_MINOR_VERSION=$(shell $(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) -c "import sys; print(sys.version_info.minor)")
36+
PYTHON_MINOR_VERSION=$(shell $(PYTHON_SYS_EXECUTABLE) -c "import sys; print(sys.version_info.minor)")
3537

3638
ifeq ($(RUST_DEBUG),1)
3739
RUST_FLAG = --debug
@@ -105,7 +107,7 @@ install-oss: oss
105107

106108
local:
107109
SAPLING_OSS_BUILD=$(OSS) HGNAME=$(HGNAME) \
108-
$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) setup.py $(PURE) \
110+
$(PYTHON_SYS_EXECUTABLE) setup.py $(PURE) \
109111
build_interactive_smartlog \
110112
build_clib $(COMPILERFLAG) \
111113
build_rust_ext -i -l $(RUST_FLAG) \
@@ -116,7 +118,7 @@ endif
116118
cp build/scripts-3.$(PYTHON_MINOR_VERSION)/$(HG_BIN_NAME) $(HG_BIN_NAME)
117119

118120
hg:
119-
SAPLING_SKIP_OTHER_RUST_BINARIES=true $(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) setup.py $(PURE) \
121+
SAPLING_SKIP_OTHER_RUST_BINARIES=true $(PYTHON_SYS_EXECUTABLE) setup.py $(PURE) \
120122
build_clib $(COMPILERFLAG) \
121123
build_rust_ext -i -l $(RUST_FLAG) \
122124
build_mo
@@ -145,9 +147,9 @@ getdepsbuild:
145147
mkdir -p $(GETDEPS_BUILD_DIR)/sapling
146148
ln -sfn $(GETDEPS_BUILD_DIR)/sapling build
147149
HGNAME=$(HGNAME) GETDEPS_BUILD=1 \
148-
PYTHON_SYS_EXECUTABLE=$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) \
150+
PYTHON_SYS_EXECUTABLE=$(PYTHON_SYS_EXECUTABLE) \
149151
THRIFT="$(GETDEPS_INSTALL_DIR)/fbthrift/bin/thrift1" \
150-
$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) setup.py \
152+
$(PYTHON_SYS_EXECUTABLE) setup.py \
151153
$(PURE) build $(COMPILERFLAG)
152154

153155
cleanbutpackages:
@@ -176,8 +178,8 @@ install-home: build
176178
$(PYTHON) setup.py $(PURE) install --home="$(HOME)" --prefix="" --force
177179

178180
install-getdeps:
179-
PYTHON_SYS_EXECUTABLE=$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) \
180-
GETDEPS_BUILD=1 $(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) \
181+
PYTHON_SYS_EXECUTABLE=$(PYTHON_SYS_EXECUTABLE) \
182+
GETDEPS_BUILD=1 $(PYTHON_SYS_EXECUTABLE) \
181183
setup.py $(PURE) install --skip-build --prefix="$(PREFIX)" --install-scripts="$(PREFIX)/bin" --install-lib="$(PREFIX)/bin" --force && \
182184
cd "$(PREFIX)/bin" && ln -f "$(SL_BIN_NAME)" "$(HG_BIN_NAME)"
183185

@@ -218,7 +220,13 @@ GETDEPS_TEST_EXCLUSION_LIST := test-cats.t \
218220
test-rust-checkout.t \
219221
test-smartlog-interactive.t \
220222
test-smartlog-interactive-highlighting.t
221-
223+
224+
ifeq ($(PYTHON_MINOR_VERSION),12)
225+
# output differs for these on 3.12 in ways that are hard to match for 3.10 and 3.12 simultaneously
226+
GETDEPS_TEST_EXCLUSION_LIST := $(GETDEPS_TEST_EXCLUSION_LIST) \
227+
test-eager-exchange.t
228+
endif
229+
222230
# convert to a sed expression
223231
GETDEPS_TEST_EXCLUSIONS := $(subst $() $(),|,$(GETDEPS_TEST_EXCLUSION_LIST))
224232

@@ -230,14 +238,14 @@ test-getdeps:
230238
# ensure that fbpython is present, as some tests depend on it being on PATH
231239
if ! which fbpython >/dev/null 2>&1; then \
232240
FBPYTHON="$(GETDEPS_INSTALL_DIR)/sapling/bin/fbpython"; \
233-
PYTHON_SYS_EXECUTABLE=$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)); \
241+
PYTHON_SYS_EXECUTABLE=$(PYTHON_SYS_EXECUTABLE); \
234242
printf "#!/bin/sh\nexec \"$$PYTHON_SYS_EXECUTABLE\" \"\$$@\"\n" > $$FBPYTHON; \
235243
chmod +x "$$FBPYTHON"; \
236244
fi;
237245
# Run tests and retry any failures
238246
export GETDEPS_BUILD=1; \
239247
export HGTEST_HG=$(GETDEPS_INSTALL_DIR)/sapling/bin/$(HG_BIN_NAME); \
240-
cd tests && export PYTHON_SYS_EXECUTABLE=$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)); \
248+
cd tests && export PYTHON_SYS_EXECUTABLE=$(PYTHON_SYS_EXECUTABLE); \
241249
for try in $$(seq 0 $(GETDEPS_TEST_RETRY)); do \
242250
RERUN_ARG=""; \
243251
GETDEPS_TEST_FILTER=$(GETDEPS_TEST_FILTER); \
@@ -260,8 +268,8 @@ check: tests
260268

261269
.PHONY: tests
262270
tests:
263-
cd tests && PYTHON_SYS_EXECUTABLE=$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) \
264-
$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) run-tests.py
271+
cd tests && PYTHON_SYS_EXECUTABLE=$(PYTHON_SYS_EXECUTABLE) \
272+
$(PYTHON_SYS_EXECUTABLE) run-tests.py
265273

266274
update-pot: i18n/hg.pot
267275

eden/scm/contrib/check-code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def rephere(m):
415415

416416
txtpats = [
417417
[
418-
("\s$", "trailing whitespace"),
418+
("\\s$", "trailing whitespace"),
419419
(".. note::[ \n][^\n]", "add two newlines after note::"),
420420
],
421421
[],

0 commit comments

Comments
 (0)