Skip to content

Commit d08a4bd

Browse files
committed
Streamline python package setup
1 parent 728e83e commit d08a4bd

File tree

10 files changed

+97
-54
lines changed

10 files changed

+97
-54
lines changed

.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# http://editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
indent_style = space
7+
indent_size = 4
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
charset = utf-8
11+
end_of_line = lf
12+
max_line_length = 88
13+
14+
[*.{json,yml,yaml,js,jsx}]
15+
indent_size = 2
16+
17+
[LICENSE]
18+
insert_final_newline = false
19+
20+
[Makefile]
21+
indent_style = tab
File renamed without changes.

MANIFEST.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include s3file/static/s3file/js/s3file.js
2+
prune tests
3+
prune .github
4+
exclude .fussyfox.yml
5+
exclude .travis.yml
6+
exclude .gitignore

requirements-dev.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

s3file/forms.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class S3FileInputMixin:
1414
"""FileInput that uses JavaScript to directly upload to Amazon S3."""
1515

1616
needs_multipart_form = False
17-
upload_path = getattr(settings, 'S3FILE_UPLOAD_PATH', pathlib.PurePosixPath('tmp', 's3file'))
17+
upload_path = getattr(
18+
settings, 'S3FILE_UPLOAD_PATH', pathlib.PurePosixPath('tmp', 's3file')
19+
)
1820
expires = settings.SESSION_COOKIE_AGE
1921

2022
@property
@@ -30,7 +32,8 @@ def build_attrs(self, *args, **kwargs):
3032

3133
accept = attrs.get('accept')
3234
response = self.client.generate_presigned_post(
33-
self.bucket_name, str(pathlib.PurePosixPath(self.upload_folder, '${filename}')),
35+
self.bucket_name,
36+
str(pathlib.PurePosixPath(self.upload_folder, '${filename}')),
3437
Conditions=self.get_conditions(accept),
3538
ExpiresIn=self.expires,
3639
)

setup.cfg

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[metadata]
22
name = django-s3file
33
author = Johannes Hoppe
4-
author-email = [email protected]
5-
summary = A lightweight file uploader input for Django and Amazon S3
6-
description-file = README.rst
7-
home-page = https://github.com/codingjoe/django-s3file
4+
author_email = [email protected]
5+
description = A lightweight file uploader input for Django and Amazon S3
6+
long_description = file: README.rst
7+
url = https://github.com/codingjoe/django-s3file
88
license = MIT
9+
license_file = LICENSE
910
classifier =
1011
Development Status :: 5 - Production/Stable
1112
Environment :: Web Environment
@@ -17,30 +18,62 @@ classifier =
1718
Topic :: Software Development
1819
Programming Language :: Python :: 3
1920

20-
[files]
21-
packages =
22-
s3file
23-
data_files =
24-
s3file/static/ = s3file/static/*
21+
[options]
22+
include_package_data = True
23+
packages = find:
24+
install_requires =
25+
django>=2.0
26+
django-storages
27+
boto3
28+
setup_requires =
29+
setuptools_scm
30+
pytest-runner
31+
tests_require =
32+
pytest
33+
pytest-cov
34+
pytest-django
35+
selenium
36+
37+
[options.package_data]
38+
* = *.txt, *.rst, *.html, *.po
39+
40+
[options.packages.find]
41+
exclude =
42+
tests
43+
44+
[bdist_wheel]
45+
universal = 1
46+
47+
[aliases]
48+
test = pytest
2549

2650
[tool:pytest]
27-
addopts = --tb=short -rxs
51+
addopts = --cov=s3file --cov-report xml --tb=short -rxs
2852
DJANGO_SETTINGS_MODULE=tests.testapp.settings
29-
norecursedirs = env docs .eggs
53+
54+
[tox:tox]
55+
envlist = py{36,37}-dj{20,21,22,master}
56+
57+
[testenv]
58+
deps=
59+
dj20: https://github.com/django/django/archive/stable/2.0.x.tar.gz#egg=django
60+
dj21: https://github.com/django/django/archive/stable/2.1.x.tar.gz#egg=django
61+
dj22: https://github.com/django/django/archive/stable/2.2.x.tar.gz#egg=django
62+
djmaster: https://github.com/django/django/archive/master.tar.gz#egg=django
63+
commands=
64+
python setup.py test
3065

3166
[flake8]
32-
max-line-length = 99
33-
exclude = */migrations/*,docs/*,env/*,.tox/*
67+
max-line-length=88
68+
exclude = venv,.tox,.eggs
3469

3570
[pydocstyle]
36-
add-ignore = D1
37-
match-dir = (?!tests|env|\.).*
71+
add_ignore = D1
3872

3973
[isort]
4074
atomic = true
41-
multi_line_output = 5
42-
line_length = 79
43-
skip = manage.py,.tox,env,.eggs
44-
known_first_party = s3file,tests
45-
known_third_party = django
75+
line_length = 88
76+
known_first_party = s3file, tests
77+
include_trailing_comma = True
78+
default_section=THIRDPARTY
4679
combine_as_imports = true

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#!/usr/bin/env python
22
from setuptools import setup
33

4-
setup(
5-
setup_requires=['pbr'],
6-
pbr=True,
7-
)
4+
setup(use_scm_version=True)

tests/test_forms.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ def test_value_from_datadict_initial_data(self, filemodel):
5959
assert not form.is_valid()
6060

6161
def test_file_does_not_exist_no_fallback(self, filemodel):
62-
form = UploadForm(data={'file': 'foo.bar', 's3file': 'file'}, instance=filemodel)
62+
form = UploadForm(
63+
data={'file': 'foo.bar', 's3file': 'file'},
64+
instance=filemodel,
65+
)
6366
assert form.is_valid()
6467
assert form.cleaned_data['file'] == filemodel.file
6568

@@ -110,14 +113,19 @@ def test_accept(self):
110113

111114
widget = ClearableFileInput(attrs={'accept': 'image/*'})
112115
assert 'accept="image/*"' in widget.render(name='file', value='test.jpg')
113-
assert ["starts-with", "$Content-Type", "image/"] in widget.get_conditions('image/*')
116+
assert [
117+
"starts-with", "$Content-Type", "image/"
118+
] in widget.get_conditions('image/*')
114119

115120
widget = ClearableFileInput(attrs={'accept': 'image/jpeg'})
116121
assert 'accept="image/jpeg"' in widget.render(name='file', value='test.jpg')
117122
assert {"Content-Type": 'image/jpeg'} in widget.get_conditions('image/jpeg')
118123

119124
widget = ClearableFileInput(attrs={'accept': 'application/pdf,image/*'})
120-
assert 'accept="application/pdf,image/*"' in widget.render(name='file', value='test.jpg')
125+
assert 'accept="application/pdf,image/*"' in widget.render(
126+
name='file',
127+
value='test.jpg',
128+
)
121129
assert ["starts-with", "$Content-Type", ""] in widget.get_conditions(
122130
'application/pdf,image/*')
123131
assert {"Content-Type": 'application/pdf'} not in widget.get_conditions(

tox.ini

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)