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

Move to pyproject.toml and cleanup non-source files #89

Closed
wants to merge 15 commits into from
Closed
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/sample_files/* binary
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 0 additions & 3 deletions AUTHORS

This file was deleted.

8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### 1.0.3 / 2023-12-12

- Move to `pyproject.toml` to support dependabot [#56](https://github.com/tus/tus-py-client/issues/56)
- Remove `AUTHORS`
- Autogenerate `CONTRIBUTORS` from git history
- Update licence to refer to `CONTRIBUTORS`
- Add extra badges to `README.md`

### 1.0.2 / 2023-11-30

- Remove unnecessary future install requirement [#81](https://github.com/tus/tus-py-client/pulls/81)
Expand Down
30 changes: 27 additions & 3 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
Contributors:
# Names should be added to this file as:
# Name <email address>
The following people have contributed to tus-py-client:

Ifedapo Olarewaju ([email protected])
Marius ([email protected])
Mariusz Obajtek ([email protected])
Nykakin ([email protected])
Omer Katz ([email protected])
Kirill Malovitsa ([email protected])
Peixian Wang ([email protected])
VImeo-Loaner ([email protected])
Richo Healey ([email protected])
Brian Gardiner ([email protected])
David D Lowe ([email protected])
mochic808 ([email protected])
mohsenjavidpanah ([email protected])
Adrian Partl ([email protected])
ifedapoolarewaju ([email protected])
Brian Tate ([email protected])
Dave Takahashi ([email protected])
Guang-De Lin ([email protected])
Janne Pulkkinen ([email protected])
Honglei ([email protected])
Hemant Sachdeva ([email protected])
Jasper ([email protected])
Marius Kleidl ([email protected])
Nicola Soranzo ([email protected])
Nicholas Hairs ([email protected])
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 Ifedapo .A. Olarewaju
Copyright (c) The tus-py-client CONTRIBUTORS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include README.md
include CONTRIBUTORS
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# tus-py-client [![Build Status](https://github.com/tus/tus-py-client/actions/workflows/CI.yml/badge.svg)](https://github.com/tus/tus-py-client/actions/workflows/CI.yml)
# tus-py-client
[![PyPi](https://img.shields.io/pypi/v/tuspy.svg)](https://pypi.python.org/pypi/tuspy/)
[![PyPI - Status](https://img.shields.io/pypi/status/tuspy)](https://pypi.python.org/pypi/tuspy/)
[![Python Versions](https://img.shields.io/pypi/pyversions/tuspy.svg)](https://github.com/tus/tus-py-client)
[![License](https://img.shields.io/github/license/tus/tus-py-client.svg)](https://github.com/tus/tus-py-client)
![PyPI - Downloads](https://img.shields.io/pypi/dm/tuspy)
[![Build Status](https://github.com/tus/tus-py-client/actions/workflows/CI.yml/badge.svg)](https://github.com/tus/tus-py-client/actions/workflows/CI.yml)

> **tus** is a protocol based on HTTP for _resumable file uploads_. Resumable
> means that an upload can be interrupted at any moment and can be resumed without
Expand Down Expand Up @@ -107,4 +113,4 @@ If you want to work on tus-py-client internally, follow these few steps:

## License

MIT
This project is licenced under the MIT Licence - see [`LICENSE`](https://github.com/tus/tus-py-client/blob/main/LICENSE).
4 changes: 4 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[mypy]

[mypy-parametrize.*]
ignore_missing_imports = True
81 changes: 81 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "tuspy"
description = "A Python client for the tus resumable upload protocol -> http://tus.io"
authors = [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is someone who is maintain the project that isn't the original author, they should consider adding themselves to the maintainers metadata.

{name = "Ifedapo Olarewaju", email="[email protected]"},
]

# Dependency Information
requires-python = ">=3.8"
dependencies = [
"requests>=2.18.4",
"tinydb>=3.5.0",
"aiohttp>=3.6.2",
]

# Extra Information
readme = "README.md"
license = {text = "MIT Licence"}
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"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",
"Topic :: Communications :: File Sharing",
"Topic :: Internet :: File Transfer Protocol (FTP)",
"Topic :: Software Development :: Libraries :: Python Modules",
"Typing :: Typed",
]

# Misc
dynamic = ["version"]

[project.urls]
Homepage = "http://tus-py-client.readthedocs.io/en/latest/"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like the documentation online has been updated in over 5 years, I've set the metadata to point to this documentation as the homepage but maybe that's a bad idea.

GitHub = "http://github.com/tus/tus-py-client/"

[project.optional-dependencies]
test = [
"aioresponses>=0.6.2",
"coverage>=4.2",
"parametrize", # https://stackoverflow.com/a/67462680/12281814
"pytest>=3.0.3",
"pytest-cov>=2.3.1,<2.6",
"responses>=0.5.1",
]

dev = [
"black",
"mypy",
"sphinx-autobuild==2021.3.14",
"Sphinx==1.7.1",
"tox>=2.3.1",
"types-requests",
]

[tool.setuptools]
packages = [
"tusclient",
"tusclient.fingerprint",
"tusclient.storage",
"tusclient.uploader",
]
include-package-data = true
platforms = ["any"]

[tool.setuptools.dynamic]
version = {attr = "tusclient.__version__"}

51 changes: 0 additions & 51 deletions setup.py

This file was deleted.

11 changes: 6 additions & 5 deletions tests/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

from tusclient import client

FILEPATH_TEXT = "tests/sample_files/text.txt"


class Mixin(unittest.TestCase):
@responses.activate
def setUp(self):
self.client = client.TusClient('http://tusd.tusdemo.net/files/')
self.url = 'http://tusd.tusdemo.net/files/15acd89eabdf5738ffc'
responses.add(responses.HEAD, self.url,
adding_headers={"upload-offset": "0"})
self.uploader = self.client.uploader('./LICENSE', url=self.url)
self.client = client.TusClient("http://tusd.tusdemo.net/files/")
self.url = "http://tusd.tusdemo.net/files/15acd89eabdf5738ffc"
responses.add(responses.HEAD, self.url, adding_headers={"upload-offset": "0"})
self.uploader = self.client.uploader(FILEPATH_TEXT, url=self.url)
Binary file added tests/sample_files/binary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions tests/sample_files/text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) The tus-py-client CONTRIBUTORS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion tests/storage_file
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"_default": {"1": {"url": "http://tusd.tusdemo.net/files/foo_bar", "key": "size:1078--md5:f3e5fa051d458fb7f22eaf03749c8272"}}}
{"_default": {"1": {"key": "size:1082--md5:cbb679e9dbcf82224fe3bc5fdc881f06", "url": "http://tusd.tusdemo.net/files/foo_bar"}, "2": {"key": "size:49588--md5:ae275d47f1ef9aed4902b0251455e627", "url": "http://tusd.tusdemo.net/files/foo_bar"}}}
58 changes: 27 additions & 31 deletions tests/test_async_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,36 @@
from tusclient import exceptions, client


FILEPATH_TEXT = "tests/sample_files/text.txt"


class AsyncUploaderTest(unittest.TestCase):
@responses.activate
def setUp(self):
self.client = client.TusClient('http://tusd.tusdemo.net/files/')
self.url = 'http://tusd.tusdemo.net/files/15acd89eabdf5738ffc'
responses.add(responses.HEAD, self.url,
adding_headers={"upload-offset": "0"})
self.client = client.TusClient("http://tusd.tusdemo.net/files/")
self.url = "http://tusd.tusdemo.net/files/15acd89eabdf5738ffc"
responses.add(responses.HEAD, self.url, adding_headers={"upload-offset": "0"})
self.loop = asyncio.new_event_loop()
self.async_uploader = self.client.async_uploader(
'./LICENSE', url=self.url)
self.async_uploader = self.client.async_uploader(FILEPATH_TEXT, url=self.url)

def tearDown(self):
self.loop.stop()

def _validate_request(self, url, **kwargs):
self.assertEqual(self.url, str(url))
req_headers = kwargs['headers']
self.assertEqual(req_headers.get('Tus-Resumable'), '1.0.0')
req_headers = kwargs["headers"]
self.assertEqual(req_headers.get("Tus-Resumable"), "1.0.0")

body = kwargs['data']
with open('./LICENSE', 'rb') as stream:
body = kwargs["data"]
with open(FILEPATH_TEXT, "rb") as stream:
expected_content = stream.read()
self.assertEqual(expected_content, body)

response_headers = {
'upload-offset': str(self.async_uploader.offset + self.async_uploader.get_request_length())}
"upload-offset": str(
self.async_uploader.offset + self.async_uploader.get_request_length()
)
}

return CallbackResult(status=204, headers=response_headers)

Expand All @@ -52,29 +56,22 @@ def test_upload(self):
resps.patch(self.url, callback=self._validate_request)

self.loop.run_until_complete(self.async_uploader.upload())
self.assertEqual(self.async_uploader.offset,
self.async_uploader.get_file_size())
self.assertEqual(self.async_uploader.offset, self.async_uploader.get_file_size())

def test_upload_empty(self):
with aioresponses() as resps:
resps.post(
self.client.url, status=200,
headers={
"upload-offset": "0",
"location": f"{self.client.url}this-is-not-used"
}
self.client.url,
status=200,
headers={"upload-offset": "0", "location": f"{self.client.url}this-is-not-used"},
)
resps.patch(
f"{self.client.url}this-is-not-used",
exception=ValueError(
"PATCH request not allowed for empty file"
)
exception=ValueError("PATCH request not allowed for empty file"),
)

# Upload an empty file
async_uploader = self.client.async_uploader(
file_stream=io.BytesIO(b"")
)
async_uploader = self.client.async_uploader(file_stream=io.BytesIO(b""))
self.loop.run_until_complete(async_uploader.upload())

# Upload URL being set means the POST request was sent and the empty
Expand All @@ -90,8 +87,7 @@ def test_upload_retry(self):

self.assertEqual(self.async_uploader._retried, 0)
with pytest.raises(exceptions.TusCommunicationError):
self.loop.run_until_complete(
self.async_uploader.upload_chunk())
self.loop.run_until_complete(self.async_uploader.upload_chunk())

self.assertEqual(self.async_uploader._retried, num_of_retries)

Expand All @@ -103,16 +99,16 @@ def test_upload_verify_tls_cert(self):

def validate_verify_tls_cert(url, **kwargs):
nonlocal ssl
ssl = kwargs['ssl']
ssl = kwargs["ssl"]

response_headers = {
'upload-offset': str(self.async_uploader.offset + self.async_uploader.get_request_length())
"upload-offset": str(
self.async_uploader.offset + self.async_uploader.get_request_length()
)
}

return CallbackResult(status=204, headers=response_headers)

resps.patch(
self.url, status=204, callback=validate_verify_tls_cert
)
resps.patch(self.url, status=204, callback=validate_verify_tls_cert)
self.loop.run_until_complete(self.async_uploader.upload())
self.assertEqual(ssl, False)
Loading