Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to pyproject.toml #927

Merged
merged 5 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[flake8] # black and isort compatible rules
exclude = .git,.tox,__pycache__,.eggs,dist,venv,.venv*,venv27,virtualenv,adoc,build
max-line-length = 88
ignore = W503,W504,E203

[flake8:local-plugins]
extension =
CLI = globus_cli_flake8:Plugin
paths = ./src/globus_cli/
80 changes: 80 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
[build-system]
requires = ["setuptools>=61.2"]
build-backend = "setuptools.build_meta"

[project]
name = "globus-cli"
description = "Globus CLI"
readme = "README.rst"
authors = [
{ name = "Stephen Rosen", email = "[email protected]" },
]
keywords = [
"globus",
"cli",
"command line",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
requires-python = ">=3.7"
dependencies = [
"globus-sdk==3.34.0",
"click>=8.1.4,<9",
"jmespath==1.0.1",
"packaging>=17.0",
"typing_extensions>=4.0;python_version<'3.11'",
# these are dependencies of the SDK, but they are used directly in the CLI
# declare them here in case the underlying lib ever changes
"requests>=2.19.1,<3.0.0",
"cryptography>=3.3.1",
]
dynamic = ["version"]

[project.urls]
homepage = "https://github.com/globus/globus-cli"

[project.optional-dependencies]
test = [
"coverage>=7",
"pytest>=7",
"pytest-xdist<3",
"pytest-timeout<2",
"click-type-test==0.0.5;python_version>='3.10'",
"responses==0.23.3",
# loading test fixture data
"ruamel.yaml==0.17.32",
# Python 3.12 needs setuptools.
"setuptools;python_version>='3.12'",
]

[project.scripts]
globus = "globus_cli:main"

[tool.setuptools.dynamic.version]
attr = "globus_cli.version.__version__"

[tool.isort]
profile = "black"

[tool.pytest.ini_options]
addopts = "--timeout 3"
filterwarnings = ["error"]

[tool.scriv]
version = "literal: src/globus_cli/version.py: __version__"
categories = "Bugfixes, Enhancements, Other"
# we're using adoc, we'll produce fragments as 'md' and "fix" later
format = "md"
output_file = "changelog.adoc"
entry_title_template = '{{ version }} ({{ date.strftime("%Y-%m-%d") }})'
28 changes: 0 additions & 28 deletions setup.cfg

This file was deleted.

87 changes: 2 additions & 85 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,86 +1,3 @@
import os
import re
from setuptools import setup

from setuptools import find_packages, setup

TEST_REQUIREMENTS = [
"coverage>=7",
"pytest>=7",
"pytest-xdist<3",
"pytest-timeout<2",
"click-type-test==0.0.5;python_version>='3.10'",
"responses==0.23.3",
# loading test fixture data
"ruamel.yaml==0.17.32",
# Python 3.12 needs setuptools.
"setuptools;python_version>='3.12'",
]
DEV_REQUIREMENTS = TEST_REQUIREMENTS + [
"tox>=4",
"scriv==1.3.1",
]


def parse_version():
# single source of truth for package version
version_string = ""
version_pattern = re.compile(r'__version__ = "([^"]*)"')
with open(os.path.join("src", "globus_cli", "version.py")) as f:
for line in f:
match = version_pattern.match(line)
if match:
version_string = match.group(1)
break
if not version_string:
raise RuntimeError("Failed to parse version information")
return version_string


def read_readme():
with open("README.rst") as fp:
return fp.read()


setup(
name="globus-cli",
version=parse_version(),
packages=find_packages("src"),
package_dir={"": "src"},
python_requires=">=3.7",
install_requires=[
"globus-sdk==3.33.0",
"click>=8.1.4,<9",
"jmespath==1.0.1",
"packaging>=17.0",
# these are dependencies of the SDK, but they are used directly in the CLI
# declare them here in case the underlying lib ever changes
"requests>=2.19.1,<3.0.0",
"cryptography>=3.3.1",
# depend on the latest version of typing-extensions on python versions which do
# not have all of the typing features we use
'typing_extensions>=4.0;python_version<"3.11"',
],
extras_require={"test": TEST_REQUIREMENTS, "development": DEV_REQUIREMENTS},
entry_points={"console_scripts": ["globus = globus_cli:main"]},
# descriptive info, non-critical
description="Globus CLI",
long_description=read_readme(),
long_description_content_type="text/x-rst",
author="Stephen Rosen",
author_email="[email protected]",
url="https://github.com/globus/globus-cli",
keywords=["globus", "cli", "command line"],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
)
setup()
2 changes: 1 addition & 1 deletion src/globus_cli/commands/endpoint/permission/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def update_command(
*,
permissions: Literal["r", "rw"],
rule_id: str,
endpoint_id: uuid.UUID
endpoint_id: uuid.UUID,
) -> None:
"""
Update an existing access control rule's permissions.
Expand Down
2 changes: 1 addition & 1 deletion src/globus_cli/commands/endpoint/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def endpoint_show(
login_manager: LoginManager,
*,
endpoint_id: uuid.UUID,
skip_endpoint_type_check: bool
skip_endpoint_type_check: bool,
) -> None:
"""Display a detailed endpoint definition"""
transfer_client = login_manager.get_transfer_client()
Expand Down
4 changes: 3 additions & 1 deletion src/globus_cli/login_manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ def is_logged_in(self) -> bool:
def _validate_token(self, token: str) -> bool:
auth_client = internal_auth_client()
try:
res = auth_client.oauth2_validate_token(token)
res = auth_client.post(
"/v2/oauth2/token/validate", data={"token": token}, encoding="form"
)
# if the instance client is invalid, an AuthAPIError will be raised
except globus_sdk.AuthAPIError:
return False
Expand Down
10 changes: 7 additions & 3 deletions tests/functional/test_login_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@ def test_login_validates_token(
disable_login_manager_validate_token.undo()

with mock.patch("globus_cli.login_manager.manager.internal_auth_client") as m:
ac = mock.MagicMock(spec=globus_sdk.NativeAppAuthClient)
ac = mock.MagicMock(spec=globus_sdk.ConfidentialAppAuthClient)
m.return_value = ac

run_line("globus login")

by_rs = mock_login_token_response.by_resource_server
a_rt = by_rs["auth.globus.org"]["refresh_token"]
t_rt = by_rs["transfer.api.globus.org"]["refresh_token"]
ac.oauth2_validate_token.assert_any_call(a_rt)
ac.oauth2_validate_token.assert_any_call(t_rt)
ac.post.assert_any_call(
"/v2/oauth2/token/validate", data={"token": a_rt}, encoding="form"
)
ac.post.assert_any_call(
"/v2/oauth2/token/validate", data={"token": t_rt}, encoding="form"
)


class MockToken:
Expand Down