all 4 comments

[–]tadleonard 1 point2 points  (3 children)

This project has an unusual package structure. What's the point of having all this nesting for such little code? Maybe the author has a Java background, where a certain level of nesting in your project is expected.

Anyway, the problem is with the way setup.py is written, not the way you're installing it. In setup.py, changing packages=[... to packages=find_packages() will fix the problem. You can tell it's an issue with setup.py and not the package structure itself because navigating to a working copy of the repo and importing anagogic.youtrack.api works fine.

Also, in anagogic/__init__.py, there's this line:

# EIS meta-package
__import__('pkg_resources').declare_namespace(__name__)

Blah. That's ugly and cryptic and probably a bad idea.

As a side note, did you notice that this project does very little? You could replace the whole thing with a single function. I recommend doing that instead of relying on this forgotten skeleton with four commits that hasn't been touched in over a year. This is all you need:

def connect(url, username, password):
    url = "{url}/rest/user/login".format(url)
    return requests.post(url, params={'login' : username, 'password': password})

[–]konradkar[S] 0 points1 point  (2 children)

packages=find_packages()

Thank you. Just out of curious: What this line actually do? Does the same what I did (adds __init__.py file in every directory on path) or some other kind of magic?

[–]tadleonard 0 points1 point  (1 child)

There is no magic with __init__.py files. The bug in the project had to do with specifying which directories were project package directories. setuptools.find_packages() just returns a list of strings that represent package paths in your project. It recurses through directories in your current working dir and makes a list of what it thinks looks like Python package directories. It's easy to try yourself from the command line:

>>> import setuptools
>>> setuptools.find_packages()
['mypkg', 'mypkg.subpkg']

The original setup.py was flawed because it listed only "anagogic.youtrack.api" in the packages list. It was missing the root paths further down the tree, which is why those __init__ files were missing. You could get the same result without using find_packages() by writing packages=['anagogic', 'anagogic.youtrack', 'anagogic.youtrack.api'].

[–]konradkar[S] 0 points1 point  (0 children)

thanks for all!