[Python] InvalidDistribution: Metadata is missing required fields (Name, Version) when...

Discussão em 'Python' iniciado por Stack, Abril 25, 2025.

  1. Stack

    Stack Membro Participativo

    Title:
    InvalidDistribution: Metadata is missing required fields (Name, Version) when uploading wheel to TestPyPI


    Question:
    I’ve built a Python package called OmniMind (a plug‑and‑play library for effortless MCP server integration, powered by Google Gemini). The source is on GitHub: https://github.com/Techiral/OmniMind.

    I can successfully build both the sdist and wheel locally:

    > python -m build
    * Building sdist...
    * Building wheel...
    Successfully built omnimind-0.1.0.tar.gz and omnimind-0.1.0-py3-none-any.whl


    But when I try to upload to TestPyPI, I get:

    Checking dist/omnimind-0.1.0-py3-none-any.whl: ERROR InvalidDistribution: Metadata is missing required fields: Name, Version.
    …
    Uploading distributions to https://test.pypi.org/legacy/
    ERROR InvalidDistribution: Metadata is missing required fields: Name, Version.


    I’ve tried 23+ different variations of my packaging files and consulted various AI assistants over three days, but nothing seems to fix it. Here are my current configs:

    setup.py


    from setuptools import setup

    setup()

    setup.cfg


    [metadata]
    name = omnimind
    version = 0.1.0
    author = Lakshya Gupta
    author_email = techiralthefuture@gmail.com
    description = A plug-and-play Python library for effortless MCP server integration, powered by Google Gemini
    long_description = file: README.md
    long_description_content_type = text/markdown
    url = https://github.com/Techiral/OmniMind
    license = MIT
    classifiers =
    Programming Language :: Python :: 3
    Operating System :: OS Independent
    Topic :: Software Development :: Libraries :: Python Modules
    Intended Audience :: Developers
    Development Status :: 3 - Alpha

    [options]
    packages = find:
    python_requires = >=3.8
    install_requires =
    mcp>=1.6.0
    langchain-google-genai>=2.1.2
    langgraph>=0.3.25
    langchain-mcp-adapters>=0.0.7
    python-dotenv>=1.1.0

    pyproject.toml


    [build-system]
    requires = ["setuptools>=61.0", "wheel"]
    build-backend = "setuptools.build_meta"

    What I’ve tried so far

    1. Explicitly listing name and version in setup.py instead of relying on setup.cfg.
    2. Switching metadata between setup.cfg and pyproject.toml.
    3. Downgrading/upgrading setuptools, wheel, and build versions.
    4. Adding a MANIFEST.in (though my sdist already includes all necessary files).
    5. Using flit and poetry instead of setuptools.
    6. Ensuring UTF‑8 encoding on all files and CRLF vs. LF line endings.
    7. Verifying that PKG-INFO inside the built archives actually contains the Name: and Version: fields (it does not).

    Nothing has made the Name and Version fields appear in the wheel metadata. I suspect I’m missing something fundamental in how setuptools reads metadata from setup.cfg or pyproject.toml.

    Questions

    1. Why are Name and Version missing from my wheel’s metadata even though they’re declared in setup.cfg?
    2. What’s the correct minimal configuration to get a wheel with valid metadata for TestPyPI?
    3. Are there any gotchas with mixing setup.cfg and pyproject.toml for a simple project?

    Any pointers or examples of a working minimal project layout would be hugely appreciated!

    Continue reading...

Compartilhe esta Página