Skip to content

Commit 4179727

Browse files
authored
chore: switch to poetry and source layout (#103)
1 parent 7589c1a commit 4179727

File tree

4 files changed

+45
-30
lines changed

4 files changed

+45
-30
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ jobs:
8383
run: make lint
8484
- name: Test
8585
working-directory: ./sdk-repo-updated
86-
run: make test
86+
run: make test

.github/workflows/sdk-pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ jobs:
6666
GH_REPO: 'stackitcloud/stackit-sdk-python'
6767
GH_TOKEN: ${{ secrets.SDK_PR_TOKEN }}
6868
run: |
69-
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 }})" "[email protected]:stackitcloud/stackit-sdk-python.git" "python"
69+
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 }})" "[email protected]:stackitcloud/stackit-sdk-python.git" "python"

scripts/generate-sdk/languages/python.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,14 @@ generate_python_sdk() {
114114
rm "${SERVICES_FOLDER}/${service}/stackit/__init__.py"
115115
rm "${SERVICES_FOLDER}/${service}/.github/workflows/python.yml"
116116

117+
# Create source layout
118+
mkdir "${SERVICES_FOLDER}/${service}/src"
119+
mv "${SERVICES_FOLDER}/${service}/stackit/" "${SERVICES_FOLDER}/${service}/src/"
117120

118121
# If the service has a wait package files, move them inside the service folder
119-
if [ -d ${sdk_services_backup_dir}/${service}/wait ]; then
122+
if [ -d ${sdk_services_backup_dir}/${service}/src/wait ]; then
120123
echo "Found ${service} \"wait\" package"
121-
cp -r ${sdk_services_backup_dir}/${service}/wait ${SERVICES_FOLDER}/${service}/wait
124+
cp -r ${sdk_services_backup_dir}/${service}/src/wait ${SERVICES_FOLDER}/${service}/src/wait
122125
fi
123126

124127
# If the service has a CHANGELOG file, move it inside the service folder

templates/python/pyproject.mustache

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,60 @@
1-
[project]
1+
[tool.poetry]
22
name = "{{{pythonPackageName}}}"
33
version = "{{{packageVersion}}}"
44
authors = [
5-
{ name="{{infoName}}{{^infoName}}OpenAPI Generator Community{{/infoName}}", email="{{infoEmail}}{{^infoEmail}}[email protected]{{/infoEmail}}" },
5+
"{{infoName}}{{^infoName}}OpenAPI Generator Community{{/infoName}} <{{infoEmail}}{{^infoEmail}}[email protected]{{/infoEmail}}>",
66
]
77
description = "{{{appName}}}"
88
#readme = "README.md"
99
#license = "{{{licenseInfo}}}{{^licenseInfo}}NoLicense{{/licenseInfo}}"
10-
requires-python = ">=3.8"
1110
classifiers = [
1211
"Programming Language :: Python :: 3",
1312
"License :: OSI Approved :: Apache Software License",
1413
"Operating System :: OS Independent",
1514
]
16-
dependencies = [
17-
"requests ~= 2.32.3",
18-
"python_dateutil ~= 2.5.3",
19-
"pydantic ~= 2.9.2",
20-
"stackit-core ~= 0.0.1",
15+
packages = [
16+
{ include = "stackit", from="src" }
2117
]
2218

23-
[project.optional-dependencies]
24-
dev = [
25-
"black >= 24.8.0",
26-
"pytest ~= 8.3.2",
27-
"flake8 ~= 7.1.0",
28-
"flake8-black ~= 0.3.6",
29-
"flake8-pyproject ~= 1.2.3",
30-
"flake8-quotes ~= 3.4.0",
31-
"flake8-bandit ~= 4.1.1",
32-
"flake8-bugbear ~= 24.8.19",
33-
"flake8-eradicate ~= 1.5.0",
34-
"flake8-eol ~= 0.0.8",
35-
"autoimport ~= 1.6.1",
36-
"isort ~= 5.13.2",
19+
[tool.poetry.dependencies]
20+
python = ">=3.8,<4.0"
21+
stackit-core = "^0.0.1"
22+
requests = "^2.32.3"
23+
pydantic = "^2.9.2"
24+
python-dateutil = "^2.9.0.post0"
25+
26+
[tool.poetry.group.dev.dependencies]
27+
black = ">=24.8.0"
28+
pytest = ">=8.3.3"
29+
flake8 = [
30+
{ version= ">=5.0.3", python="<3.12"},
31+
{ version= ">=6.0.1", python=">=3.12"}
3732
]
33+
flake8-black = ">=0.3.6"
34+
flake8-pyproject = ">=1.2.3"
35+
autoimport = ">=1.6.1"
36+
flake8-eol = ">=0.0.8"
37+
flake8-eradicate = ">=1.5.0"
38+
flake8-bandit = ">=4.1.1"
39+
flake8-bugbear = ">=23.1.14"
40+
flake8-quotes = ">=3.4.0"
41+
isort = ">=5.13.2"
3842

3943
[project.urls]
4044
Homepage = "https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}"
4145
Issues = "https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}/issues"
4246

4347
[build-system]
44-
requires = ["setuptools"]
45-
build-backend = "setuptools.build_meta"
48+
requires = ["setuptools", "poetry-core"]
49+
build-backend = "poetry.core.masonry.api"
50+
51+
[tool.pytest.ini_options]
52+
pythonpath = [
53+
"src"
54+
]
55+
testpaths = [
56+
"tests"
57+
]
4658

4759
[tool.black]
4860
line-length = 120
@@ -85,9 +97,9 @@ per-file-ignores = """
8597
./tests/*: S101,
8698
# F841: some variables get generated but may not be used, depending on the api-spec
8799
# E501: long descriptions/string values might lead to lines that are too long
88-
./stackit/*/models/*: F841,E501
100+
./src/stackit/*/models/*: F841,E501
89101
# F841: some variables get generated but may not be used, depending on the api-spec
90102
# E501: long descriptions/string values might lead to lines that are too long
91103
# B028: stacklevel for deprecation warning is irrelevant
92-
./stackit/*/api/default_api.py: F841,B028,E501
104+
./src/stackit/*/api/default_api.py: F841,B028,E501
93105
"""

0 commit comments

Comments
 (0)