I've got a very simple wheel file I'm building, which seems to build okay, but it relies on a separate config.py
module that is called upon import, which is failing after pip
installing the wheel file.
Research done: Building a python wheel : "no module named ______" (I can't discern where I'm deviating from that advice)
Project structure:
/easypki
/easypki
/__init__.py
/config.json
/config.py
/easypki.py
README.md
setup.py
Contents of __init__.py
:
#!/usr/bin/python3
__version__ = "0.1"
from . easypki import EasyPKI # main class
from . config import Config # configuration class
Contents of setup.py
:
import pathlib
from setuptools import setup, find_packages
__here__ = pathlib.Path(__file__).parent
README = (__here__ / "README.md").read_text()
setup(
name="easypki",
version="0.1",
description="Even simpler client PKI cert interface",
long_description=README,
long_description_content_type="text/markdown",
url="https://wherever",
author="me",
author_email="my@email.com",
license="MIT",
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7"
],
packages=find_packages(),
include_package_data=True,
install_requires=["requests", "requests_pkcs12"],
)
I am almost 100% sure that I'm going wrong in __init__.py
but am having trouble figuring out exactly what needs changed.
EDIT: adding full error message:
>>> import easypki
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\easypki\__init__.py", line 7, in <module>
from . easypki import EasyPKI
File "C:\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\easypki\__init__.py", line 2, in <module>
from config import Config
ModuleNotFoundError: No module named 'config'
EDIT 2:
I ended up getting this working, however I'm not entirely sure why. I believe it has something to do with how the import call to the config.Config
class was being made from within easypki.py
:
from config import Config
So I did a couple things:
- I moved the
config.Config
import call to withineasypki.EasyPKI
__init__()
method. - I switched the import call to
from .config import Config
- I removed the line
from .config import Config
from__init__.py
as theconfig.Config
class is not (yet) meant to be set directly but is just reading whatever's inconfig.json
.