Title: Python setuptools: is it mandatory that the package name is the folder name?
Tags: python;python-import;setuptools;packaging
Question: For a specific project, I don't want to store my Python package into a folder with a long name. Using setuptools, and installing in developer mode, I wish I could name my package as I want for the imports, but in a folder with another name:
# Project structure
my-exploratory-analysis
- 2021-04-28_analyse-XY.md
- 2021-04-29_Z-versus-XY.md
- other .py, .ipynb, .sh files
- setup.py  # to install the &quot;tools&quot; as a package
- tools/
- __init__.py
- common_tools.py
- XY_tools.py
- _tests/
From a python analysis:
# wanted import name:
from myexploratory_analysis.common_tools import myregression
Is it mandatory that the folder name becomes the package name? I can't find a workaround.  This question suggests that this is not possible.
Installing something named &quot;tools&quot; system-wide does not seem specific enough, and having a &quot;myexploratory_analysis&quot; nested folder is redundant and cumbersome.
Comment: Just give your package a meaningful name instead of "tools". A _folder with another name_ will break the imports either while developing or after installing.



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2021:00:04/28/21', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><python-import><setuptools><packaging>', 'Title': 'Python setuptools: is it mandatory that the package name is the folder name?', 'ViewCount': 90, 'id': 67307593, 'user_AboutMe': None, 'user_AccountId': 4778217.0, 'user_DisplayName': 'PlasmaBinturong', 'user_Reputation': 1880.0, 'user_Views': 356.0, 'user_id': 4614641.0}}