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

Fix setuptools package discovery #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

MarkKoz
Copy link

@MarkKoz MarkKoz commented Nov 4, 2023

I tried to install this package on Python 3.9 with pip 23.3.1 and setuptools 68.2.2. It incorrectly installs the package into the root site-packages directory (instead of within an h2p_parser subdirectory). The module is not importable when installed this way.

I don't really know why setuptools installs it that way, but the config seemed relatively complex for what this package needs. package_dir seems unnecessary since the package is in the root directory:

If your packages are not in the root of the repository or do not correspond exactly to the directory structure, you also need to configure package_dir:

(https://setuptools.pypa.io/en/latest/userguide/package_discovery.html)

@MarkKoz
Copy link
Author

MarkKoz commented Nov 4, 2023

Okay this doesn't seem to work — I was initially testing with the repo as the cwd, so I missed this:

>>> import h2p_parser
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Mark\Desktop\virtualenv\lib\site-packages\h2p_parser\__init__.py", line 20, in <module>
    from h2p_parser import data
ImportError: cannot import name 'data' from partially initialized module 'h2p_parser' (most likely due to a circular import) (C:\Users\Mark\Desktop\virtualenv\lib\site-packages\h2p_parser\__init__.py)

Not sure why this is a problem.

@MarkKoz
Copy link
Author

MarkKoz commented Nov 4, 2023

Right, so I was only including the root package and not subpackages. Subpackages would have to be explicitly included when providing a list. So instead, I switched to find_packages.

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

Successfully merging this pull request may close these issues.

None yet

1 participant