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)
This commit is contained in:
parent
2b84b7d4b6
commit
adc0cc3f69
|
@ -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>
|
||||
|
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue