Skip to content

Commit

Permalink
fix python shebang in scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
nim65s committed Nov 30, 2023
1 parent c23fb36 commit 6e9fe4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- fix python shebang in scripts

## [v0.52.1] - 2023-11-21

## [v0.52.0] - 2023-11-21
Expand Down
10 changes: 5 additions & 5 deletions cmeel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
"The next patch would delete",
]

EXECUTABLE = """#!python
from cmeel.run import cmeel_run
cmeel_run()
"""
EXECUTABLE = ["#!python", "from cmeel.run import cmeel_run", "cmeel_run()"]


class PatchError(CalledProcessError):
Expand Down Expand Up @@ -176,7 +173,10 @@ def expose_bin(install: Path, wheel_dir: Path, distribution: str):
with fn.open("rb") as fo:
is_script = fo.read(2) == b"#!"
with executable.open("w") as fe:
fe.write(fn.read_text() if is_script else EXECUTABLE)
content = fn.read_text().split("\n") if is_script else EXECUTABLE
if "python" in content[0]:
content = ["#!python", *content[1:]]
fe.write("\n".join(content))
executable.chmod(0o755)


Expand Down

0 comments on commit 6e9fe4c

Please sign in to comment.