Skip to content

Commit 0487b2c

Browse files
authored
Merge pull request #144 from microsoftgraph/task/refactor-packaging
Task/refactor packaging
2 parents db356dd + 661f529 commit 0487b2c

18 files changed

+222
-140
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
pipenv run isort .
3434
- name: Lint with Pylint
3535
run: |
36-
pipenv run pylint msgraph --disable=W --rcfile=.pylintrc
36+
pipenv run pylint src --disable=W --rcfile=.pylintrc
3737
- name: Test with pytest
3838
run: |
3939
pipenv run pytest

.github/workflows/publish.yml

+14-13
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout code
14-
uses: actions/checkout@v2
15-
- name: Set up Python 3.8
16-
uses: actions/setup-python@v1
14+
uses: actions/checkout@v3
15+
- name: Set up Python 3.9
16+
uses: actions/setup-python@v3
1717
with:
18-
python-version: 3.8
19-
- name: Install flit
18+
python-version: 3.9
19+
- name: Install dependencies
2020
run: |
21-
pip install flit
22-
- name: Publish the distibution to PyPI
23-
if: github.repository == 'microsoftgraph/msgraph-sdk-python-core'
24-
run: flit publish
25-
env:
26-
FLIT_INDEX_URL: https://upload.pypi.org/legacy/
27-
FLIT_USERNAME: __token__
28-
FLIT_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
21+
python -m pip install --upgrade pip
22+
pip install build
23+
- name: Build package
24+
run: python -m build
25+
- name: Publish package
26+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
27+
with:
28+
user: __token__
29+
password: ${{ secrets.PYPI_API_TOKEN }}

Pipfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ microsoft-kiota-authentication-azure = "==0.1.0"
1010
httpx = {version = "==0.23.0", extras = ["http2"]}
1111

1212
[dev-packages] # Packages required to develop the application
13-
flit = "==3.7.1"
13+
setuptools = "==65.5.1"
14+
build = "==0.9.0"
15+
bumpver = "==2022.1119"
1416
pylint = "==2.15.4"
1517
mypy = "==0.982"
1618
yapf = "==0.32.0"

Pipfile.lock

+164-94
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

msgraph/core/__init__.py

-10
This file was deleted.

pyproject.toml

+27-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
[build-system]
2-
requires = ["flit_core >=3.2,<4"]
3-
build-backend = "flit_core.buildapi"
2+
requires = ["setuptools>=65.5.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "msgraph-core"
7+
version = "0.2.2"
78
authors = [{name = "Microsoft", email = "[email protected]"}]
9+
description = "Core component of the Microsoft Graph Python SDK"
810
dependencies = [
911
"microsoft-kiota-abstractions >=0.1.0",
1012
"microsoft-kiota-http >=0.1.0",
1113
"httpx[http2] >=0.23.0",
1214
]
15+
requires-python = ">=3.6"
1316
license = {file = "LICENSE"}
1417
readme = "README.md"
1518
keywords = ["msgraph", "openAPI", "Microsoft", "Graph"]
@@ -23,19 +26,18 @@ classifiers = [
2326
"Programming Language :: Python :: 3.11",
2427
"License :: OSI Approved :: MIT License",
2528
]
26-
dynamic = ["version", "description"]
29+
30+
[project.optional-dependencies]
31+
dev = ["yapf", "bumpver", "isort", "pylint", "pytest", "mypy"]
2732

2833
[project.urls]
2934
homepage = "https://github.com/microsoftgraph/msgraph-sdk-python-core#readme"
3035
repository = "https://github.com/microsoftgraph/msgraph-sdk-python-core"
3136
documentation = "https://github.com/microsoftgraph/msgraph-sdk-python-core/docs"
3237

33-
[tool.flit.module]
34-
name = "msgraph"
35-
3638
[tool.mypy]
3739
warn_unused_configs = true
38-
files = "msgraph"
40+
files = "src"
3941
ignore_missing_imports = true
4042

4143
[tool.yapf]
@@ -46,3 +48,21 @@ column_limit = 100
4648

4749
[tool.isort]
4850
profile = "hug"
51+
52+
[tool.pytest.ini_options]
53+
pythonpath = [
54+
"src"
55+
]
56+
57+
[tool.bumpver]
58+
current_version = "0.2.2"
59+
version_pattern = "MAJOR.MINOR.PATCH"
60+
commit_message = "bump version {old_version} -> {new_version}"
61+
commit = true
62+
tag = false
63+
push = false
64+
65+
[tool.bumpver.file_patterns]
66+
"pyproject.toml" = ['current_version = "{version}"', 'version = "{version}"']
67+
"src/msgraph_core/__init__.py" = ["{version}"]
68+

msgraph/__init__.py renamed to src/msgraph_core/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"""
99
Core component of the Microsoft Graph Python SDK consisting of HTTP/Graph Client and a configurable middleware pipeline (Preview).
1010
"""
11-
from .core import SDK_VERSION
11+
from ._constants import SDK_VERSION
12+
from ._enums import APIVersion, NationalClouds
13+
from .base_graph_request_adapter import BaseGraphRequestAdapter
14+
from .graph_client_factory import GraphClientFactory
1215

1316
__version__ = SDK_VERSION
File renamed without changes.
File renamed without changes.

tests/conftest.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import httpx
22
import pytest
33
from kiota_abstractions.authentication import AnonymousAuthenticationProvider
4-
from kiota_authentication_azure.azure_identity_access_token_provider import (
5-
AzureIdentityAccessTokenProvider,
6-
)
74

8-
from msgraph.core import APIVersion, NationalClouds
9-
from msgraph.core.graph_client_factory import GraphClientFactory
10-
from msgraph.core.middleware import GraphRequestContext
5+
from msgraph_core import APIVersion, NationalClouds
6+
from msgraph_core.graph_client_factory import GraphClientFactory
7+
from msgraph_core.middleware import GraphRequestContext
118

129
BASE_URL = NationalClouds.Global + '/' + APIVersion.v1
1310

tests/unit/test_base_graph_request_adapter.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import httpx
22
import pytest
3-
from asyncmock import AsyncMock
43
from kiota_abstractions.serialization import (
54
ParseNodeFactoryRegistry,
65
SerializationWriterFactoryRegistry,
76
)
87

9-
from msgraph.core.base_graph_request_adapter import BaseGraphRequestAdapter
8+
from msgraph_core.base_graph_request_adapter import BaseGraphRequestAdapter
109

1110

1211
def test_create_graph_request_adapter(mock_auth_provider):

tests/unit/test_graph_client_factory.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import pytest
77
from kiota_http.middleware import AsyncKiotaTransport, MiddlewarePipeline, RedirectHandler
88

9-
from msgraph.core import APIVersion, GraphClientFactory, NationalClouds
10-
from msgraph.core.middleware.telemetry import GraphTelemetryHandler
9+
from msgraph_core import APIVersion, GraphClientFactory, NationalClouds
10+
from msgraph_core.middleware.telemetry import GraphTelemetryHandler
1111

1212

1313
def test_create_with_default_middleware():

tests/unit/test_graph_telemetry_handler.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import httpx
1010
import pytest
1111

12-
from msgraph.core import SDK_VERSION, APIVersion, NationalClouds
13-
from msgraph.core._enums import FeatureUsageFlag
14-
from msgraph.core.middleware import GraphRequestContext, GraphTelemetryHandler
12+
from msgraph_core import SDK_VERSION, APIVersion, NationalClouds
13+
from msgraph_core._enums import FeatureUsageFlag
14+
from msgraph_core.middleware import GraphRequestContext, GraphTelemetryHandler
1515

1616
BASE_URL = NationalClouds.Global + '/' + APIVersion.v1
1717

0 commit comments

Comments
 (0)