Skip to content

Commit

Permalink
Deterministic distfile iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Dec 13, 2023
1 parent e185cf3 commit 70de4d3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 325 deletions.
2 changes: 1 addition & 1 deletion src/packse/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
320 changes: 0 additions & 320 deletions tests/__snapshots__/test_build.ambr
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
8 changes: 4 additions & 4 deletions tests/__snapshots__/test_publish.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -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

''',
})
Expand Down

0 comments on commit 70de4d3

Please sign in to comment.