From 70baf4de7d9561d193db8078a25946c082b446e1 Mon Sep 17 00:00:00 2001 From: Ambro17 Date: Sat, 19 Nov 2022 18:44:26 -0300 Subject: [PATCH 01/11] =?UTF-8?q?=E2=9C=A8=20Migrate=20package=20installat?= =?UTF-8?q?ion=20to=20pyproject.toml=20(PEP=20621)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.rst | 9 ++++++++ pyproject.toml | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 51 -------------------------------------------- 3 files changed, 67 insertions(+), 51 deletions(-) create mode 100644 pyproject.toml delete mode 100755 setup.py diff --git a/README.rst b/README.rst index 8f8521b..2e2b970 100644 --- a/README.rst +++ b/README.rst @@ -26,3 +26,12 @@ If you want to test: $ pip install -r requirements.txt $ pytest + + +Release new version +---- + +.. code-block:: bash + + $ pip install build + $ python3 -m build diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f4edcd6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,58 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "python-multipart" +version = "0.0.6" # Improvement: Setup to be dynamic from a git tag or release +description = "A streaming multipart parser for Python" +readme = "README.rst" +license = "Apache-2.0" +requires-python = ">=3.7" +authors = [ + { name = "Andrew Dunham", email = "andrew@du.nham.ca" }, +] +classifiers = [ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Web Environment', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3', + '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', + 'Topic :: Software Development :: Libraries :: Python Modules', +] +dependencies = [] + +[project.optional-dependencies] +dev = [ + "atomicwrites==1.2.1", + "attrs==19.2.0", + "coverage==4.5.1", + "more-itertools==4.3.0", + "pbr==4.3.0", + "pluggy==1.0.0", + "py==1.11.0", + "pytest==7.2.0", + "PyYAML==5.1", +] + +[project.urls] +Homepage = "https://github.com/andrew-d/python-multipart" +Documentation = "https://andrew-d.github.io/python-multipart/" +Changelog = "https://github.com/andrew-d/python-multipart/tags" +# Funding = "https://github.com/sponsors/andrew-d" +Source = "https://github.com/andrew-d/python-multipart" + +[tool.hatch.version] +path = "multipart/__init__.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/multipart", +] diff --git a/setup.py b/setup.py deleted file mode 100755 index ba82682..0000000 --- a/setup.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python - -import os -import re -from setuptools import setup - -version_file = os.path.join('multipart', '_version.py') -with open(version_file, 'rb') as f: - version_data = f.read().strip().decode('ascii') - -version_re = re.compile(r'((?:\d+)\.(?:\d+)\.(?:\d+))') -version = version_re.search(version_data).group(0) - -tests_require = [ - 'pytest', - 'pytest-cov', - 'PyYAML' -] - -setup(name='python-multipart', - version=version, - description='A streaming multipart parser for Python', - author='Andrew Dunham', - url='https://github.com/andrew-d/python-multipart', - license='Apache', - platforms='any', - zip_safe=False, - tests_require=tests_require, - packages=[ - 'multipart', - 'multipart.tests', - ], - python_requires='>=3.7', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Web Environment', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache Software License', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3', - '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', - 'Topic :: Software Development :: Libraries :: Python Modules' - ], - test_suite = 'multipart.tests.suite', - ) - From e206857de3adea86a18ad50de18df8be49695e1e Mon Sep 17 00:00:00 2001 From: Ambro17 Date: Sat, 19 Nov 2022 18:56:15 -0300 Subject: [PATCH 02/11] =?UTF-8?q?=E2=9E=95=20Add=20pytest-cov=20as=20a=20d?= =?UTF-8?q?ev=20dependency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index f4edcd6..ec42c30 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ dev = [ "pluggy==1.0.0", "py==1.11.0", "pytest==7.2.0", + "pytest-cov==4.0.0", "PyYAML==5.1", ] From 0d69f8b259ab862da3b9a253ca818444db09e2b6 Mon Sep 17 00:00:00 2001 From: Ambro17 Date: Sat, 19 Nov 2022 19:20:27 -0300 Subject: [PATCH 03/11] =?UTF-8?q?=F0=9F=94=A7=20Make=20version=20dynamic?= =?UTF-8?q?=20as=20in=20starlette?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- multipart/_version.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/multipart/_version.py b/multipart/_version.py index eead319..fa9c4ec 100644 --- a/multipart/_version.py +++ b/multipart/_version.py @@ -1 +1 @@ -__version__ = '0.0.5' +__version__ = '0.0.6' diff --git a/pyproject.toml b/pyproject.toml index ec42c30..003d334 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "python-multipart" -version = "0.0.6" # Improvement: Setup to be dynamic from a git tag or release +dynamic = ["version"] description = "A streaming multipart parser for Python" readme = "README.rst" license = "Apache-2.0" From 9327d046b7e65b3305923cc355aeaa95f46fe674 Mon Sep 17 00:00:00 2001 From: Ambro17 Date: Sat, 19 Nov 2022 19:21:16 -0300 Subject: [PATCH 04/11] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Upgrade=20libraries?= =?UTF-8?q?=20and=20tweak=20due=20to=20api=20changes.=20Also=20added=20mis?= =?UTF-8?q?sing=20libs=20for=20a=20successful=20test=20run?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 5 ++++- tasks.py | 14 +++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 003d334..8dcf491 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ dependencies = [] dev = [ "atomicwrites==1.2.1", "attrs==19.2.0", - "coverage==4.5.1", + "coverage==6.5.0", "more-itertools==4.3.0", "pbr==4.3.0", "pluggy==1.0.0", @@ -41,6 +41,9 @@ dev = [ "pytest==7.2.0", "pytest-cov==4.0.0", "PyYAML==5.1", + "invoke==1.7.3", + "pytest-timeout==2.1.0", + "hatch", ] [project.urls] diff --git a/tasks.py b/tasks.py index b099df3..74592b8 100644 --- a/tasks.py +++ b/tasks.py @@ -14,7 +14,7 @@ class g: @task -def test(all=False): +def test(ctx, all=False): test_cmd = [ 'pytest', # Test command '--cov-report term-missing', # Print only uncovered lines to stdout @@ -37,7 +37,7 @@ def test(all=False): @task -def bump(type): +def bump(ctx, type): # Read and parse version. with open(version_file, 'rb') as f: file_data = f.read().replace('\r\n', '\n') @@ -75,10 +75,14 @@ def bump(type): print(f"Bumped version from: {version} --> {new_ver}") -@task(pre=['test']) -def deploy(): +@task(pre=[test]) +def deploy(ctx): if not g.test_success: print("Tests must pass before deploying!", file=sys.stderr) return - run('python setup.py sdist upload') + # # Build source distribution and wheel + run('hatch build') + # + # # Upload distributions from last step to pypi + run('hatch publish') From 6459f599a36692af995e6f4a2f9b337e2abd323b Mon Sep 17 00:00:00 2001 From: Ambro17 Date: Sat, 19 Nov 2022 19:40:25 -0300 Subject: [PATCH 05/11] =?UTF-8?q?=F0=9F=94=A7=20Fix=20versioning=20task?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- multipart/__init__.py | 3 +-- multipart/_version.py | 1 - tasks.py | 6 +++--- 3 files changed, 4 insertions(+), 6 deletions(-) delete mode 100644 multipart/_version.py diff --git a/multipart/__init__.py b/multipart/__init__.py index 1f04bca..9d3a472 100644 --- a/multipart/__init__.py +++ b/multipart/__init__.py @@ -4,9 +4,8 @@ __author__ = 'Andrew Dunham' __license__ = 'Apache' __copyright__ = "Copyright (c) 2012-2013, Andrew Dunham" +__version__ = "0.0.6" -# We get the version from a sub-file that can be automatically generated. -from ._version import __version__ from .multipart import ( FormParser, diff --git a/multipart/_version.py b/multipart/_version.py deleted file mode 100644 index fa9c4ec..0000000 --- a/multipart/_version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = '0.0.6' diff --git a/tasks.py b/tasks.py index 74592b8..3ac7419 100644 --- a/tasks.py +++ b/tasks.py @@ -5,7 +5,7 @@ from invoke import task, run -version_file = os.path.join('multipart', '_version.py') +version_file = os.path.join('multipart', '__init__.py') version_regex = re.compile(r'((?:\d+)\.(?:\d+)\.(?:\d+))') # Get around Python 2.X's lack of 'nonlocal' keyword @@ -39,7 +39,7 @@ def test(ctx, all=False): @task def bump(ctx, type): # Read and parse version. - with open(version_file, 'rb') as f: + with open(version_file, 'r') as f: file_data = f.read().replace('\r\n', '\n') m = version_regex.search(file_data) @@ -68,7 +68,7 @@ def bump(ctx, type): new_ver = ".".join(str(x) for x in ver_nums) new_data = before + new_ver + after - with open(version_file, 'wb') as f: + with open(version_file, 'w') as f: f.write(new_data) # Print information. From 1015e97e17a86a5294af6f3ad66581fd4d3c75bb Mon Sep 17 00:00:00 2001 From: Ambro17 Date: Sat, 19 Nov 2022 19:40:42 -0300 Subject: [PATCH 06/11] =?UTF-8?q?=F0=9F=93=9A=20Update=20README.rst?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.rst | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index 2e2b970..0a7dac4 100644 --- a/README.rst +++ b/README.rst @@ -24,14 +24,5 @@ If you want to test: .. code-block:: bash - $ pip install -r requirements.txt - $ pytest - - -Release new version ----- - -.. code-block:: bash - - $ pip install build - $ python3 -m build + $ pip install .[dev] + $ inv test From e9fd1eb689f0e1f6f342b97e0d22eebcc31adafe Mon Sep 17 00:00:00 2001 From: Ambro17 Date: Tue, 29 Nov 2022 12:43:21 +0300 Subject: [PATCH 07/11] =?UTF-8?q?=F0=9F=A7=B9=20Remove=20setup.py=20as=20i?= =?UTF-8?q?t=20was=20replaced=20by=20pyproject.toml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 setup.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..bc90da2 --- /dev/null +++ b/setup.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +import os +import re +from setuptools import setup + +version_file = os.path.join('multipart', '__init__.py') +with open(version_file, 'rb') as f: + version_data = f.read().strip().decode('ascii') + +version_re = re.compile(r'((?:\d+)\.(?:\d+)\.(?:\d+))') +version = version_re.search(version_data).group(0) + +tests_require = [ + 'pytest', + 'pytest-cov', + 'PyYAML' +] + +setup(name='python-multipart', + version=version, + description='A streaming multipart parser for Python', + author='Andrew Dunham', + url='https://github.com/andrew-d/python-multipart', + license='Apache-2.0', + platforms='any', + zip_safe=False, + tests_require=tests_require, + packages=[ + 'multipart', + 'multipart.tests', + ], + python_requires='>=3.7', + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Web Environment', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3', + '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', + 'Topic :: Software Development :: Libraries :: Python Modules' + ], + test_suite = 'multipart.tests.suite', + ) + From 9f744a0d8ce034c85d905746eb21d12765879df7 Mon Sep 17 00:00:00 2001 From: Ambro17 Date: Tue, 29 Nov 2022 12:45:22 +0300 Subject: [PATCH 08/11] =?UTF-8?q?=F0=9F=A7=B9=20Remove=20setup.py=20as=20i?= =?UTF-8?q?t=20was=20replaced=20by=20pyproject.toml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.py | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 setup.py diff --git a/setup.py b/setup.py deleted file mode 100644 index bc90da2..0000000 --- a/setup.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python - -import os -import re -from setuptools import setup - -version_file = os.path.join('multipart', '__init__.py') -with open(version_file, 'rb') as f: - version_data = f.read().strip().decode('ascii') - -version_re = re.compile(r'((?:\d+)\.(?:\d+)\.(?:\d+))') -version = version_re.search(version_data).group(0) - -tests_require = [ - 'pytest', - 'pytest-cov', - 'PyYAML' -] - -setup(name='python-multipart', - version=version, - description='A streaming multipart parser for Python', - author='Andrew Dunham', - url='https://github.com/andrew-d/python-multipart', - license='Apache-2.0', - platforms='any', - zip_safe=False, - tests_require=tests_require, - packages=[ - 'multipart', - 'multipart.tests', - ], - python_requires='>=3.7', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Web Environment', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache Software License', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3', - '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', - 'Topic :: Software Development :: Libraries :: Python Modules' - ], - test_suite = 'multipart.tests.suite', - ) - From 49d97813810131cfac60dd8a1a6e53cd1f5a8715 Mon Sep 17 00:00:00 2001 From: Ambro17 Date: Tue, 29 Nov 2022 13:34:00 +0300 Subject: [PATCH 09/11] =?UTF-8?q?=F0=9F=94=A7=20Implement=20hatch's=20auth?= =?UTF-8?q?or=20suggestion=20to=20explicitly=20declare=20wheel=20target=20?= =?UTF-8?q?dir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 8dcf491..5c3a4d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,6 +56,10 @@ Source = "https://github.com/andrew-d/python-multipart" [tool.hatch.version] path = "multipart/__init__.py" +[tool.hatch.build.targets.wheel] +packages = [ + "multipart", +] [tool.hatch.build.targets.sdist] include = [ "/multipart", From 94c4cc332b8a88ac1753feccfac310d58270c628 Mon Sep 17 00:00:00 2001 From: Nahuel Ambrosini Date: Tue, 29 Nov 2022 14:39:40 -0300 Subject: [PATCH 10/11] Update multipart/__init__.py Co-authored-by: Marcelo Trylesinski --- multipart/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multipart/__init__.py b/multipart/__init__.py index 9d3a472..39e5605 100644 --- a/multipart/__init__.py +++ b/multipart/__init__.py @@ -4,7 +4,7 @@ __author__ = 'Andrew Dunham' __license__ = 'Apache' __copyright__ = "Copyright (c) 2012-2013, Andrew Dunham" -__version__ = "0.0.6" +__version__ = "0.0.5" from .multipart import ( From 7e059daf697db65d6edd7a78bdc7040787362aca Mon Sep 17 00:00:00 2001 From: Nahuel Ambrosini Date: Fri, 9 Dec 2022 06:05:40 -0300 Subject: [PATCH 11/11] Update pyproject.toml Co-authored-by: Marcelo Trylesinski --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5c3a4d1..2220432 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,6 @@ dev = [ Homepage = "https://github.com/andrew-d/python-multipart" Documentation = "https://andrew-d.github.io/python-multipart/" Changelog = "https://github.com/andrew-d/python-multipart/tags" -# Funding = "https://github.com/sponsors/andrew-d" Source = "https://github.com/andrew-d/python-multipart" [tool.hatch.version]