sapling/eden/scm/Makefile

216 lines
7.4 KiB
Makefile
Raw Normal View History

# Portions Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# Copyright Olivia Mackall <olivia@selenic.com> and others
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
# If you want to change PREFIX, do not just edit it below. The changed
# value wont get passed on to recursive make calls. You should instead
# override the variable on the command like:
#
# % make PREFIX=/opt/ install
export PREFIX=/usr/local
ifeq ($(OS),Windows_NT)
PYTHON := python
else
PYTHON := python2
endif
PYTHON3 := python3
ifeq ($(RUST_DEBUG),1)
RUST_FLAG = --debug
endif
$(eval HGROOT := $(shell pwd))
HGPYTHONS ?= $(HGROOT)/build/pythons
2009-01-24 03:47:36 +03:00
PURE=
PYFILES:=$(shell find mercurial ext -name '*.py' 2>/dev/null)
DOCFILES=edenscm/help/*.txt
export LANGUAGE=C
export LC_ALL=C
TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
OSXVERSIONFLAGS ?= $(shell echo $$OSXVERSIONFLAGS)
HGNAME ?= hg
SL_NAME = sl
# Set this to e.g. "mingw32" to use a non-default compiler.
COMPILER=
COMPILERFLAG_tmp_ =
COMPILERFLAG_tmp_${COMPILER} ?= -c $(COMPILER)
COMPILERFLAG=${COMPILERFLAG_tmp_${COMPILER}}
# Mac Big Sur doesn't find the standard library without this.
export SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
help:
@echo 'Commonly used make targets:'
@echo ' all - build program'
@echo ' install - install program and man pages to $$PREFIX ($(PREFIX))'
setup: merge setup*.py back to setup.py Summary: It's weird to have `setup_with_versions.py` as the entry point and have noisy files in the project root. For example, upstream hg has tests to track files in project root (https://www.mercurial-scm.org/repo/hg/file/c261a628e525/tests/test-check-code.t#l54) Let's move them back to setup.py. This is basically a revert of D40983642 (https://github.com/facebook/sapling/commit/a2eaef5617a49d717443bb78c47b00dff83cfa79), followed by: ``` diff --git a/fbcode/eden/scm/setup.py b/fbcode/eden/scm/setup.py --- a/fbcode/eden/scm/setup.py +++ b/fbcode/eden/scm/setup.py @@ -386,9 +386,13 @@ def pickversion(): + # Respect SAPLING_VERSION set by GitHub workflows. + version = os.environ.get("SAPLING_VERSION") + if version: + return version # New version system: YYMMDD_HHmmSS_hash # This is duplicated a bit from build_rpm.py:auto_release_str() - template = '{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' + template = r'{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' # if hg is not found, fallback to a fixed version out = hgtemplate(template) or "" # Some tools parse this number to figure out if they support this version of @@ -1829,6 +1833,10 @@ rename=hgname, features=hgmainfeatures, cfgs=["Py_%s" % PY_VERSION], + env={ + "SAPLING_VERSION": version, + "SAPLING_VERSION_HASH": versionhash, + }, ), ] ``` The `SAPLING_VERSION` env is only passed to `cargo`. It does not affect the current process. This also avoids overhead launching another Python process (previously by `setup_with_version.py`) Reviewed By: bolinfest Differential Revision: D41640370 fbshipit-source-id: 01bd37de7c6dcd1238171c1736137edd82bc07db
2022-12-01 23:30:00 +03:00
@echo ' install-home - install with setup.py install --home=$$HOME ($(HOME))'
@echo ' local - build for inplace usage'
@echo ' tests - run all tests in the automatic test suite'
@echo ' test-foo - run only specified tests (e.g. test-merge1.t)'
@echo ' dist - run all tests and create a source tarball in dist/'
@echo ' clean - remove files created by other targets'
@echo ' (except installed files or dist source tarball)'
@echo ' update-pot - update i18n/hg.pot'
@echo
@echo 'Example for a system-wide installation under /usr/local:'
@echo ' make all && su -c "make install" && hg version'
@echo
@echo 'Example for a local installation (usable in this directory):'
@echo ' make local && ./hg version'
all: build
oss:
SAPLING_OSS_BUILD=true HGNAME=$(SL_NAME) \
setup: merge setup*.py back to setup.py Summary: It's weird to have `setup_with_versions.py` as the entry point and have noisy files in the project root. For example, upstream hg has tests to track files in project root (https://www.mercurial-scm.org/repo/hg/file/c261a628e525/tests/test-check-code.t#l54) Let's move them back to setup.py. This is basically a revert of D40983642 (https://github.com/facebook/sapling/commit/a2eaef5617a49d717443bb78c47b00dff83cfa79), followed by: ``` diff --git a/fbcode/eden/scm/setup.py b/fbcode/eden/scm/setup.py --- a/fbcode/eden/scm/setup.py +++ b/fbcode/eden/scm/setup.py @@ -386,9 +386,13 @@ def pickversion(): + # Respect SAPLING_VERSION set by GitHub workflows. + version = os.environ.get("SAPLING_VERSION") + if version: + return version # New version system: YYMMDD_HHmmSS_hash # This is duplicated a bit from build_rpm.py:auto_release_str() - template = '{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' + template = r'{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' # if hg is not found, fallback to a fixed version out = hgtemplate(template) or "" # Some tools parse this number to figure out if they support this version of @@ -1829,6 +1833,10 @@ rename=hgname, features=hgmainfeatures, cfgs=["Py_%s" % PY_VERSION], + env={ + "SAPLING_VERSION": version, + "SAPLING_VERSION_HASH": versionhash, + }, ), ] ``` The `SAPLING_VERSION` env is only passed to `cargo`. It does not affect the current process. This also avoids overhead launching another Python process (previously by `setup_with_version.py`) Reviewed By: bolinfest Differential Revision: D41640370 fbshipit-source-id: 01bd37de7c6dcd1238171c1736137edd82bc07db
2022-12-01 23:30:00 +03:00
$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) setup.py $(PURE) \
build_interactive_smartlog \
build_py -c -d . \
build_clib $(COMPILERFLAG) \
build_ext $(COMPILERFLAG) -i \
build_rust_ext -i -l $(RUST_FLAG) \
build_pyzip -i \
build_mo
ifeq ($(OS),Windows_NT)
cp build/scripts-3*/$(SL_NAME).exe $(SL_NAME).exe
else
$(RM) $(SL_NAME)
cp build/scripts-3*/$(SL_NAME) $(SL_NAME)
endif
install-oss: oss
SAPLING_OSS_BUILD=true HGNAME=$(SL_NAME) \
setup: merge setup*.py back to setup.py Summary: It's weird to have `setup_with_versions.py` as the entry point and have noisy files in the project root. For example, upstream hg has tests to track files in project root (https://www.mercurial-scm.org/repo/hg/file/c261a628e525/tests/test-check-code.t#l54) Let's move them back to setup.py. This is basically a revert of D40983642 (https://github.com/facebook/sapling/commit/a2eaef5617a49d717443bb78c47b00dff83cfa79), followed by: ``` diff --git a/fbcode/eden/scm/setup.py b/fbcode/eden/scm/setup.py --- a/fbcode/eden/scm/setup.py +++ b/fbcode/eden/scm/setup.py @@ -386,9 +386,13 @@ def pickversion(): + # Respect SAPLING_VERSION set by GitHub workflows. + version = os.environ.get("SAPLING_VERSION") + if version: + return version # New version system: YYMMDD_HHmmSS_hash # This is duplicated a bit from build_rpm.py:auto_release_str() - template = '{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' + template = r'{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' # if hg is not found, fallback to a fixed version out = hgtemplate(template) or "" # Some tools parse this number to figure out if they support this version of @@ -1829,6 +1833,10 @@ rename=hgname, features=hgmainfeatures, cfgs=["Py_%s" % PY_VERSION], + env={ + "SAPLING_VERSION": version, + "SAPLING_VERSION_HASH": versionhash, + }, ), ] ``` The `SAPLING_VERSION` env is only passed to `cargo`. It does not affect the current process. This also avoids overhead launching another Python process (previously by `setup_with_version.py`) Reviewed By: bolinfest Differential Revision: D41640370 fbshipit-source-id: 01bd37de7c6dcd1238171c1736137edd82bc07db
2022-12-01 23:30:00 +03:00
$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) setup.py $(PURE) \
install --root="$(DESTDIR)/" --prefix="$(PREFIX)" \
--install-lib="$(PREFIX)"/lib/python3.$(shell $(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) -c "import sys; print(sys.version_info.minor)")/site-packages \
--install-scripts="$(PREFIX)/bin" --force
local:
setup: merge setup*.py back to setup.py Summary: It's weird to have `setup_with_versions.py` as the entry point and have noisy files in the project root. For example, upstream hg has tests to track files in project root (https://www.mercurial-scm.org/repo/hg/file/c261a628e525/tests/test-check-code.t#l54) Let's move them back to setup.py. This is basically a revert of D40983642 (https://github.com/facebook/sapling/commit/a2eaef5617a49d717443bb78c47b00dff83cfa79), followed by: ``` diff --git a/fbcode/eden/scm/setup.py b/fbcode/eden/scm/setup.py --- a/fbcode/eden/scm/setup.py +++ b/fbcode/eden/scm/setup.py @@ -386,9 +386,13 @@ def pickversion(): + # Respect SAPLING_VERSION set by GitHub workflows. + version = os.environ.get("SAPLING_VERSION") + if version: + return version # New version system: YYMMDD_HHmmSS_hash # This is duplicated a bit from build_rpm.py:auto_release_str() - template = '{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' + template = r'{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' # if hg is not found, fallback to a fixed version out = hgtemplate(template) or "" # Some tools parse this number to figure out if they support this version of @@ -1829,6 +1833,10 @@ rename=hgname, features=hgmainfeatures, cfgs=["Py_%s" % PY_VERSION], + env={ + "SAPLING_VERSION": version, + "SAPLING_VERSION_HASH": versionhash, + }, ), ] ``` The `SAPLING_VERSION` env is only passed to `cargo`. It does not affect the current process. This also avoids overhead launching another Python process (previously by `setup_with_version.py`) Reviewed By: bolinfest Differential Revision: D41640370 fbshipit-source-id: 01bd37de7c6dcd1238171c1736137edd82bc07db
2022-12-01 23:30:00 +03:00
$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) setup.py $(PURE) \
build_py -c -d . \
build_clib $(COMPILERFLAG) \
build_ext $(COMPILERFLAG) -i \
build_rust_ext -i -l $(RUST_FLAG) \
build_pyzip -i \
build_mo
ifeq ($(OS),Windows_NT)
cp build/scripts-3*/$(HGNAME).exe $(HGNAME).exe
else
$(RM) $(HGNAME)
cp build/scripts-3*/$(HGNAME) $(HGNAME)
endif
build:
setup: merge setup*.py back to setup.py Summary: It's weird to have `setup_with_versions.py` as the entry point and have noisy files in the project root. For example, upstream hg has tests to track files in project root (https://www.mercurial-scm.org/repo/hg/file/c261a628e525/tests/test-check-code.t#l54) Let's move them back to setup.py. This is basically a revert of D40983642 (https://github.com/facebook/sapling/commit/a2eaef5617a49d717443bb78c47b00dff83cfa79), followed by: ``` diff --git a/fbcode/eden/scm/setup.py b/fbcode/eden/scm/setup.py --- a/fbcode/eden/scm/setup.py +++ b/fbcode/eden/scm/setup.py @@ -386,9 +386,13 @@ def pickversion(): + # Respect SAPLING_VERSION set by GitHub workflows. + version = os.environ.get("SAPLING_VERSION") + if version: + return version # New version system: YYMMDD_HHmmSS_hash # This is duplicated a bit from build_rpm.py:auto_release_str() - template = '{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' + template = r'{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' # if hg is not found, fallback to a fixed version out = hgtemplate(template) or "" # Some tools parse this number to figure out if they support this version of @@ -1829,6 +1833,10 @@ rename=hgname, features=hgmainfeatures, cfgs=["Py_%s" % PY_VERSION], + env={ + "SAPLING_VERSION": version, + "SAPLING_VERSION_HASH": versionhash, + }, ), ] ``` The `SAPLING_VERSION` env is only passed to `cargo`. It does not affect the current process. This also avoids overhead launching another Python process (previously by `setup_with_version.py`) Reviewed By: bolinfest Differential Revision: D41640370 fbshipit-source-id: 01bd37de7c6dcd1238171c1736137edd82bc07db
2022-12-01 23:30:00 +03:00
$(PYTHON) setup.py $(PURE) build $(COMPILERFLAG)
deb:
write "Depends" into .deb and build for Python 3.10 on Ubuntu 22.04 Summary: Although D39042765 (https://github.com/facebookexperimental/eden/commit/a04fc2e9b3a3304af123b68bd4ce01f4d566e875) appeared to successfully produce `.deb` files, it turns out that they would only work if you already had the requisite package dependencies installed. For example, running `hg --version` on a clean Ubuntu instance would yield: ``` hg: error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory ``` It turned out that our `DEBIAN/control` file was missing a key `Depends:` line to tell `dpkg` what dependencies to install. Once again, I decided to look and see how wezterm deals with this, and the solution appears to be `dpkg-shlibdeps`: https://github.com/wez/wezterm/blob/97eaa58112a4/ci/deploy.sh#L234,L240 `dpkg-shlibdeps` looks at your executables and, based on the symbols, determines what the appropriate packages are. For our Ubuntu 22.04 `.deb`, this turns out to be: ``` Depends: libc6 (>= 2.34), libgcc-s1 (>= 4.2), libpython3.10 (>= 3.10.0), libssl3 (>= 3.0.0~~alpha1), zlib1g (>= 1:1.1.4) ``` Apparently you cannot have a package in the `Depends:` line that comes from a PPA, so if you want to make your `.deb` easy for users to install, that means you should limit your dependencies to "standard" packages for the distro. In our case, that meant that our Ubuntu 22.04 `.deb` should use Python 3.10 instead of Python 3.8 (which we previously fetched from `ppa:deadsnakes/ppa`). In order to support this, this diff makes a number of changes: - Adds logic to `setup.py` to check the `PY_VERSION` environment variable to decide whether to use Python 3.10 or something else. - Updates `gen_workflows.py` to define different Python deps based on the Ubuntu version. - Updates `gen_workflows.py` to remove the logic that uses the `ppa:deadsnakes/ppa`. - Ran `buck2 run //eden/oss/ci:gen_workflows -- eden/oss/.github/workflows/` to update the GitHub Actions - Moved the logic for the `deb` target in the `Makefile` into a separate shell script because it was getting too complex to express directly in Make. - Introduced separate `deb-ubuntu-20.04` and `deb-ubuntu-22.04` targets in the `Makefile`. - Updated `bytearrayobject.rs` to support Python 3.10 in addition to Python 3.9. - Updated `pick_python.py` to consider `python3.10` if `python3.8` is not found before going down the rest of the list. As you can see in the Test Plan, we are *really close* to things "just working," but we also have to register `git` as a dependency, which is not discovered by `dpkg-shlibdeps`. This will be addressed in D39156794. Reviewed By: DurhamG Differential Revision: D39156794 fbshipit-source-id: ca1e0a73096e0de97230804a97f316114b8bfc2e
2022-09-01 01:00:05 +03:00
./packaging/debian/build_deb.sh
rpm:
rpmbuild \
--define "sapling_root `pwd`" \
--define "version $(VERSION)" \
-bb packaging/rpm/sapling.spec
2015-10-09 20:30:46 +03:00
wheel:
setup: merge setup*.py back to setup.py Summary: It's weird to have `setup_with_versions.py` as the entry point and have noisy files in the project root. For example, upstream hg has tests to track files in project root (https://www.mercurial-scm.org/repo/hg/file/c261a628e525/tests/test-check-code.t#l54) Let's move them back to setup.py. This is basically a revert of D40983642 (https://github.com/facebook/sapling/commit/a2eaef5617a49d717443bb78c47b00dff83cfa79), followed by: ``` diff --git a/fbcode/eden/scm/setup.py b/fbcode/eden/scm/setup.py --- a/fbcode/eden/scm/setup.py +++ b/fbcode/eden/scm/setup.py @@ -386,9 +386,13 @@ def pickversion(): + # Respect SAPLING_VERSION set by GitHub workflows. + version = os.environ.get("SAPLING_VERSION") + if version: + return version # New version system: YYMMDD_HHmmSS_hash # This is duplicated a bit from build_rpm.py:auto_release_str() - template = '{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' + template = r'{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' # if hg is not found, fallback to a fixed version out = hgtemplate(template) or "" # Some tools parse this number to figure out if they support this version of @@ -1829,6 +1833,10 @@ rename=hgname, features=hgmainfeatures, cfgs=["Py_%s" % PY_VERSION], + env={ + "SAPLING_VERSION": version, + "SAPLING_VERSION_HASH": versionhash, + }, ), ] ``` The `SAPLING_VERSION` env is only passed to `cargo`. It does not affect the current process. This also avoids overhead launching another Python process (previously by `setup_with_version.py`) Reviewed By: bolinfest Differential Revision: D41640370 fbshipit-source-id: 01bd37de7c6dcd1238171c1736137edd82bc07db
2022-12-01 23:30:00 +03:00
FORCE_SETUPTOOLS=1 $(PYTHON) setup.py $(PURE) bdist_wheel $(COMPILERFLAG)
2015-10-09 20:30:46 +03:00
getdepsbuild:
mkdir -p $(GETDEPS_BUILD_DIR)/eden_scm
ln -sfn $(GETDEPS_BUILD_DIR)/eden_scm build
GETDEPS_BUILD=1 \
PYTHON_SYS_EXECUTABLE=$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) \
THRIFT="$(GETDEPS_INSTALL_DIR)/fbthrift/bin/thrift1" \
setup: merge setup*.py back to setup.py Summary: It's weird to have `setup_with_versions.py` as the entry point and have noisy files in the project root. For example, upstream hg has tests to track files in project root (https://www.mercurial-scm.org/repo/hg/file/c261a628e525/tests/test-check-code.t#l54) Let's move them back to setup.py. This is basically a revert of D40983642 (https://github.com/facebook/sapling/commit/a2eaef5617a49d717443bb78c47b00dff83cfa79), followed by: ``` diff --git a/fbcode/eden/scm/setup.py b/fbcode/eden/scm/setup.py --- a/fbcode/eden/scm/setup.py +++ b/fbcode/eden/scm/setup.py @@ -386,9 +386,13 @@ def pickversion(): + # Respect SAPLING_VERSION set by GitHub workflows. + version = os.environ.get("SAPLING_VERSION") + if version: + return version # New version system: YYMMDD_HHmmSS_hash # This is duplicated a bit from build_rpm.py:auto_release_str() - template = '{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' + template = r'{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' # if hg is not found, fallback to a fixed version out = hgtemplate(template) or "" # Some tools parse this number to figure out if they support this version of @@ -1829,6 +1833,10 @@ rename=hgname, features=hgmainfeatures, cfgs=["Py_%s" % PY_VERSION], + env={ + "SAPLING_VERSION": version, + "SAPLING_VERSION_HASH": versionhash, + }, ), ] ``` The `SAPLING_VERSION` env is only passed to `cargo`. It does not affect the current process. This also avoids overhead launching another Python process (previously by `setup_with_version.py`) Reviewed By: bolinfest Differential Revision: D41640370 fbshipit-source-id: 01bd37de7c6dcd1238171c1736137edd82bc07db
2022-12-01 23:30:00 +03:00
$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) setup.py \
$(PURE) build $(COMPILERFLAG)
eden/scm: provide getdeps.py way of building eden/scm on GitHub Summary: In order to do what the title says, this diff does: 1. Add the `eden/oss/.../third-party/rust/.../Cargo.toml` files. As mentioned in the previous diff, those are required by GitHub so that the third party dependencies that are local in fbsource are properly defined with a "git" dependency in order for Cargo to "link" crates properly. 2. Changes to `eden/scm/Makefile` to add build/install commands for getdeps to invoke. Those command knowing that they are called from withing getdeps context they link the dependencies brought by getdeps into their proper places that match their folder layout in fbsource. Those Makefile commands also pass a GETDEPS_BUILD env to the setup.py invocations so that it knows it is being called withing a getdeps build. 3. Changes to `eden/scm/setup.py` that add "thriftasset" that makes use of the getdeps.py provided "thrift" binary to build .py files out of thrift files. 4. Changes to `distutils_rust` to use the vendored crates dir provided by getdeps. 5. Changes to `getdeps/builder.py` and `getdeps/manifest.py` that enable more fine-grained configuratior of how Makefile builds are invoked. 6. Changes to `getdeps/buildopts.py` and `getdeps/manifest.py` to disable overriding PATH and pkgconfig env, so that "eden/scm" builds in getdeps using system libraries rather than getdeps-provided ones (NOTE: I've tried to use getdeps provided libraries, but the trickiest bit was that Rust links with Python, which is currently not providable by getdeps, so if you try to build everything the system provided Python libraries will collide with getdeps provided ones) 7. Added `opensource/fbcode_builder/manifests/eden_scm` for the getdeps build. Reviewed By: quark-zju Differential Revision: D22336485 fbshipit-source-id: 244d10c9e06ee83de61e97e62a1f2a2184d2312f
2020-07-03 03:52:20 +03:00
cleanbutpackages:
setup: merge setup*.py back to setup.py Summary: It's weird to have `setup_with_versions.py` as the entry point and have noisy files in the project root. For example, upstream hg has tests to track files in project root (https://www.mercurial-scm.org/repo/hg/file/c261a628e525/tests/test-check-code.t#l54) Let's move them back to setup.py. This is basically a revert of D40983642 (https://github.com/facebook/sapling/commit/a2eaef5617a49d717443bb78c47b00dff83cfa79), followed by: ``` diff --git a/fbcode/eden/scm/setup.py b/fbcode/eden/scm/setup.py --- a/fbcode/eden/scm/setup.py +++ b/fbcode/eden/scm/setup.py @@ -386,9 +386,13 @@ def pickversion(): + # Respect SAPLING_VERSION set by GitHub workflows. + version = os.environ.get("SAPLING_VERSION") + if version: + return version # New version system: YYMMDD_HHmmSS_hash # This is duplicated a bit from build_rpm.py:auto_release_str() - template = '{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' + template = r'{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' # if hg is not found, fallback to a fixed version out = hgtemplate(template) or "" # Some tools parse this number to figure out if they support this version of @@ -1829,6 +1833,10 @@ rename=hgname, features=hgmainfeatures, cfgs=["Py_%s" % PY_VERSION], + env={ + "SAPLING_VERSION": version, + "SAPLING_VERSION_HASH": versionhash, + }, ), ] ``` The `SAPLING_VERSION` env is only passed to `cargo`. It does not affect the current process. This also avoids overhead launching another Python process (previously by `setup_with_version.py`) Reviewed By: bolinfest Differential Revision: D41640370 fbshipit-source-id: 01bd37de7c6dcd1238171c1736137edd82bc07db
2022-12-01 23:30:00 +03:00
-$(PYTHON3) setup.py clean --all # ignore errors from this command
find contrib doc i18n edenscm edenscmnative tests \
2013-11-15 03:17:44 +04:00
\( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
rm -f MANIFEST MANIFEST.in edenscm/ext/__index__.py tests/*.err
rm -f edenscm/__modulepolicy__.py
if test -d .hg; then rm -f edenscm/__version__.py; fi
rm -rf build/*
rm -rf build edenscm/locale
ifeq ($(OS),Windows_NT)
$(RM) -r hg-python $(HGNAME).exe python27.dll
else
$(RM) $(HGNAME)
endif
clean: cleanbutpackages
rm -rf packages
install: build
setup: merge setup*.py back to setup.py Summary: It's weird to have `setup_with_versions.py` as the entry point and have noisy files in the project root. For example, upstream hg has tests to track files in project root (https://www.mercurial-scm.org/repo/hg/file/c261a628e525/tests/test-check-code.t#l54) Let's move them back to setup.py. This is basically a revert of D40983642 (https://github.com/facebook/sapling/commit/a2eaef5617a49d717443bb78c47b00dff83cfa79), followed by: ``` diff --git a/fbcode/eden/scm/setup.py b/fbcode/eden/scm/setup.py --- a/fbcode/eden/scm/setup.py +++ b/fbcode/eden/scm/setup.py @@ -386,9 +386,13 @@ def pickversion(): + # Respect SAPLING_VERSION set by GitHub workflows. + version = os.environ.get("SAPLING_VERSION") + if version: + return version # New version system: YYMMDD_HHmmSS_hash # This is duplicated a bit from build_rpm.py:auto_release_str() - template = '{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' + template = r'{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' # if hg is not found, fallback to a fixed version out = hgtemplate(template) or "" # Some tools parse this number to figure out if they support this version of @@ -1829,6 +1833,10 @@ rename=hgname, features=hgmainfeatures, cfgs=["Py_%s" % PY_VERSION], + env={ + "SAPLING_VERSION": version, + "SAPLING_VERSION_HASH": versionhash, + }, ), ] ``` The `SAPLING_VERSION` env is only passed to `cargo`. It does not affect the current process. This also avoids overhead launching another Python process (previously by `setup_with_version.py`) Reviewed By: bolinfest Differential Revision: D41640370 fbshipit-source-id: 01bd37de7c6dcd1238171c1736137edd82bc07db
2022-12-01 23:30:00 +03:00
$(PYTHON) setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --force
install-home: build
setup: merge setup*.py back to setup.py Summary: It's weird to have `setup_with_versions.py` as the entry point and have noisy files in the project root. For example, upstream hg has tests to track files in project root (https://www.mercurial-scm.org/repo/hg/file/c261a628e525/tests/test-check-code.t#l54) Let's move them back to setup.py. This is basically a revert of D40983642 (https://github.com/facebook/sapling/commit/a2eaef5617a49d717443bb78c47b00dff83cfa79), followed by: ``` diff --git a/fbcode/eden/scm/setup.py b/fbcode/eden/scm/setup.py --- a/fbcode/eden/scm/setup.py +++ b/fbcode/eden/scm/setup.py @@ -386,9 +386,13 @@ def pickversion(): + # Respect SAPLING_VERSION set by GitHub workflows. + version = os.environ.get("SAPLING_VERSION") + if version: + return version # New version system: YYMMDD_HHmmSS_hash # This is duplicated a bit from build_rpm.py:auto_release_str() - template = '{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' + template = r'{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' # if hg is not found, fallback to a fixed version out = hgtemplate(template) or "" # Some tools parse this number to figure out if they support this version of @@ -1829,6 +1833,10 @@ rename=hgname, features=hgmainfeatures, cfgs=["Py_%s" % PY_VERSION], + env={ + "SAPLING_VERSION": version, + "SAPLING_VERSION_HASH": versionhash, + }, ), ] ``` The `SAPLING_VERSION` env is only passed to `cargo`. It does not affect the current process. This also avoids overhead launching another Python process (previously by `setup_with_version.py`) Reviewed By: bolinfest Differential Revision: D41640370 fbshipit-source-id: 01bd37de7c6dcd1238171c1736137edd82bc07db
2022-12-01 23:30:00 +03:00
$(PYTHON) setup.py $(PURE) install --home="$(HOME)" --prefix="" --force
eden/scm: provide getdeps.py way of building eden/scm on GitHub Summary: In order to do what the title says, this diff does: 1. Add the `eden/oss/.../third-party/rust/.../Cargo.toml` files. As mentioned in the previous diff, those are required by GitHub so that the third party dependencies that are local in fbsource are properly defined with a "git" dependency in order for Cargo to "link" crates properly. 2. Changes to `eden/scm/Makefile` to add build/install commands for getdeps to invoke. Those command knowing that they are called from withing getdeps context they link the dependencies brought by getdeps into their proper places that match their folder layout in fbsource. Those Makefile commands also pass a GETDEPS_BUILD env to the setup.py invocations so that it knows it is being called withing a getdeps build. 3. Changes to `eden/scm/setup.py` that add "thriftasset" that makes use of the getdeps.py provided "thrift" binary to build .py files out of thrift files. 4. Changes to `distutils_rust` to use the vendored crates dir provided by getdeps. 5. Changes to `getdeps/builder.py` and `getdeps/manifest.py` that enable more fine-grained configuratior of how Makefile builds are invoked. 6. Changes to `getdeps/buildopts.py` and `getdeps/manifest.py` to disable overriding PATH and pkgconfig env, so that "eden/scm" builds in getdeps using system libraries rather than getdeps-provided ones (NOTE: I've tried to use getdeps provided libraries, but the trickiest bit was that Rust links with Python, which is currently not providable by getdeps, so if you try to build everything the system provided Python libraries will collide with getdeps provided ones) 7. Added `opensource/fbcode_builder/manifests/eden_scm` for the getdeps build. Reviewed By: quark-zju Differential Revision: D22336485 fbshipit-source-id: 244d10c9e06ee83de61e97e62a1f2a2184d2312f
2020-07-03 03:52:20 +03:00
install-getdeps: getdepsbuild
PYTHON_SYS_EXECUTABLE=$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) \
GETDEPS_BUILD=1 $(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) \
setup: merge setup*.py back to setup.py Summary: It's weird to have `setup_with_versions.py` as the entry point and have noisy files in the project root. For example, upstream hg has tests to track files in project root (https://www.mercurial-scm.org/repo/hg/file/c261a628e525/tests/test-check-code.t#l54) Let's move them back to setup.py. This is basically a revert of D40983642 (https://github.com/facebook/sapling/commit/a2eaef5617a49d717443bb78c47b00dff83cfa79), followed by: ``` diff --git a/fbcode/eden/scm/setup.py b/fbcode/eden/scm/setup.py --- a/fbcode/eden/scm/setup.py +++ b/fbcode/eden/scm/setup.py @@ -386,9 +386,13 @@ def pickversion(): + # Respect SAPLING_VERSION set by GitHub workflows. + version = os.environ.get("SAPLING_VERSION") + if version: + return version # New version system: YYMMDD_HHmmSS_hash # This is duplicated a bit from build_rpm.py:auto_release_str() - template = '{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' + template = r'{sub("([:+-]|\d\d\d\d$)", "",date|isodatesec)} {node|short}' # if hg is not found, fallback to a fixed version out = hgtemplate(template) or "" # Some tools parse this number to figure out if they support this version of @@ -1829,6 +1833,10 @@ rename=hgname, features=hgmainfeatures, cfgs=["Py_%s" % PY_VERSION], + env={ + "SAPLING_VERSION": version, + "SAPLING_VERSION_HASH": versionhash, + }, ), ] ``` The `SAPLING_VERSION` env is only passed to `cargo`. It does not affect the current process. This also avoids overhead launching another Python process (previously by `setup_with_version.py`) Reviewed By: bolinfest Differential Revision: D41640370 fbshipit-source-id: 01bd37de7c6dcd1238171c1736137edd82bc07db
2022-12-01 23:30:00 +03:00
setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --install-lib="$(PREFIX)/bin" --force
test-getdeps: install-getdeps
# Run one test to check the binary is minimally good as will be used later in Mononoke getdeps tests
# Running all the tests requires a bit of filtering to run the good set (or deleting flaky ones)
cd tests && PYTHON_SYS_EXECUTABLE=$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) \
$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) run-tests.py -j1 --getdeps-build --with-hg="$(PREFIX)/bin/$(HGNAME)" test-status.t test-convert.t
eden/scm: provide getdeps.py way of building eden/scm on GitHub Summary: In order to do what the title says, this diff does: 1. Add the `eden/oss/.../third-party/rust/.../Cargo.toml` files. As mentioned in the previous diff, those are required by GitHub so that the third party dependencies that are local in fbsource are properly defined with a "git" dependency in order for Cargo to "link" crates properly. 2. Changes to `eden/scm/Makefile` to add build/install commands for getdeps to invoke. Those command knowing that they are called from withing getdeps context they link the dependencies brought by getdeps into their proper places that match their folder layout in fbsource. Those Makefile commands also pass a GETDEPS_BUILD env to the setup.py invocations so that it knows it is being called withing a getdeps build. 3. Changes to `eden/scm/setup.py` that add "thriftasset" that makes use of the getdeps.py provided "thrift" binary to build .py files out of thrift files. 4. Changes to `distutils_rust` to use the vendored crates dir provided by getdeps. 5. Changes to `getdeps/builder.py` and `getdeps/manifest.py` that enable more fine-grained configuratior of how Makefile builds are invoked. 6. Changes to `getdeps/buildopts.py` and `getdeps/manifest.py` to disable overriding PATH and pkgconfig env, so that "eden/scm" builds in getdeps using system libraries rather than getdeps-provided ones (NOTE: I've tried to use getdeps provided libraries, but the trickiest bit was that Rust links with Python, which is currently not providable by getdeps, so if you try to build everything the system provided Python libraries will collide with getdeps provided ones) 7. Added `opensource/fbcode_builder/manifests/eden_scm` for the getdeps build. Reviewed By: quark-zju Differential Revision: D22336485 fbshipit-source-id: 244d10c9e06ee83de61e97e62a1f2a2184d2312f
2020-07-03 03:52:20 +03:00
2011-05-02 11:50:21 +04:00
check: tests
.PHONY: tests
tests:
cd tests && PYTHON_SYS_EXECUTABLE=$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) \
$(shell $(PYTHON3) contrib/pick_python.py $(PYTHON3)) run-tests.py
update-pot: i18n/hg.pot
i18n/hg.pot: $(PYFILES) $(DOCFILES) i18n/posplit i18n/hggettext
$(PYTHON) i18n/hggettext edenscm/commands.py \
edenscm/ext/*.py edenscm/ext/*/__init__.py \
edenscm/fileset.py edenscm/revset.py \
edenscm/templatefilters.py edenscm/templatekw.py \
edenscm/templater.py \
edenscm/filemerge.py \
edenscm/util.py \
$(DOCFILES) > i18n/hg.pot.tmp
# All strings marked for translation in Mercurial contain
# ASCII characters only. But some files contain string
# literals like this '\037\213'. xgettext thinks it has to
2009-05-02 14:10:38 +04:00
# parse them even though they are not marked for translation.
# Extracting with an explicit encoding of ISO-8859-1 will make
# xgettext "parse" and ignore them.
echo $(PYFILES) | xargs \
xgettext --package-name "Mercurial" \
--msgid-bugs-address "<mercurial-devel@mercurial-scm.org>" \
--copyright-holder "Olivia Mackall <olivia@selenic.com> and others" \
--from-code ISO-8859-1 --join --sort-by-file --add-comments=i18n: \
--keyword=_n:1,2 -d hg -p i18n -o hg.pot.tmp
$(PYTHON) i18n/posplit i18n/hg.pot.tmp
# The target file is not created before the last step. So it never is in
# an intermediate state.
mv -f i18n/hg.pot.tmp i18n/hg.pot
%.po: i18n/hg.pot
# work on a temporary copy for never having a half completed target
cp $@ $@.tmp
msgmerge --no-location --update $@.tmp $^
mv -f $@.tmp $@
# Packaging targets
.PHONY: help all local build cleanbutpackages clean install install-home install-getdeps getdepsbuild deb