Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Nov 2021 11:55:45 GMT
From:      Kai Knoblich <kai@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-branches@FreeBSD.org
Subject:   git: 53d9b1720e8f - 2021Q4 - devel/py-setuptools_scm: Do not run "git archive" on Ports tree
Message-ID:  <202111021155.1A2Btjtb030437@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch 2021Q4 has been updated by kai:

URL: https://cgit.FreeBSD.org/ports/commit/?id=53d9b1720e8f92aaa1ba0bc693f148ffe33ccc02

commit 53d9b1720e8f92aaa1ba0bc693f148ffe33ccc02
Author:     Kai Knoblich <kai@FreeBSD.org>
AuthorDate: 2021-10-24 10:43:33 +0000
Commit:     Kai Knoblich <kai@FreeBSD.org>
CommitDate: 2021-11-02 11:53:42 +0000

    devel/py-setuptools_scm: Do not run "git archive" on Ports tree
    
    * In build environments have git installed in conjunction with a
      git-based Ports tree and haven't WRKDIRPREFIX set, there will be
      significant delays when building devel/py-setuptools_scm or ports
      that depend on it.
    
      This is because the top-level directory of the git repository is
      determined during build via "git rev-parse --show-toplevel" which is
      issued inside the WRKSRC directory.
    
      Once the top-level directory (which is PORTSDIR) has been determined,
      an archive is created from this point using "git archive" which is
      then very time-consuming due the complexity of the Ports tree.
    
      In environments (e.g. poudriere) that have WRKDIRPREFIX set and also
      have git present during build, the issue doesn't appear because
      "git rev-parse --show-toplevel" fails silently with "not a git repo".
    
      Remedy the issue by returning only the actual path of WRKSRC, but only
      if it has "setup.py" in it (= devel/py-setuptools_scm is built) or a
      test session is performed.
    
    * Modernize the "do-test" target while I'm here and bump PORTREVISION
      due package change.
    PR:             258891
    Reported by:    Robert Clausecker <fuz@fuz.su>
    Obtained from:  OpenIndiana
    MFH:            2021Q4 (after 1 week)
    
    (cherry picked from commit adc0cc3f69aeac37b9678c6d5b4d548d9c60cfae)
---
 devel/py-setuptools_scm/Makefile                   |  8 ++++++--
 .../patch-src_setuptools__scm_file__finder__git.py | 22 ++++++++++++++++++++++
 .../patch-src_setuptools__scm_file__finder__hg.py  | 22 ++++++++++++++++++++++
 3 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/devel/py-setuptools_scm/Makefile b/devel/py-setuptools_scm/Makefile
index 6d5f80cc6d07..c3a15793cfb0 100644
--- a/devel/py-setuptools_scm/Makefile
+++ b/devel/py-setuptools_scm/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	setuptools_scm
 PORTVERSION=	4.1.2
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	devel python
 MASTER_SITES=	CHEESESHOP
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
@@ -19,6 +19,10 @@ TEST_DEPENDS=	${PYTHON_PKGNAMEPREFIX}pytest>0:devel/py-pytest@${PY_FLAVOR} \
 USES=		python:3.6+
 USE_PYTHON=	autoplist distutils
 
+# Workaround to get a 100% working test suite.  This can be removed once
+# https://github.com/pypa/setuptools_scm/issues/353 is solved.
+TEST_ENV=	_PYTEST_SESSION=yes
+
 NO_ARCH=	yes
 
 OPTIONS_DEFINE=		TOML
@@ -28,6 +32,6 @@ TOML_DESC=		Support for parsing pyproject.toml files [PEP 517/518]
 TOML_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}toml>0:textproc/py-toml@${PY_FLAVOR}
 
 do-test:
-	@cd ${WRKSRC} && ${PYTHON_CMD} -m pytest -v -rs
+	@cd ${TEST_WRKSRC} && ${SETENV} ${TEST_ENV} ${PYTHON_CMD} -m pytest -v -rs
 
 .include <bsd.port.mk>
diff --git a/devel/py-setuptools_scm/files/patch-src_setuptools__scm_file__finder__git.py b/devel/py-setuptools_scm/files/patch-src_setuptools__scm_file__finder__git.py
new file mode 100644
index 000000000000..d33a125106b5
--- /dev/null
+++ b/devel/py-setuptools_scm/files/patch-src_setuptools__scm_file__finder__git.py
@@ -0,0 +1,22 @@
+Workaround for https://github.com/pypa/setuptools_scm/issues/353
+
+Original version (without the check for test sessions) obtained from:
+
+https://github.com/OpenIndiana/oi-userland/commit/7d928fa26c0c5e4c29b4826fe78dc42401730529
+
+--- src/setuptools_scm/file_finder_git.py.orig	2021-10-20 09:27:26 UTC
++++ src/setuptools_scm/file_finder_git.py
+@@ -18,7 +18,12 @@ def _git_toplevel(path):
+                 stderr=devnull,
+             )
+         trace("find files toplevel", out)
+-        return os.path.normcase(os.path.realpath(out.strip()))
++        toplevel_path = os.path.normcase(os.path.realpath(out.strip()))
++        setup_py_path = os.path.join(toplevel_path, "setup.py")
++        if os.path.exists(setup_py_path) or os.environ.get("_PYTEST_SESSION"):
++            return toplevel_path
++        else:
++            return None
+     except subprocess.CalledProcessError:
+         # git returned error, we are not in a git repo
+         return None
diff --git a/devel/py-setuptools_scm/files/patch-src_setuptools__scm_file__finder__hg.py b/devel/py-setuptools_scm/files/patch-src_setuptools__scm_file__finder__hg.py
new file mode 100644
index 000000000000..7da5458d484a
--- /dev/null
+++ b/devel/py-setuptools_scm/files/patch-src_setuptools__scm_file__finder__hg.py
@@ -0,0 +1,22 @@
+Workaround for https://github.com/pypa/setuptools_scm/issues/353
+
+Original version (without the check for test sessions) obtained from:
+
+https://github.com/OpenIndiana/oi-userland/commit/7d928fa26c0c5e4c29b4826fe78dc42401730529
+
+--- src/setuptools_scm/file_finder_hg.py.orig	2021-10-20 09:29:52 UTC
++++ src/setuptools_scm/file_finder_hg.py
+@@ -13,7 +13,12 @@ def _hg_toplevel(path):
+                 universal_newlines=True,
+                 stderr=devnull,
+             )
+-        return os.path.normcase(os.path.realpath(out.strip()))
++        toplevel_path = os.path.normcase(os.path.realpath(out.strip()))
++        setup_py_path = os.path.join(toplevel_path, "setup.py")
++        if os.path.exists(setup_py_path) or os.environ.get("_PYTEST_SESSION"):
++            return toplevel_path
++        else:
++            return None
+     except subprocess.CalledProcessError:
+         # hg returned error, we are not in a mercurial repo
+         return None



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202111021155.1A2Btjtb030437>