question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

editable install breaks custom package_dir spec

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
itcarrollcommented, Oct 20, 2022

thanks @abravalheri for offering to troubleshoot my pyproject.toml! I was copying the error here when I finally read it in eough detail to realize that package_dir is renamed package-dir for use in pyproject.toml. So this is my now working and equivalent pyproject.toml

[project]
name = "test-1801"
version = "0.1.0"

[tool.setuptools]
packages = ["issue_1801"]
package-dir = { issue_1801 = "src" }

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
0reactions
abravalhericommented, Oct 20, 2022

Thank you for confirming @itcarroll !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Standardising editable mode installs (runtime layout - Packaging
bar" correctly throws an ImportError , but after pip install -e . , I am able to successfully import foo.bar . That came...
Read more >
When would the -e, --editable option be useful with pip install?
As the man page says it: -e,--editable <path/url> Install a project in editable mode (i.e. setuptools "develop mode") from a local project ...
Read more >
Making a Python Package
There are a bunch of nifty tools that help you build, install and distribute packages. ... It is python code, so you can...
Read more >
build backend is missing the 'build_editable' hook. - You.com
Note: To be able to do an editable installation to your user site ( pip install -e --user ) ... My project uses...
Read more >
My How and Why: pyproject.toml & the 'src' Project Structure
Both the pip install -e . and python setup.py develop approaches should now ... setuptools -independent specification of editable installs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found