Skip to content

[BUG] setup.py incorrect using python or python-pydantic-v1 generators when no paths are specified #20090

@loic-seguin

Description

@loic-seguin

Bug Report Checklist

  • [ x] Have you provided a full/minimal spec to reproduce the issue?
  • [ x] Have you validated the input using an OpenAPI validator (example)?
  • [ x] Have you tested with the latest master to confirm the issue still exists?
  • [ x] Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I generate a python client based on my really simple openapi.yaml.
But the setup.py that is generated does not contain the setup() method.
So it is not possible to import this library with poetry or pip.

openapi-generator version

7.9.0 but it seems to have the same issue on 7.0.0

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: RepositoryActions
  version: '1.0'
servers:
  - url: 'http://localhost:3000'
paths: {}
components:
  schemas:
    RepositoryActions:
      type: object
      properties:
        repository_url:
          type: string
        actions:
          type: array
          items:
            $ref: '#/components/schemas/CreateCommentAction'
    CreateCommentAction:
      type: object
      properties:
        text:
          type: string
Generation Details

openapi-generator-cli generate -i openapi.yaml -g python -o ./generated-python-client

Steps to reproduce

openapi-generator-cli generate -i openapi.yaml -g python -o ./generated-python-client

  • Create a new folder testpoetry at the same level of the folder that has been generated
  • Create a new file testpoetry/pyproject.toml with this content
[tool.poetry]
name = "poetrytest"
version = "0.1.0"
description = ""
authors = ["me"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"
openapi-client = {path="../generated-python-client/"}

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Run the command 'poetry install'

You will get this error

poetry install
Updating dependencies
Resolving dependencies... (0.5s)

Package operations: 1 install, 0 updates, 0 removals

  - Installing openapi-client (1.0.0 /home/lseguin/Documents/github_describe_issue/generated-python-client): Failed

  ChefBuildError

  Backend subprocess exited when trying to invoke build_wheel
  
  Traceback (most recent call last):
    File "/home/lseguin/.local/share/pypoetry/venv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
      main()
    File "/home/lseguin/.local/share/pypoetry/venv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in main
      json_out["return_val"] = hook(**hook_input["kwargs"])
    File "/home/lseguin/.local/share/pypoetry/venv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 280, in build_wheel
      return _build_backend().build_wheel(
    File "/tmp/tmp8o7fzmxu/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 435, in build_wheel
      return _build(['bdist_wheel'])
    File "/tmp/tmp8o7fzmxu/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 426, in _build
      return self._build_with_temp_dir(
    File "/tmp/tmp8o7fzmxu/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 409, in _build_with_temp_dir
      result_basename = _file_with_extension(tmp_dist_dir, result_extension)
    File "/tmp/tmp8o7fzmxu/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 128, in _file_with_extension
      raise ValueError(
  ValueError: No distribution was found. Ensure that `setup.py` is not empty and that it calls `setup()`.
  

  at ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/chef.py:164 in _prepare
      160│ 
      161│                 error = ChefBuildError("\n\n".join(message_parts))
      162│ 
      163│             if error is not None:
    → 164│                 raise error from None
      165│ 
      166│             return path
      167│ 
      168│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with openapi-client (1.0.0 /home/lseguin/Documents/github_describe_issue/generated-python-client) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "openapi-client @ file:///home/lseguin/Documents/github_describe_issue/generated-python-client"'.
Suggest a fix

The generation of the setup.py is incorrect, as it should call the setup method for me :

from setuptools import setup, find_packages

NAME = "openapi-client"
VERSION = "1.0.0"
PYTHON_REQUIRES = ">=3.7"
setup(name=NAME,version=VERSION,python_requires=PYTHON_REQUIRES)

This file does not seem to be used properly ->

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions