Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing junos-eznc using pip lacks __init__.py file #653

Closed
SandMouse opened this issue Jan 25, 2017 · 2 comments
Closed

Installing junos-eznc using pip lacks __init__.py file #653

SandMouse opened this issue Jan 25, 2017 · 2 comments

Comments

@SandMouse
Copy link

When I install junos-eznc using pip my intellisense does not recognize it's corresponding folders as a package.

from jnpr.junos.factory.factory_loader import FactoryLoader

This line of code will run and the package loads just fine. Browsing through the files of the package it seems as if the folder 'jnpr' lacks the init.py file. When I add an empty file named init.py manually this issue is solved.

Python: 2.7.12 (via Homebrew)
OS: macOS Sierra 10.12.3
IDE: Visual Studio Code 1.8.1
VSC extention: Python 0.5.6 (donjayamanne.python)
pylint 1.6.4,
astroid 1.4.8

@stacywsmith
Copy link
Contributor

Hi @SandMouse

PyEZ declares jnpr to be a namespace package. This was done to allow other Juniper packages (say a future jnpr.foo package) to coexist with PyEZ under jnpr.
https://github.com/Juniper/py-junos-eznc/blob/master/setup.py#L13

It also includes a jnpr/__init__.py with a recommended (although older method) of dealing with namespace packages:
https://github.com/Juniper/py-junos-eznc/blob/master/lib/jnpr/__init__.py

Unfortunately, there seems to be an issue with pip and/or setuptools which causes this __init__.py to not be installed. There is a long discussion on the issue here:
pypa/pip#3

I understand that pip/setuptools doesn't install the jnpr/__init.py__ file from the PyEZ package because there's a conflict if a jnpr.foo package also provides a jnpr/__init.py__ file. In that case, which file should be installed, and what happens if one of the packages is removed, but the other is not?

I've tried a few unsuccessful ways of working around this issue, and if anyone else has suggestions on how to fix it, I'm definitely interested in hearing.

In general, this is a very minor issue. It really only causes issues in a few unusual circumstances. One of those is obviously the issue you have with intellisense. The issue where I have seen before is when both a jnpr.junos (PyEZ) package and another jnpr.foo package is installed in a different location (such as a local folder where you're doing development.) In this case, one of the packages isn't seen even if both folders are in $PYTHONPATH.

The workaround is to manually copy the contents of https://github.com/Juniper/py-junos-eznc/blob/master/lib/jnpr/__init__.py into jnpr/__init__.py. (NOTE: Installing an empty jnpr/__init__.py as you have done will solve the intellisense issue, but won't solve the case where I encountered the problem.)

I hope this helps you understand the problem, and I'll leave this issue open to see if anyone can come up with a real fix for the problem.

@stacywsmith
Copy link
Contributor

@SandMouse I'm going to close this issue for now. We can re-examine if someone can provide a possible fix or workaround to this pip/setuptools issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants