Repository navigation
Setup is not working - package name? #492
Description
Activity
- changed the title
[-]Setup issue - package name? [/-][+]Setup is not working - package name? [/+]on Sep 15, 2021 @Leem0sh I'm not able to reproduce this on macOS with Python 3.9.7 (no conda) and the latest
openapi-python-client0.10.4. Here's what I did:openapi-python-client generate --path end_to_end_tests/openapi.json --meta setup(so just using the spec we use for end to end tests)cd my-test-api-clientpython3 -m venv .venvsource .venv/bin/activatepip install .python>>> from my_test_api_client import Client, models, api
No errors. I'm not familiar with
condaat all, does it require something special in thesetup.py? Or maybe this is a Windows thing? I'm really not sure.Would you be able to tinker with the
setup.pyfile and see what it takes to get it working?BTW my
pipversion in the generated virtual environment is 21.2.4.Thanks!
@Leem0sh is there any update on this? I'm hoping to sweep up most of the open bugs this weekend.
Hey @dbanty!
So we were just debugging the issue with my colleague a bit and found out that your example is working, but only bcs you are using
pythonand importing the library with relative pathing. If you'd go into different directory, the import wouldn't be working.Issue is with using
package_dirandfind_pakage(where=...)We tried code below and it was working nicely. What do you think?
import pathlib from setuptools import find_packages, setup here = pathlib.Path(__file__).parent.resolve() long_description = (here / "README.md").read_text(encoding="utf-8") setup( name="<service_name>", version="0.3.0", description="A client library for accessing <service_name>", long_description=long_description, long_description_content_type="text/markdown", packages=find_packages(), python_requires=">=3.6, <4", install_requires=["httpx >= 0.15.0, < 0.19.0", "attrs >= 20.1.0, < 22.0.0", "python-dateutil >= 2.8.0, < 3"], package_data={"": ["CHANGELOG.md"], "<service_name>": ["py.typed"]},Basically in your solution - after creating a wheel file with
python setup.py bdist_wheeland extracting the dist/<wheel_file.WHL>, you can find 3 dirs (image).
When you try our solution, you are getting 2 dirs (the ones, you should get)
Reacted by Václav Dohnal and Dylan Anthony- linked a pull request that will close this issuefix: setup.py should generate importable packages named <project>_client (closes #520) #521
on Oct 25, 2021 - added a commit that references this issue
on Oct 25, 2021
Describe the bug
Unable to import client even after successful generation with setup
To Reproduce
Having a dir
-openapi-gen (ROOT)
--schemas
----dimensions.json
Steps to reproduce the behavior:
Created new env with conda
conda create --name Generators python==3.9.6conda activate Generatorspip install openapi-python-clientopenapi-python-client generate --meta setup --path schemas/dimensionsService.jsonGenerates dimensions-service-client
openapi-gen directory has now 2 directories - schemas + dimensions-service-client
cd dimensions-service-clientpip install .Client is successfully installed.
But now I have a problem. In Pycharm I see that lib is installed, but in site-packages is only
....dist-infodirectory and not any other dir with api, models etc. THEN I noticed thatapiandmodelsdirectories are directly inside the site-packages and not inside its own directory.Expected behavior
Expected to have it's own directory so I can just use
import dimensions_service_clientand notimport api(not mentioning that I'm not able to initiate the Client)The issue is probably connected with
package nameinsidesetup.py?OpenAPI Spec File
Any
Desktop (please complete the following information):