I installed all dependencies in dist folder
pip install -r requirements.txt --target dist/
I created .whl package for pythonapp using below command: python3 setup.py bdist_wheel
and installed pythonapp-1.0.0-py3-none-any.whl package into dist folder, After that created create pyz file from it from following command
shiv --site-packages dist -e "pythonapp.__main__:main" -o ps.pyz
When I executed pyz package using python ps.pyz
raise ResolverError(msg, sys.exc_info())
connexion.exceptions.ResolverError: \<ResolverError: Cannot resolve operationId "stationdetails.getstationName"! Import error was "No module named 'stationdetails'"\>
I tried using different connexion
resolve like RelativeResolver
, RestyResolver
, but nothing seems to work.
I tried remove init.py file also, but if I remove init.py file, whl package does not include all python files.
Any help would be appreciated.
Directory Structure
test
- setup.py
- dist
- pythonapp
- __init__.py (empty)
- __main__.py
\_ openapi.yml
- stationdetails.py
stationdetails.py
import logging
def getstationName():
pass
openapi.yml
paths:
/getstationName:
get:
tags:
- pythonapp
operationId: stationdetails.getstationName
responses:
'200':
description: ok
import connexion
def main():
app = connexion.App(__name__)
app.add_api('openapi.yml')
app.run(host="0.0.0.0",port=8000)
if __name__ == "__main__":
main()
setup.py (outside pythonapp folder)
from setuptools import find_packages, setup
version = '1.0.0'
setup(name='pythonapp',
version=version,
description='pythonapp',
url='',
author='test',
author_email='',
packages=find_packages(),
data_files=[('pythonapp',
['pythonapp/openapi.yml'])],
include_package_data=True,
zip_safe=False,
)
A shot in the dark, but try changing
operationId: stationdetails.getstationName
to
operationId: pythonapp.stationdetails.getstationName
When connexion is trying to import stationdetails
it'd fail because that module is inside pythonapp
, so adding that to the operationId might fix it.
If the problem persists, please note that .whl and .pyz files are just zip archives, and you can open them to inspect if the stationdetails.py
was copied successfully and the folder structure is intact.