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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-08-04 11:00:00 +0000
Seen: 7 times
Last updated: Apr 08 '22
How can I set up Gunicorn with a Django Project?
Looking for a Python Module that finds Tags for a Text describing its Content
Need a Function in Python to remove entries less than 2 digits from an Array
How can I convert a Document in Python?
How can I program a Loop in Python?
How can I enable Python Code Highlighting in Askbot?