Skip to content

Commit 3e4db8e

Browse files
Merge pull request Kludex#54 from Ambro17/master
✨ Migrate package installation to pyproject.toml (PEP 621)
2 parents 299fb19 + 7e059da commit 3e4db8e

File tree

6 files changed

+80
-64
lines changed

6 files changed

+80
-64
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ If you want to test:
2424

2525
.. code-block:: bash
2626
27-
$ pip install -r requirements.txt
28-
$ pytest
27+
$ pip install .[dev]
28+
$ inv test

multipart/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
__author__ = 'Andrew Dunham'
55
__license__ = 'Apache'
66
__copyright__ = "Copyright (c) 2012-2013, Andrew Dunham"
7+
__version__ = "0.0.5"
78

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

1110
from .multipart import (
1211
FormParser,

multipart/_version.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

pyproject.toml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "python-multipart"
7+
dynamic = ["version"]
8+
description = "A streaming multipart parser for Python"
9+
readme = "README.rst"
10+
license = "Apache-2.0"
11+
requires-python = ">=3.7"
12+
authors = [
13+
{ name = "Andrew Dunham", email = "[email protected]" },
14+
]
15+
classifiers = [
16+
'Development Status :: 5 - Production/Stable',
17+
'Environment :: Web Environment',
18+
'Intended Audience :: Developers',
19+
'License :: OSI Approved :: Apache Software License',
20+
'Operating System :: OS Independent',
21+
'Programming Language :: Python :: 3 :: Only',
22+
'Programming Language :: Python :: 3',
23+
'Programming Language :: Python :: 3.7',
24+
'Programming Language :: Python :: 3.8',
25+
'Programming Language :: Python :: 3.9',
26+
'Programming Language :: Python :: 3.10',
27+
'Programming Language :: Python :: 3.11',
28+
'Topic :: Software Development :: Libraries :: Python Modules',
29+
]
30+
dependencies = []
31+
32+
[project.optional-dependencies]
33+
dev = [
34+
"atomicwrites==1.2.1",
35+
"attrs==19.2.0",
36+
"coverage==6.5.0",
37+
"more-itertools==4.3.0",
38+
"pbr==4.3.0",
39+
"pluggy==1.0.0",
40+
"py==1.11.0",
41+
"pytest==7.2.0",
42+
"pytest-cov==4.0.0",
43+
"PyYAML==5.1",
44+
"invoke==1.7.3",
45+
"pytest-timeout==2.1.0",
46+
"hatch",
47+
]
48+
49+
[project.urls]
50+
Homepage = "https://github.com/andrew-d/python-multipart"
51+
Documentation = "https://andrew-d.github.io/python-multipart/"
52+
Changelog = "https://github.com/andrew-d/python-multipart/tags"
53+
Source = "https://github.com/andrew-d/python-multipart"
54+
55+
[tool.hatch.version]
56+
path = "multipart/__init__.py"
57+
58+
[tool.hatch.build.targets.wheel]
59+
packages = [
60+
"multipart",
61+
]
62+
[tool.hatch.build.targets.sdist]
63+
include = [
64+
"/multipart",
65+
]

setup.py

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

tasks.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from invoke import task, run
66

77

8-
version_file = os.path.join('multipart', '_version.py')
8+
version_file = os.path.join('multipart', '__init__.py')
99
version_regex = re.compile(r'((?:\d+)\.(?:\d+)\.(?:\d+))')
1010

1111
# Get around Python 2.X's lack of 'nonlocal' keyword
@@ -14,7 +14,7 @@ class g:
1414

1515

1616
@task
17-
def test(all=False):
17+
def test(ctx, all=False):
1818
test_cmd = [
1919
'pytest', # Test command
2020
'--cov-report term-missing', # Print only uncovered lines to stdout
@@ -37,9 +37,9 @@ def test(all=False):
3737

3838

3939
@task
40-
def bump(type):
40+
def bump(ctx, type):
4141
# Read and parse version.
42-
with open(version_file, 'rb') as f:
42+
with open(version_file, 'r') as f:
4343
file_data = f.read().replace('\r\n', '\n')
4444

4545
m = version_regex.search(file_data)
@@ -68,17 +68,21 @@ def bump(type):
6868
new_ver = ".".join(str(x) for x in ver_nums)
6969
new_data = before + new_ver + after
7070

71-
with open(version_file, 'wb') as f:
71+
with open(version_file, 'w') as f:
7272
f.write(new_data)
7373

7474
# Print information.
7575
print(f"Bumped version from: {version} --> {new_ver}")
7676

7777

78-
@task(pre=['test'])
79-
def deploy():
78+
@task(pre=[test])
79+
def deploy(ctx):
8080
if not g.test_success:
8181
print("Tests must pass before deploying!", file=sys.stderr)
8282
return
8383

84-
run('python setup.py sdist upload')
84+
# # Build source distribution and wheel
85+
run('hatch build')
86+
#
87+
# # Upload distributions from last step to pypi
88+
run('hatch publish')

0 commit comments

Comments
 (0)