Skip to content

Commit

Permalink
Merge pull request #54 from Ambro17/master
Browse files Browse the repository at this point in the history
✨ Migrate package installation to pyproject.toml (PEP 621)
  • Loading branch information
tomchristie committed Dec 12, 2022
2 parents 299fb19 + 7e059da commit 3e4db8e
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 64 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ If you want to test:

.. code-block:: bash
$ pip install -r requirements.txt
$ pytest
$ pip install .[dev]
$ inv test
3 changes: 1 addition & 2 deletions multipart/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
__author__ = 'Andrew Dunham'
__license__ = 'Apache'
__copyright__ = "Copyright (c) 2012-2013, Andrew Dunham"
__version__ = "0.0.5"

# We get the version from a sub-file that can be automatically generated.
from ._version import __version__

from .multipart import (
FormParser,
Expand Down
1 change: 0 additions & 1 deletion multipart/_version.py

This file was deleted.

65 changes: 65 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "python-multipart"
dynamic = ["version"]
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==6.5.0",
"more-itertools==4.3.0",
"pbr==4.3.0",
"pluggy==1.0.0",
"py==1.11.0",
"pytest==7.2.0",
"pytest-cov==4.0.0",
"PyYAML==5.1",
"invoke==1.7.3",
"pytest-timeout==2.1.0",
"hatch",
]

[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"
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",
]
51 changes: 0 additions & 51 deletions setup.py

This file was deleted.

20 changes: 12 additions & 8 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -37,9 +37,9 @@ def test(all=False):


@task
def bump(type):
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)
Expand Down Expand Up @@ -68,17 +68,21 @@ def bump(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.
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')

0 comments on commit 3e4db8e

Please sign in to comment.