diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 75325bf..503980e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -83,4 +83,4 @@ jobs: run: make lint - name: Test working-directory: ./sdk-repo-updated - run: make test \ No newline at end of file + run: make test diff --git a/.github/workflows/sdk-pr.yaml b/.github/workflows/sdk-pr.yaml index 0ef6fbb..90a40b3 100644 --- a/.github/workflows/sdk-pr.yaml +++ b/.github/workflows/sdk-pr.yaml @@ -66,4 +66,4 @@ jobs: GH_REPO: 'stackitcloud/stackit-sdk-python' GH_TOKEN: ${{ secrets.SDK_PR_TOKEN }} run: | - scripts/sdk-create-pr.sh "generator-bot-${{ github.run_id }}" "Generated from GitHub run [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" "git@github.com:stackitcloud/stackit-sdk-python.git" "python" \ No newline at end of file + scripts/sdk-create-pr.sh "generator-bot-${{ github.run_id }}" "Generated from GitHub run [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" "git@github.com:stackitcloud/stackit-sdk-python.git" "python" diff --git a/scripts/generate-sdk/languages/python.sh b/scripts/generate-sdk/languages/python.sh index aa35204..c72d84f 100644 --- a/scripts/generate-sdk/languages/python.sh +++ b/scripts/generate-sdk/languages/python.sh @@ -114,11 +114,14 @@ generate_python_sdk() { rm "${SERVICES_FOLDER}/${service}/stackit/__init__.py" rm "${SERVICES_FOLDER}/${service}/.github/workflows/python.yml" + # Create source layout + mkdir "${SERVICES_FOLDER}/${service}/src" + mv "${SERVICES_FOLDER}/${service}/stackit/" "${SERVICES_FOLDER}/${service}/src/" # If the service has a wait package files, move them inside the service folder - if [ -d ${sdk_services_backup_dir}/${service}/wait ]; then + if [ -d ${sdk_services_backup_dir}/${service}/src/wait ]; then echo "Found ${service} \"wait\" package" - cp -r ${sdk_services_backup_dir}/${service}/wait ${SERVICES_FOLDER}/${service}/wait + cp -r ${sdk_services_backup_dir}/${service}/src/wait ${SERVICES_FOLDER}/${service}/src/wait fi # If the service has a CHANGELOG file, move it inside the service folder diff --git a/templates/python/pyproject.mustache b/templates/python/pyproject.mustache index 6cb8712..511ba58 100644 --- a/templates/python/pyproject.mustache +++ b/templates/python/pyproject.mustache @@ -1,48 +1,60 @@ -[project] +[tool.poetry] name = "{{{pythonPackageName}}}" version = "{{{packageVersion}}}" authors = [ - { name="{{infoName}}{{^infoName}}OpenAPI Generator Community{{/infoName}}", email="{{infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}" }, + "{{infoName}}{{^infoName}}OpenAPI Generator Community{{/infoName}} <{{infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}>", ] description = "{{{appName}}}" #readme = "README.md" #license = "{{{licenseInfo}}}{{^licenseInfo}}NoLicense{{/licenseInfo}}" -requires-python = ">=3.8" classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", ] -dependencies = [ - "requests ~= 2.32.3", - "python_dateutil ~= 2.5.3", - "pydantic ~= 2.9.2", - "stackit-core ~= 0.0.1", +packages = [ + { include = "stackit", from="src" } ] -[project.optional-dependencies] -dev = [ - "black >= 24.8.0", - "pytest ~= 8.3.2", - "flake8 ~= 7.1.0", - "flake8-black ~= 0.3.6", - "flake8-pyproject ~= 1.2.3", - "flake8-quotes ~= 3.4.0", - "flake8-bandit ~= 4.1.1", - "flake8-bugbear ~= 24.8.19", - "flake8-eradicate ~= 1.5.0", - "flake8-eol ~= 0.0.8", - "autoimport ~= 1.6.1", - "isort ~= 5.13.2", +[tool.poetry.dependencies] +python = ">=3.8,<4.0" +stackit-core = "^0.0.1" +requests = "^2.32.3" +pydantic = "^2.9.2" +python-dateutil = "^2.9.0.post0" + +[tool.poetry.group.dev.dependencies] +black = ">=24.8.0" +pytest = ">=8.3.3" +flake8 = [ + { version= ">=5.0.3", python="<3.12"}, + { version= ">=6.0.1", python=">=3.12"} ] +flake8-black = ">=0.3.6" +flake8-pyproject = ">=1.2.3" +autoimport = ">=1.6.1" +flake8-eol = ">=0.0.8" +flake8-eradicate = ">=1.5.0" +flake8-bandit = ">=4.1.1" +flake8-bugbear = ">=23.1.14" +flake8-quotes = ">=3.4.0" +isort = ">=5.13.2" [project.urls] Homepage = "https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}" Issues = "https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}/issues" [build-system] -requires = ["setuptools"] -build-backend = "setuptools.build_meta" +requires = ["setuptools", "poetry-core"] +build-backend = "poetry.core.masonry.api" + +[tool.pytest.ini_options] +pythonpath = [ + "src" +] +testpaths = [ + "tests" +] [tool.black] line-length = 120 @@ -85,9 +97,9 @@ per-file-ignores = """ ./tests/*: S101, # F841: some variables get generated but may not be used, depending on the api-spec # E501: long descriptions/string values might lead to lines that are too long - ./stackit/*/models/*: F841,E501 + ./src/stackit/*/models/*: F841,E501 # F841: some variables get generated but may not be used, depending on the api-spec # E501: long descriptions/string values might lead to lines that are too long # B028: stacklevel for deprecation warning is irrelevant - ./stackit/*/api/default_api.py: F841,B028,E501 + ./src/stackit/*/api/default_api.py: F841,B028,E501 """ \ No newline at end of file