Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Dry-run #125

Open
kairos03 opened this issue Feb 20, 2024 · 1 comment
Open

Support Dry-run #125

kairos03 opened this issue Feb 20, 2024 · 1 comment

Comments

@kairos03
Copy link

kairos03 commented Feb 20, 2024

Before uploading a new package, I want to ensure that the version does not already exist.

To do this, I typically use the --strict option with upload and immediately delete the package afterward.

However, I believe this is not the best approach. Could you introduce a --dry-run option to merely check if the new version upload will cause a conflict?

If possible, I want to work on it. TX

@mdwint
Copy link
Member

mdwint commented Feb 21, 2024

Hello @kairos03. I'm open to this feature, and you're welcome to work on it.

Implementation hint: Try subclassing S3Storage and stub out all put/delete methods:

s3pypi/s3pypi/storage.py

Lines 85 to 102 in f1d2e3c

def put_index(self, directory: str, index: Index) -> None:
self._object(directory, self.index_name).put(
Body=index.to_html(),
ContentType="text/html",
CacheControl="public, must-revalidate, proxy-revalidate, max-age=0",
**self.cfg.put_kwargs, # type: ignore
)
def put_distribution(self, directory: str, local_path: Path) -> None:
with open(local_path, mode="rb") as f:
self._object(directory, local_path.name).put(
Body=f,
ContentType="application/x-gzip",
**self.cfg.put_kwargs, # type: ignore
)
def delete(self, directory: str, filename: str) -> None:
self._object(directory, filename).delete()

The put methods can be changed to register if puts were attempted. At the end you can check the result and return the appropriate exit code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants