I'm working on a Python project where I've to communicate with the Jira API. I want to use the "offical" Jira client for Python which is available here.
The package introduces a global namespace jira
, meaning you have to
from jira import JIRA
to use the API.
How can I create a sub-package
company.project.datasources.jira
without shadowing the global jira
package?
Let me add a few steps to reproduce my problem and to show what I have in mind:
This is my directory layout:
.
├── company
│ ├── __init__.py
│ └── project
│ ├── datasources
│ │ ├── __init__.py
│ │ └── jira.py
│ └── __init__.py
└── test.py
company/project/datasources/jira.py
# This should be the global class. I don't know how to import it
from jira import JIRA as BaseJira
class JIRA(BaseJira):
# Add something fancy here
pass
test.py
from company.project.datasources.jira import JIRA
custom_jira = JIRA()
When I try:
python test.py
I get the following error:
Traceback (most recent call last):
File "test.py", line 1, in <module>
from company.project.datasources.jira import JIRA
File "/tmp/test/company/project/datasources/jira.py", line 2, in <module>
from jira import JIRA as BaseJira
ImportError: cannot import name JIRA
The __init__.py
are currently all empty files. I've tried a lot with them but it doesn't worked for me. Probably these files are they key to my problem?