pypa / pypa/setuptools

editable install breaks custom package_dir spec

Open
#1,801 15 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Waiting User Feedback
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

I have a project with this directory structure:

- project_folder_name
  - lib
    - __init__.py
    - module.py
    - ...

So in my setup.py I followed the instructions in the docs and set the package_dir:

from setuptools import setup
setup(name='project-name',
      packages=['project'],
      package_dir={'project' : 'lib'},
)

If I install normally python setup.py install everything is fine and I can get the module like: import project. (Possibly another issue but pip install . seems to have issues though.)

However, in development mode python setup.py develop or pip install -e . I can't import via the package name. Strangely, I can import from the folder name import lib.

Just as a reference and sanity check I also tried other organizations that work i.e. "lib/project" with package_dir={'' : 'lib'}. Would like for this directory structure though if possible.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the shown setup.py and the commands python setup.py develop and pip install -e ., then compare them with python setup.py install. Trace the editable-install handling for the custom package_dir mapping. Done means both editable-install paths allow import project rather than only import lib.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.