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

InvalidDistribution: Unknown distribution format: 'artifact' when not specifying an artifact name #235

Closed
danielniccoli opened this issue Apr 27, 2024 · 12 comments

Comments

@danielniccoli
Copy link

An error InvalidDistribution: Unknown distribution format: 'artifact' is thrown when artifact upload/download is used with the default name.

jobs:
  build:
    - name: Store the distribution packages
      uses: actions/upload-artifact@v3
      with:
        # name: python-package-distributions
        path: dist/

  publish-to-testpypi:
    steps:
    - name: Download all the dists
      uses: actions/download-artifact@v3
      with:
        # name: python-package-distributions
        path: dist/
    - name: Publish distribution 📦 to TestPyPI
      uses: pypa/gh-action-pypi-publish@release/v1
      with:
        repository-url: https://test.pypi.org/legacy/
Warning:  It looks like there are no Python distribution packages to publish in the directory 'dist/'. Please verify that they are in place should you face this problem.
Checking dist/artifact: ERROR    InvalidDistribution: Unknown distribution format: 'artifact'  
@shenxianpeng
Copy link

Checking dist/artifact: ERROR    InvalidDistribution: Unknown distribution format: 'artifact'

From the above error message, it seems using actions/download-artifact@v3 changed your package name to artifact under the dist/ folder. so I guess you can try to fix the package name format from the download step of path, e.g. change path: dist/ to path: dist/mypackage.whl

@danielniccoli
Copy link
Author

If I name it python-package-distributions it works. So where's the difference between artifact and python-package-distributions. One name works, the other fails.

@webknjaz
Copy link
Member

webknjaz commented May 1, 2024

@danielniccoli v3 of the action allows uploading/downloading artifacts without supplying the name input. In that case, their internals default to using the artifact name. That's not something related to this action, really.

@webknjaz
Copy link
Member

webknjaz commented May 1, 2024

This is likely because when you download w/o a name, GH combines all the artifacts related to the workflow into one and that behavior is known to differ.

@danielniccoli
Copy link
Author

@danielniccoli v3 of the action allows uploading/downloading artifacts without supplying the name input. In that case, their internals default to using the artifact name. That's not something related to this action, really.

  1. Yes, I know that.
  2. I know that, too. But that's not the point of this issue.

@danielniccoli
Copy link
Author

danielniccoli commented May 2, 2024

This is likely because when you download w/o a name, GH combines all the artifacts related to the workflow into one and that behavior is known to differ.

My build process only creates one artifact.

The content of both archives artifact and python-package-distributions are identical. If it works for the archive python-package-distributions, it must work for artifact. So why does one throw an error? This still sounds like a bug with this action.

If you need logs, let me know how to collect them and I will help with that.

@webknjaz
Copy link
Member

webknjaz commented May 2, 2024

So why does one throw an error?

Because artifact is a subfolder and GitHub's official action puts stuff in a nested folder structure. So if you want to use that, you'll have to adjust the packages-dir: input which defaults to dist/ to something else, like dist/artifact/, perhaps. The action will not traverse your folder structure to guess what you want to upload, it's your responsibility to set up a proper folder structure before calling this action: https://github.com/marketplace/actions/pypi-publish#non-goals.

@webknjaz
Copy link
Member

webknjaz commented May 2, 2024

InvalidDistribution: Unknown distribution format: 'artifact'

FYI we don't output this error, it's the underlying call to Twine that does.

@webknjaz
Copy link
Member

webknjaz commented May 2, 2024

If you need logs, let me know how to collect them and I will help with that.

Try injecting a call to tree dist/ or ls -alhR dist/ right after invoking the download action to see the difference. You should see that the structure GitHub's action produces is nested in one of the cases.

@webknjaz
Copy link
Member

webknjaz commented May 2, 2024

This still sounds like a bug with this action.

It's not, because we don't do anything with GitHub artifacts at all. We only work with files on disk that you put there. And we only call twine and a few other helpers but don't do anything advanced like looking into deeply nested directories.

@danielniccoli danielniccoli closed this as not planned Won't fix, can't repro, duplicate, stale May 3, 2024
@webknjaz
Copy link
Member

webknjaz commented May 3, 2024

Perhaps, it might make sense to add an explanatory warning message if a folder called artifact/ exists. But it seems like too much special-casing to maintain. If someone else gets confused by this, I'll consider implementing such a check.

@danielniccoli
Copy link
Author

You were right. When downloading, name causes the action to download everything in that folder. If not given, the entire folder is downloaded, along with any other folder that may exist there.

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

3 participants