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

Update setup #43

Merged
merged 7 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
72 changes: 72 additions & 0 deletions .github/workflows/run-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Run tests

on:
push:
pull_request:


jobs:
run-test:
name: test-${{ matrix.python-version }}
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "pypy-3.7"

fail-fast: false

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Set up python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade tox setuptools
pip list

- name: Run tests
run: |
tox

run-lint:
name: lint
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version:
- "3.10"

fail-fast: false

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Set up python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade tox setuptools
pip list

- name: Run lint
run: |
tox -e flake8
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
dist/
build/
.venv/
.vscode
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include README.rst LICENSE mimeparse_test.py testdata.json
include README.rst LICENSE mimeparse_test.py testdata.json pyproject.toml
11 changes: 3 additions & 8 deletions mimeparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,9 @@ def quality_and_fitness_parsed(mime_type, parsed_ranges):
for (type, subtype, params) in parsed_ranges:

# check if the type and the subtype match
type_match = (
type in (target_type, '*') or
target_type == '*'
)
subtype_match = (
subtype in (target_subtype, '*') or
target_subtype == '*'
)
type_match = type in (target_type, '*') or target_type == '*'

subtype_match = subtype in (target_subtype, '*') or target_subtype == '*'

# if they do, assess the "fitness" of this mime_type
if type_match and subtype_match:
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=47",
"wheel>=0.34",
]
42 changes: 40 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,40 @@
[bdist_wheel]
universal = 1
[metadata]
name = python-mimeparse
version = attr: mimeparse.__version__
description = A module provides basic functions for parsing mime-type names and matching them against a list of media-ranges.
long_description = file: README.rst
long_description_content_type = text/x-rst
url = https://github.com/falconry/python-mimeparse
author = DB Tsai
author_email = [email protected]
vytas7 marked this conversation as resolved.
Show resolved Hide resolved
maintainer = Falcon team
maintainer_email = [email protected]
license = MIT
license_file = LICENSE
classifiers =
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Topic :: Internet :: WWW/HTTP
Topic :: Software Development :: Libraries :: Python Modules
keywords =
mime-type
project_urls =
Issue Tracker=https://github.com/falconry/python-mimeparse

[options]
python_requires = >=3.6
CaselIT marked this conversation as resolved.
Show resolved Hide resolved
py_modules = mimeparse
install_requires =
tests_require =
pytest
62 changes: 1 addition & 61 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,3 @@
#!/usr/bin/env python

import codecs
import os
import re

from setuptools import setup


def get_version(filename):
"""
Return package version as listed in `__version__` in 'filename'.
"""
with open(filename) as fp:
contents = fp.read()
return re.search("__version__ = ['\"]([^'\"]+)['\"]", contents).group(1)


version = get_version('mimeparse.py')
if not version:
raise RuntimeError('Cannot find version information')


def read(fname):
path = os.path.join(os.path.dirname(__file__), fname)
with codecs.open(path, encoding='utf-8') as fp:
return fp.read()


setup(
name="python-mimeparse",
py_modules=["mimeparse"],
version=version,
description=("A module provides basic functions for parsing mime-type "
"names and matching them against a list of media-ranges."),
author="DB Tsai",
license="MIT",
author_email="[email protected]",
url="https://github.com/dbtsai/python-mimeparse",
download_url=("https://github.com/dbtsai/python-mimeparse/tarball/" +
version),
keywords=["mime-type"],
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Libraries :: Python Modules",
],
long_description=read('README.rst')
)
setup()
30 changes: 3 additions & 27 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,33 +1,9 @@
[tox]
envlist = py37,py36,py35,py34,py32,py27,pypy,pypy3,flake8
envlist = py

[testenv]
commands = python --version
./mimeparse_test.py

[testenv:py37]
basepython = python3.7

[testenv:py36]
basepython = python3.6

[testenv:py35]
basepython = python3.5

[testenv:py34]
basepython = python3.4

[testenv:py32]
basepython = python3.2

[testenv:py27]
basepython = python2.7

[testenv:pypy]
basepython = pypy

[testenv:pypy3]
basepython = pypy3
deps = pytest
commands = pytest

[testenv:flake8]
deps = flake8
Expand Down