From 70de4d34d22e16671ac88a4e620c5279bb66c471 Mon Sep 17 00:00:00 2001 From: Zanie Date: Wed, 13 Dec 2023 13:55:19 -0600 Subject: [PATCH] Deterministic distfile iteration --- src/packse/publish.py | 2 +- tests/__snapshots__/test_build.ambr | 320 -------------------------- tests/__snapshots__/test_publish.ambr | 8 +- 3 files changed, 5 insertions(+), 325 deletions(-) diff --git a/src/packse/publish.py b/src/packse/publish.py index fd4f60c9..59b8bb95 100644 --- a/src/packse/publish.py +++ b/src/packse/publish.py @@ -24,7 +24,7 @@ def publish(targets: list[Path], skip_existing: bool, dry_run: bool): logger.info("Publishing %s target%s...", len(targets), s) for target in targets: logger.info("Publishing '%s'...", target.name) - for distfile in target.iterdir(): + for distfile in sorted(target.iterdir()): try: publish_package_distribution(distfile, dry_run) except PublishAlreadyExists: diff --git a/tests/__snapshots__/test_build.ambr b/tests/__snapshots__/test_build.ambr index 181c2548..f0e66a32 100644 --- a/tests/__snapshots__/test_build.ambr +++ b/tests/__snapshots__/test_build.ambr @@ -1,324 +1,4 @@ # serializer version: 1 -# name: test_build_example - dict({ - 'exit_code': 0, - 'filesystem': dict({ - 'build/example-cd797223/example-cd797223-a-1.0.0/pyproject.toml': ''' - [build-system] - requires = ["hatchling"] - build-backend = "hatchling.build" - - [tool.hatch.build] - sources = ["src"] - - [project] - name = "example-cd797223-a" - version = "1.0.0" - dependencies = ["example-cd797223-b>=1.0.0"] - requires-python = ">=3.7" - - ''', - 'build/example-cd797223/example-cd797223-a-1.0.0/src/example_cd797223_a/__init__.py': ''' - __version__ = "1.0.0" - - ''', - 'build/example-cd797223/example-cd797223-b-1.0.0/pyproject.toml': ''' - [build-system] - requires = ["hatchling"] - build-backend = "hatchling.build" - - [tool.hatch.build] - sources = ["src"] - - [project] - name = "example-cd797223-b" - version = "1.0.0" - dependencies = [] - requires-python = ">=3.7" - - ''', - 'build/example-cd797223/example-cd797223-b-1.0.0/src/example_cd797223_b/__init__.py': ''' - __version__ = "1.0.0" - - ''', - 'dist/example-cd797223/example_cd797223_a-1.0.0-py3-none-any.whl': 'md5:faa8dde3d6637662e11790eba6669e69', - 'dist/example-cd797223/example_cd797223_a-1.0.0.tar.gz': 'md5:45bf482ba51f183595d35f9a37d765c2', - 'dist/example-cd797223/example_cd797223_b-1.0.0-py3-none-any.whl': 'md5:5094ffef466de99e9dbbe930b96f1715', - 'dist/example-cd797223/example_cd797223_b-1.0.0.tar.gz': 'md5:e2805e172c50fea19762cc403918644b', - 'tree': ''' - test_build_example0 - ├── build - │ └── example-cd797223 - │ ├── example-cd797223-a-1.0.0 - │ │ ├── pyproject.toml - │ │ └── src - │ │ └── example_cd797223_a - │ │ └── __init__.py - │ └── example-cd797223-b-1.0.0 - │ ├── pyproject.toml - │ └── src - │ └── example_cd797223_b - │ └── __init__.py - └── dist - └── example-cd797223 - ├── example_cd797223_a-1.0.0-py3-none-any.whl - ├── example_cd797223_a-1.0.0.tar.gz - ├── example_cd797223_b-1.0.0-py3-none-any.whl - └── example_cd797223_b-1.0.0.tar.gz - - 10 directories, 8 files - - ''', - }), - 'stderr': ''' - INFO:root:Building 'example-cd797223' in directory 'build/example-cd797223' - INFO:packse.template:Creating example-cd797223-a-1.0.0 - INFO:packse.template:Creating example-cd797223-a-1.0.0/pyproject.toml - INFO:packse.template:Creating example-cd797223-a-1.0.0/src - INFO:packse.template:Creating example-cd797223-a-1.0.0/src/example_cd797223_a - INFO:packse.template:Creating example-cd797223-a-1.0.0/src/example_cd797223_a/__init__.py - INFO:packse.build:Building build/example-cd797223/example-cd797223-a-1.0.0 with hatch - INFO:packse.build:Linked distribution to dist/example-cd797223/example_cd797223_a-1.0.0-py3-none-any.whl - INFO:packse.build:Linked distribution to dist/example-cd797223/example_cd797223_a-1.0.0.tar.gz - INFO:packse.template:Creating example-cd797223-b-1.0.0 - INFO:packse.template:Creating example-cd797223-b-1.0.0/pyproject.toml - INFO:packse.template:Creating example-cd797223-b-1.0.0/src - INFO:packse.template:Creating example-cd797223-b-1.0.0/src/example_cd797223_b - INFO:packse.template:Creating example-cd797223-b-1.0.0/src/example_cd797223_b/__init__.py - INFO:packse.build:Building build/example-cd797223/example-cd797223-b-1.0.0 with hatch - INFO:packse.build:Linked distribution to dist/example-cd797223/example_cd797223_b-1.0.0-py3-none-any.whl - INFO:packse.build:Linked distribution to dist/example-cd797223/example_cd797223_b-1.0.0.tar.gz - - ''', - 'stdout': ''' - example-cd797223-a - - ''', - }) -# --- -# name: test_build_example_already_exists - dict({ - 'exit_code': 0, - 'filesystem': dict({ - 'build/example-cd797223/example-cd797223-a-1.0.0/pyproject.toml': ''' - [build-system] - requires = ["hatchling"] - build-backend = "hatchling.build" - - [tool.hatch.build] - sources = ["src"] - - [project] - name = "example-cd797223-a" - version = "1.0.0" - dependencies = ["example-cd797223-b>=1.0.0"] - requires-python = ">=3.7" - - ''', - 'build/example-cd797223/example-cd797223-a-1.0.0/src/example_cd797223_a/__init__.py': ''' - __version__ = "1.0.0" - - ''', - 'build/example-cd797223/example-cd797223-b-1.0.0/pyproject.toml': ''' - [build-system] - requires = ["hatchling"] - build-backend = "hatchling.build" - - [tool.hatch.build] - sources = ["src"] - - [project] - name = "example-cd797223-b" - version = "1.0.0" - dependencies = [] - requires-python = ">=3.7" - - ''', - 'build/example-cd797223/example-cd797223-b-1.0.0/src/example_cd797223_b/__init__.py': ''' - __version__ = "1.0.0" - - ''', - 'dist/example-cd797223/example_cd797223_a-1.0.0-py3-none-any.whl': 'md5:faa8dde3d6637662e11790eba6669e69', - 'dist/example-cd797223/example_cd797223_a-1.0.0.tar.gz': 'md5:45bf482ba51f183595d35f9a37d765c2', - 'dist/example-cd797223/example_cd797223_b-1.0.0-py3-none-any.whl': 'md5:5094ffef466de99e9dbbe930b96f1715', - 'dist/example-cd797223/example_cd797223_b-1.0.0.tar.gz': 'md5:e2805e172c50fea19762cc403918644b', - 'tree': ''' - test_build_example_already_exi0 - ├── build - │ └── example-cd797223 - │ ├── example-cd797223-a-1.0.0 - │ │ ├── pyproject.toml - │ │ └── src - │ │ └── example_cd797223_a - │ │ └── __init__.py - │ └── example-cd797223-b-1.0.0 - │ ├── pyproject.toml - │ └── src - │ └── example_cd797223_b - │ └── __init__.py - └── dist - └── example-cd797223 - ├── example_cd797223_a-1.0.0-py3-none-any.whl - ├── example_cd797223_a-1.0.0.tar.gz - ├── example_cd797223_b-1.0.0-py3-none-any.whl - └── example_cd797223_b-1.0.0.tar.gz - - 10 directories, 8 files - - ''', - }), - 'stderr': ''' - INFO:root:Building 'example-cd797223' in directory 'build/example-cd797223' - INFO:packse.template:Creating example-cd797223-a-1.0.0 - INFO:packse.template:Creating example-cd797223-a-1.0.0/pyproject.toml - INFO:packse.template:Creating example-cd797223-a-1.0.0/src - INFO:packse.template:Creating example-cd797223-a-1.0.0/src/example_cd797223_a - INFO:packse.template:Creating example-cd797223-a-1.0.0/src/example_cd797223_a/__init__.py - INFO:packse.build:Building build/example-cd797223/example-cd797223-a-1.0.0 with hatch - INFO:packse.build:Linked distribution to dist/example-cd797223/example_cd797223_a-1.0.0-py3-none-any.whl - INFO:packse.build:Linked distribution to dist/example-cd797223/example_cd797223_a-1.0.0.tar.gz - INFO:packse.template:Creating example-cd797223-b-1.0.0 - INFO:packse.template:Creating example-cd797223-b-1.0.0/pyproject.toml - INFO:packse.template:Creating example-cd797223-b-1.0.0/src - INFO:packse.template:Creating example-cd797223-b-1.0.0/src/example_cd797223_b - INFO:packse.template:Creating example-cd797223-b-1.0.0/src/example_cd797223_b/__init__.py - INFO:packse.build:Building build/example-cd797223/example-cd797223-b-1.0.0 with hatch - INFO:packse.build:Linked distribution to dist/example-cd797223/example_cd797223_b-1.0.0-py3-none-any.whl - INFO:packse.build:Linked distribution to dist/example-cd797223/example_cd797223_b-1.0.0.tar.gz - - ''', - 'stdout': ''' - example-cd797223-a - - ''', - }) -# --- -# name: test_build_example_already_exists_with_rm_flag - dict({ - 'exit_code': 0, - 'stderr': ''' - INFO:root:Building 'example-cd797223' in directory 'build/example-cd797223' - INFO:packse.template:Creating example-cd797223-a-1.0.0 - INFO:packse.template:Creating example-cd797223-a-1.0.0/pyproject.toml - INFO:packse.template:Creating example-cd797223-a-1.0.0/src - INFO:packse.template:Creating example-cd797223-a-1.0.0/src/example_cd797223_a - INFO:packse.template:Creating example-cd797223-a-1.0.0/src/example_cd797223_a/__init__.py - INFO:packse.build:Building build/example-cd797223/example-cd797223-a-1.0.0 with hatch - INFO:packse.build:Linked distribution to dist/example-cd797223/example_cd797223_a-1.0.0-py3-none-any.whl - INFO:packse.build:Linked distribution to dist/example-cd797223/example_cd797223_a-1.0.0.tar.gz - INFO:packse.template:Creating example-cd797223-b-1.0.0 - INFO:packse.template:Creating example-cd797223-b-1.0.0/pyproject.toml - INFO:packse.template:Creating example-cd797223-b-1.0.0/src - INFO:packse.template:Creating example-cd797223-b-1.0.0/src/example_cd797223_b - INFO:packse.template:Creating example-cd797223-b-1.0.0/src/example_cd797223_b/__init__.py - INFO:packse.build:Building build/example-cd797223/example-cd797223-b-1.0.0 with hatch - INFO:packse.build:Linked distribution to dist/example-cd797223/example_cd797223_b-1.0.0-py3-none-any.whl - INFO:packse.build:Linked distribution to dist/example-cd797223/example_cd797223_b-1.0.0.tar.gz - - ''', - 'stdout': ''' - example-cd797223-a - - ''', - }) -# --- -# name: test_build_example_with_seed - dict({ - 'exit_code': 0, - 'filesystem': dict({ - 'build/example-17bdcd0e/example-17bdcd0e-a-1.0.0/pyproject.toml': ''' - [build-system] - requires = ["hatchling"] - build-backend = "hatchling.build" - - [tool.hatch.build] - sources = ["src"] - - [project] - name = "example-17bdcd0e-a" - version = "1.0.0" - dependencies = ["example-17bdcd0e-b>=1.0.0"] - requires-python = ">=3.7" - - ''', - 'build/example-17bdcd0e/example-17bdcd0e-a-1.0.0/src/example_17bdcd0e_a/__init__.py': ''' - __version__ = "1.0.0" - - ''', - 'build/example-17bdcd0e/example-17bdcd0e-b-1.0.0/pyproject.toml': ''' - [build-system] - requires = ["hatchling"] - build-backend = "hatchling.build" - - [tool.hatch.build] - sources = ["src"] - - [project] - name = "example-17bdcd0e-b" - version = "1.0.0" - dependencies = [] - requires-python = ">=3.7" - - ''', - 'build/example-17bdcd0e/example-17bdcd0e-b-1.0.0/src/example_17bdcd0e_b/__init__.py': ''' - __version__ = "1.0.0" - - ''', - 'dist/example-17bdcd0e/example_17bdcd0e_a-1.0.0-py3-none-any.whl': 'md5:06db9ba92742b36d384692dffa325ad5', - 'dist/example-17bdcd0e/example_17bdcd0e_a-1.0.0.tar.gz': 'md5:987a5de418eb140685290193a168aa0e', - 'dist/example-17bdcd0e/example_17bdcd0e_b-1.0.0-py3-none-any.whl': 'md5:6eedf0f7db8998f7c3b87230d6ef58f6', - 'dist/example-17bdcd0e/example_17bdcd0e_b-1.0.0.tar.gz': 'md5:76d73a727dac8271f30039089643d8f5', - 'tree': ''' - test_build_example_with_seed0 - ├── build - │ └── example-17bdcd0e - │ ├── example-17bdcd0e-a-1.0.0 - │ │ ├── pyproject.toml - │ │ └── src - │ │ └── example_17bdcd0e_a - │ │ └── __init__.py - │ └── example-17bdcd0e-b-1.0.0 - │ ├── pyproject.toml - │ └── src - │ └── example_17bdcd0e_b - │ └── __init__.py - └── dist - └── example-17bdcd0e - ├── example_17bdcd0e_a-1.0.0-py3-none-any.whl - ├── example_17bdcd0e_a-1.0.0.tar.gz - ├── example_17bdcd0e_b-1.0.0-py3-none-any.whl - └── example_17bdcd0e_b-1.0.0.tar.gz - - 10 directories, 8 files - - ''', - }), - 'stderr': ''' - INFO:root:Building 'example-17bdcd0e' in directory 'build/example-17bdcd0e' - INFO:packse.template:Creating example-17bdcd0e-a-1.0.0 - INFO:packse.template:Creating example-17bdcd0e-a-1.0.0/pyproject.toml - INFO:packse.template:Creating example-17bdcd0e-a-1.0.0/src - INFO:packse.template:Creating example-17bdcd0e-a-1.0.0/src/example_17bdcd0e_a - INFO:packse.template:Creating example-17bdcd0e-a-1.0.0/src/example_17bdcd0e_a/__init__.py - INFO:packse.build:Building build/example-17bdcd0e/example-17bdcd0e-a-1.0.0 with hatch - INFO:packse.build:Linked distribution to dist/example-17bdcd0e/example_17bdcd0e_a-1.0.0-py3-none-any.whl - INFO:packse.build:Linked distribution to dist/example-17bdcd0e/example_17bdcd0e_a-1.0.0.tar.gz - INFO:packse.template:Creating example-17bdcd0e-b-1.0.0 - INFO:packse.template:Creating example-17bdcd0e-b-1.0.0/pyproject.toml - INFO:packse.template:Creating example-17bdcd0e-b-1.0.0/src - INFO:packse.template:Creating example-17bdcd0e-b-1.0.0/src/example_17bdcd0e_b - INFO:packse.template:Creating example-17bdcd0e-b-1.0.0/src/example_17bdcd0e_b/__init__.py - INFO:packse.build:Building build/example-17bdcd0e/example-17bdcd0e-b-1.0.0 with hatch - INFO:packse.build:Linked distribution to dist/example-17bdcd0e/example_17bdcd0e_b-1.0.0-py3-none-any.whl - INFO:packse.build:Linked distribution to dist/example-17bdcd0e/example_17bdcd0e_b-1.0.0.tar.gz - - ''', - 'stdout': ''' - example-17bdcd0e-a - - ''', - }) -# --- # name: test_build_invalid_target dict({ 'exit_code': 1, diff --git a/tests/__snapshots__/test_publish.ambr b/tests/__snapshots__/test_publish.ambr index 40855500..a07d6ba5 100644 --- a/tests/__snapshots__/test_publish.ambr +++ b/tests/__snapshots__/test_publish.ambr @@ -5,17 +5,17 @@ 'stderr': ''' INFO:packse.publish:Publishing 1 target... INFO:packse.publish:Publishing 'example-cd797223'... - INFO:packse.publish:Published 'example_cd797223_b-1.0.0.tar.gz' - INFO:packse.publish:Published 'example_cd797223_a-1.0.0.tar.gz' INFO:packse.publish:Published 'example_cd797223_a-1.0.0-py3-none-any.whl' + INFO:packse.publish:Published 'example_cd797223_a-1.0.0.tar.gz' INFO:packse.publish:Published 'example_cd797223_b-1.0.0-py3-none-any.whl' + INFO:packse.publish:Published 'example_cd797223_b-1.0.0.tar.gz' ''', 'stdout': ''' - Would execute: twine upload -r testpypi $PWD/dist/example-cd797223/example_cd797223_b-1.0.0.tar.gz - Would execute: twine upload -r testpypi $PWD/dist/example-cd797223/example_cd797223_a-1.0.0.tar.gz Would execute: twine upload -r testpypi $PWD/dist/example-cd797223/example_cd797223_a-1.0.0-py3-none-any.whl + Would execute: twine upload -r testpypi $PWD/dist/example-cd797223/example_cd797223_a-1.0.0.tar.gz Would execute: twine upload -r testpypi $PWD/dist/example-cd797223/example_cd797223_b-1.0.0-py3-none-any.whl + Would execute: twine upload -r testpypi $PWD/dist/example-cd797223/example_cd797223_b-1.0.0.tar.gz ''', })