Backend subprocess fails during get_requires_for_build_sdist execution

I’m trying to publish my Python package to PyPI using GitHub Actions but keep running into an issue. I set up the workflow following the standard packaging tutorial and used setup.py for configuration.

When the build process runs, I get this error:

running egg_info
creating src/mypackage.egg-info
writing src/mypackage.egg-info/PKG-INFO
writing dependency_links to src/mypackage.egg-info/dependency_links.txt
writing top-level names to src/mypackage.egg-info/top_level.txt
writing manifest file 'src/mypackage.egg-info/SOURCES.txt'
error: package directory 'src/mypackage' does not exist
* Creating venv isolated environment...
* Installing packages in isolated environment... (requests>=2.25.1, setuptools>=42)
* Getting dependencies for sdist...

ERROR Backend subprocess exited when trying to invoke get_requires_for_build_sdist
Error: Process completed with exit code 1.

What exactly does this backend subprocess error mean? Has anyone encountered this before and found a way to fix it? Any help would be great.

hmm, thas a strange error! it says the package directory doesnt exist, but ur using setup.py. are u mixing src layout with flat layout by accident? what does ur project structure look like?

You’re encountering the backend subprocess error because the build system cannot find your package structure when creating the sdist. The build process is looking for src/mypackage, but it seems that directory is missing. This typically indicates a mismatch between your setup.py configuration and your actual project layout. Verify that the package_dir parameter in setup.py accurately points to the corresponding source structure. If using a src layout, ensure the src directory contains your package folder named exactly as specified in your setup config. I faced a similar issue when my setup.py referenced a package name that didn’t align with my directory structure, and correcting the package_dir mapping resolved the problem immediately.

check ur setup.py - make sure the packages= param points to the actual dirs. missing or wrong paths cause this error all the time. also double-check that you’ve got init.py files where they need to be.