Skip to content

Namespace packags and setup.py develop do not place nicely. #12

Closed

Description

@dstufft

setup.py develop uses an egg-link (cross platform symlink basically) in order to make it work. However this fails miserably when the packages you're trying to develop have a setuptools style namespace package.

Activity

  1. jaraco commented on Nov 3, 2013

    @jaraco
    Member

    See pip #3 for a related discussion.

  2. eevee commented on Nov 3, 2013

    @eevee

    fwiw, I've only ever cared about setup.py develop for writing Pylons and Pyramid applications, which rely on entry points because they're run with Paste. If I could just launch them from the project directory like I do everything else then this would be less of a problem.

    Entry points themselves are a glorious mess, too, but we don't have anything better.

  3. ncoghlan commented on Nov 3, 2013

    @ncoghlan
    Member

    We do actually have a bettter option: *.pth files in virtual environments are a much better solution to this than dependency links, since they can handling multi-portion namespace packages properly and transparently.

    *.pth files are only evil in global installations (since they implicitly alter sys.path for everything run in that environment with site module processing enabled)

  4. theacodes commented on Sep 15, 2016

    @theacodes
    Member

    After reading through various stuff on this, I'm still unclear as to what needs to happen for this to be fixed? Does setuptools need to be modified to write a .nspth instead of an .egg-link when running setup.py develop for namespace packages? What are the ramifications of not using .egg-links?

    I'm asking these questions because I'm willing to do the work, but I want to make sure I'm carving the right pumpkin.

  5. ncoghlan commented on Sep 15, 2016

    @ncoghlan
    Member

    @jonparrott I think you're unclear because we're all unclear ;)

    Something I think may fix this is if setup.py develop changed to work as follows:

    • if it sees a venv is active, drop a "-develop.pth" file into the site-packages of the active virtualenv that references the project directory, rather than doing what it does now
    • if it doesn't see an active venv, it keeps doing the same thing it does today

    We may be trading one problem for another (e.g. anyone using a "shared virtualenv" model for multiple projects that they want to keep separate isn't going to like that change), but we would gain a fair bit in simplicity and predictability (since we'd be using a core import system feature, rather than something specific to setuptools)

  6. ncoghlan commented on Sep 15, 2016

    @ncoghlan
    Member

    Related to the "shared virtualenv" problem, I also just realised that .pth files could be used to implement virtualenv inheritance: putting a .pth in venv B that references the site-packages of venv A will give you a situation where venv B sees all changes made in venv A, but anything new you install (including via setup.py develop changed as suggested above) will go solely into venv B.

  7. theacodes commented on Sep 15, 2016

    @theacodes
    Member

    I think you're unclear because we're all unclear ;)

    Oh, that makes me feel better.

    Something I think may fix this

    That sounds reasonable. Could we be even more reasonable and put the new behavior behind a flag (e.g. setup.py develop --use-pth)?

    I also just realised that .pth files could be used to implement virtualenv inheritance

    That sounds interesting, but not a use case I wanna focus on for the moment.

  8. ncoghlan commented on Sep 15, 2016

    @ncoghlan
    Member

    Starting off with the new behaviour behind a flag sounds like an excellent idea, as that enables two things:

    • if the default doesn't work, we can suggest "--use-pth" as a possible fix
    • folks for whom the default currently works can readily test the new behaviour to see if it breaks anything

    That would suggest it also makes sense to add a "--use-egg-link" option to start setting up for a possible future change to the default behaviour (assuming "--use-pth" actually does turn out to fix the current problems).

  9. theacodes commented on Sep 15, 2016

    @theacodes
    Member

    SGTM, I'll start trying to make this materialize.

    FYI, I'm familiar with pip's codebase but not setuptools, so the first draft might be slightly more hacky than expected. :)

  10. theacodes commented on Sep 15, 2016

    @theacodes
    Member

    (rough) PR sent: pypa/setuptools#789

  11. merwok commented on Feb 11, 2025

    @merwok

    We now have standards-based namespace packages and develop install. I hope they work well together*, but if not this would be a normal bug to report to the build backends.

    A setuptools ticket exists and was closed. I think this ticket can be closed @woodruffw

    *(not a fan myself of PEP 420 that makes every data directory an implicit namespace package 😦)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions