Issue #42 new

tools package clashed with package from user's project

Сергей Тихонов avatarСергей Тихонов created an issue

The problem is that 'tools' is a common word that shouldn't be used for a top-level package. If I install jira-python as requirements, I can't use my own tools.py, because tools is imported from jira-python package.

Comments (5)

  1. Сергей Тихонов

    It will be not so easy...

    *
    |---apps
        |---tools
        |   |---__init__.py
        |---test_app
            |---__init__.py
            |---test.py
    

    apps/tools/init.py:

    a = "expected constant here"
    

    apps/test_app/init.py:

    import sys
    sys.path.append("apps")
    

    apps/test_app/test.py:

    from tools import a
    

    python apps/test_app/test.py:

    Traceback (most recent call last):
      File "apps/test_app/test.py", line 1, in <module>
        from tools import a
    ImportError: cannot import name a
    
  2. Jajcus

    +1

    No python package should pollute name-space this way. The contents of both tools/ and tests/ directory should be moved under the 'jira' name space.

    Really, there is no reason to install three top-level python packages for a single small library. An 'use virtualenv' is not an answer for everything.

  3. Sorin Sbarnea

    I don't like the idea of moving these outside the jira package because it will prevent me from properly including the jira package near my script. Now if I copy the jira directory the import is solved, but with this change I will miss the tools.

    From what I know you can change the behaviour of import via the init.py files, which seams like a better approach, one that would not have to move the tools, just not to import it by default.

  4. Arun Neelicattu

    Although working around this by modifying jira-python/tools/__init__.py to reuse the tools namespace is a candidate solution, however this would also require others using jira-python to be aware of this. It is still ambiguous from a user's perspective.

    It would make more sense to be able to import using import jira.tools than using import tools independent of weather this is running in a virtual env. Another possibility would be give jirashell it's own (optional) module, this would help separate out IPython as a dep too.

    As for tests, they just need to be excluded from the installation via setup.py.

  5. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.