python / python/cpython

Inconsistent behavior of `zipapp.create_archive`

Open
#156,568 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

Currently, zipapp.create_archive makes the target application archive executable only if target is a str. (see snippets bellow).

I think the target application archive should be made executable also when target is os.PathLike.

# source.py
print("Hello from pyz")
# bug_reproduction.py
import os
import pathlib
import zipapp
import sys

zipapp.create_archive("source.py", "source.pyz")

zipapp.create_archive(
    pathlib.Path("source.pyz"),
    pathlib.Path("copy.pyz"),
    interpreter=sys.executable,
)


zipapp.create_archive("source.pyz", "copy2.pyz", interpreter=sys.executable)

assert os.access("copy2.pyz", os.X_OK)  # Passes
assert os.access("copy.pyz", os.X_OK)  # Fails
CPython versions tested on:

CPython main branch, commit b0c9fc37dd0ed60456313600e6a01478308f195e

Operating systems tested on:

Linux

Linked PRs
  • gh-156569

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the zipapp.create_archive entry point and reproduce the behavior from the issue on Linux with string and pathlib.Path targets. Done means PathLike targets produce executable archives consistently with string targets; the issue's linked PR indicates this work is already underway.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.