Skip to content

Commit

Permalink
dirty: pass through previous state via env var
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Jan 18, 2024
1 parent db4ebbb commit bb68b1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,15 @@ def run_setup(modnames, pl_name, pdfium_ver):

if ModuleHelpers in modnames:
helpers_info = get_helpers_info()
# ignore dirty state due to craft_packages::tmp_ctypesgen_pin()
if pl_name == ExtPlats.sdist:
if helpers_info["dirty"]:
status = run_cmd(["git", "status", "--porcelain"], capture=True, cwd=ProjectDir).strip()
if status == "M pyproject.toml":
# ignore dirty state due to craft_packages::tmp_ctypesgen_pin()
if int(os.environ.get("SDIST_IGNORE_DIRTY", 0)):
status = run_cmd(["git", "status", "--porcelain"], capture=True, cwd=ProjectDir).strip()
assert status == "M pyproject.toml"
helpers_info["dirty"] = False
else:
print("Warning: sdist built without ctypesgen pin?", file=sys.stderr)
print("!!! Warning: sdist built without ctypesgen pin?", file=sys.stderr)
kwargs["version"] = merge_tag(helpers_info, mode="py")
# is_editable = None: unknown/fallback in case the cmdclass is not reached
helpers_info["is_editable"] = None
Expand Down
3 changes: 3 additions & 0 deletions setupsrc/pypdfium2_setup/craft_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ def main_pypi(args):

if args.sdist:
os.environ[PlatSpec_EnvVar] = ExtPlats.sdist
helpers_info = get_helpers_info()
with tmp_ctypesgen_pin():
if not helpers_info["dirty"]:
os.environ["SDIST_IGNORE_DIRTY"] = "1"
_run_pypi_build(["--sdist"])

if args.wheels:
Expand Down

0 comments on commit bb68b1a

Please sign in to comment.