Package directory does not exist. Help!

Question:
Hey guys, I’m creating a Python package called natedhaliwal [1] and I see the following error whenever I try to build the package with python setup.py sdist bdist_wheel, to make the essential dist/ directory:

running sdist
running egg_info
writing natedhaliwal.egg-info/PKG-INFO
writing dependency_links to natedhaliwal.egg-info/dependency_links.txt
writing requirements to natedhaliwal.egg-info/requires.txt
writing top-level names to natedhaliwal.egg-info/top_level.txt
error: package directory 'natedhaliwal_package' does not exist

Repl link/Link to where the bug appears:
https://replit.com/@NateDhaliwal/natedhaliwalpackage

Code for setup.py (where the command is to be run in):

from setuptools import setup

setup(
    name='natedhaliwal',
    version='1.0.0',
    description='A package that makes Python easier.',
    author='Nate Dhaliwal',
    author_email='nathaniel.shaan@gmail.com',
    url='https://github.com/NateDhaliwal/NateDhaliwal-Package',
    packages=["natedhaliwal_package"],
    install_requires=[
      "python>=3.10.0,<3.11",
      "flask>=3.0.0",
      "requests>=2.31.0"
    ],
)


I need help as I want to publish this as quickly as I can.

Thanks guys!
P.S. ChatGPT has nothing left to say.


  1. Yes, very imaginatively named… ↩︎

tbh I recommend using poetry for building your projects. I’ll work one of my existing packages into a template.

Erm @Firepup650 using poetry build?

As well as poetry upload, I find it a lot easier to use than buildtools and twine.
I finished the template, here: https://replit.com/@Firepup650/PYPI-Package-template

Ok… I’ll stick to my poetry commands.
I ran poetry publish --build, and it prompted:

There are 2 files ready for publishing. Build anyway? (yes/no)

I have no idea where these 2 files are from. Maybe something to do with my pyproject.toml?

[tool.poetry]
name = "natedhaliwal-package"
version = "1.0.0"
description = "A simple package to help code Python easier."
authors = ["Nate Dhaliwal <nathaniel.shaan@gmail.com>"]
include = ["__init__.py", "pyproject.toml", "example.py"]

[tool.poetry.dependencies]
python = "^3.6"
flask = "^3.0.0"
requests = "^2.31.0"
setuptools = "^68.2.2"
twine = "^4.0.2"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

It sounds like one of your previous commands succeeded in building the package, which would be where it’s finding the existing files to upload.

Also, you don’t need to include the pyproject.toml file in your pyproject.toml.

@Firepup650 Should I include README.md?

Pulling from my template, I don’t even use the include part:

[tool.poetry]
name = "package"
version = "0.0.1"
authors = ["author <email>"]
description = "Description"
readme = "README.md"
classifiers = [
    "Programming Language :: Python :: 3",
    "License :: OSI Approved :: MIT License",
    "Operating System :: OS Independent",
    "Development Status :: 5 - Production/Stable",
    "Environment :: Console",
    "Intended Audience :: Developers",
    "Natural Language :: English",
]
license = "MIT"
repository = "https://github.com/author/your-package"
[tool.poetry.urls]
"Bug Tracker" = "https://github.com/author/your-package/issues"
Replit = "https://replit.com/@author/your-package"

[tool.poetry.dependencies]
python = "^3.8"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

The relevant part about the README is here:

description = "Description"
readme = "README.md"

If you’re uploading using poetry, you can remove these two dependencies.

@Firepup650 Ok thanks!
Gtg now, I’ll come back tomorrow and I’ll check on the Solutions.