Skip to content

Commit 9522eb4

Browse files
authored
Merge pull request #133 from lsst/tickets/DM-48776
DM-48776: Choose shebang rewriting for pyproject scripts to match shebang target
2 parents 1ca295d + b2f3043 commit 9522eb4

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
- id: end-of-file-fixer
1010
- id: trailing-whitespace
1111
- repo: https://github.com/psf/black
12-
rev: 24.10.0
12+
rev: 25.1.0
1313
hooks:
1414
- id: black
1515
# It is recommended to specify the latest version of Python
@@ -18,12 +18,12 @@ repos:
1818
# https://pre-commit.com/#top_level-default_language_version
1919
language_version: python3.11
2020
- repo: https://github.com/pycqa/isort
21-
rev: 5.13.2
21+
rev: 6.0.0
2222
hooks:
2323
- id: isort
2424
name: isort (python)
2525
- repo: https://github.com/astral-sh/ruff-pre-commit
2626
# Ruff version.
27-
rev: v0.8.0
27+
rev: v0.9.4
2828
hooks:
2929
- id: ruff

python/lsst/sconsUtils/builders.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""Extra builders and methods to be injected into the SConsEnvironment class.
1+
"""Extra builders and methods to be injected into the SConsEnvironment
2+
class.
23
"""
34

45
__all__ = ("filesToTag", "DoxygenBuilder")
@@ -15,7 +16,7 @@
1516

1617
from . import state
1718
from .installation import determineVersion, getFingerprint
18-
from .utils import memberOf, whichPython
19+
from .utils import memberOf, needShebangRewrite, whichPython
1920

2021

2122
@memberOf(SConsEnvironment)
@@ -805,11 +806,17 @@ def makePythonScript(target, source, env):
805806
return
806807
os.makedirs(os.path.dirname(cmdfile), exist_ok=True)
807808
package, func = scripts[command].split(":", maxsplit=1)
809+
python_exe = whichPython()
810+
if needShebangRewrite():
811+
shebang = python_exe
812+
else:
813+
# Linux has very small shebang limit so always use env.
814+
shebang = f"/usr/bin/env {os.path.basename(python_exe)}"
808815
with open(cmdfile, "w") as fd:
809816
# Follow setuptools convention and always change the shebang.
810817
# Can not add noqa on Linux for long paths so do not add anywhere.
811818
print(
812-
rf"""#!{whichPython()}
819+
rf"""#!{shebang}
813820
import sys
814821
from {package} import {func}
815822
if __name__ == '__main__':

python/lsst/sconsUtils/tests.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""Control which tests run, and how.
2-
"""
1+
"""Control which tests run, and how."""
32

43
__all__ = ("Control",)
54

0 commit comments

Comments
 (0)