Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use setuptools without the src directory by using the package_dir option in the setup() function. Here's an example:

from setuptools import setup, find_packages

setup(
    name='my_package',
    version='1.0.0',
    packages=find_packages(),
    package_dir={'': 'my_package'},  # specify the root package directory
    # other configuration options...
)

In this example, we assume that your package structure looks like this:

my_package/
├── __init__.py
├── module1.py
└── module2.py

With the packagedir option, we specify that the root package directory is 'mypackage'. This means that setuptools will look for Python modules in 'my_package' instead of the default 'src' directory.

You can then install and use your package like this:

pip install .

And import modules from your package like this:

from my_package.module1 import some_function

Note that you may also need to update your import statements to reflect the change in package directory.