diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bd84fec3..e06827a6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,11 +30,35 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + # Use abatilo/actions-poetry@v2 to install Poetry + - name: Install Poetry + uses: abatilo/actions-poetry@v2 + with: + poetry-version: 1.5.1 + + # Setup Local Virtual Environment if no poetry.toml file + - name: Setup Local Virtual Environment + run: | + poetry config virtualenvs.create true --local + poetry config virtualenvs.in-project true --local + + # Load Cached Environment if it exists + - name: Load Cached Environment + id: cached-poetry-dependencies + uses: actions/cache@v4 + with: + path: .venv + key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} + + # Install Dependencies if no cached environment + - name: Install Dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root + # Runs a single command using the runners shell - name: Run all tests - run: ./runtests - + run: poetry run ./runtests diff --git a/.gitignore b/.gitignore index 35c96ea1..6186cfa5 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ local/ .vscode/ venv/ pyvenv.cfg +poetry.lock \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 259261b0..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include requirements.txt -include LICENSE -include README.md diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..8f9d7937 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,36 @@ +[tool.poetry] +name = "m3u8" +version = "6.0.0" +description = "Python m3u8 parser" +authors = ["Globo.com"] +license = "MIT" +readme = "README.md" +repository = "https://github.com/globocom/m3u8" +packages = [ + {include = "m3u8"}, + {include = "LICENSE"}, + {include = "README.md"}, +] +classifiers = [ + "License :: OSI Approved :: MIT License", + "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", + "Programming Language :: Python :: 3.12", +] + +[tool.poetry.dependencies] +python = "^3.7" +backports-datetime-fromisoformat = {version = "*", python = "<3.11"} + +[tool.poetry.group.dev.dependencies] +bottle = "*" +pytest = "*" +pytest-cov = ">=2.4.0,<2.6" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 56806d35..00000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,8 +0,0 @@ --r requirements.txt -bottle -pytest -# pytest-cov 2.6.0 has increased the version requirement -# for the coverage package from >=3.7.1 to >=4.4, -# which is in conflict with the version requirement -# defined by the python-coveralls package for coverage==4.0.3 -pytest-cov>=2.4.0,<2.6 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index c785d132..00000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -backports-datetime-fromisoformat; python_version < '3.11' diff --git a/runtests b/runtests index 7d55bd76..d63665b5 100755 --- a/runtests +++ b/runtests @@ -3,12 +3,16 @@ test_server_stdout=tests/server.stdout function install_deps { - pip install -r requirements-dev.txt + if [ -z "$GITHUB_ACTIONS" ]; then + poetry install + else + echo "Skipping dependency installation on GitHub Actions" + fi } function start_server { rm -f ${test_server_stdout} - python tests/m3u8server.py >${test_server_stdout} 2>&1 & + poetry run python tests/m3u8server.py >${test_server_stdout} 2>&1 & } function stop_server { @@ -17,7 +21,7 @@ function stop_server { } function run { - PYTHONPATH=. py.test -vv --cov-report term-missing --cov m3u8 tests/ + poetry run pytest -vv --cov-report term-missing --cov m3u8 tests/ } function main { diff --git a/setup.py b/setup.py deleted file mode 100644 index 237d7aeb..00000000 --- a/setup.py +++ /dev/null @@ -1,28 +0,0 @@ -from os.path import abspath, dirname, exists, join - -from setuptools import setup - -long_description = None -if exists("README.md"): - with open("README.md") as file: - long_description = file.read() - -install_reqs = [ - req for req in open(abspath(join(dirname(__file__), "requirements.txt"))) -] - -setup( - name="m3u8", - author="Globo.com", - version="6.0.0", - license="MIT", - zip_safe=False, - include_package_data=True, - install_requires=install_reqs, - packages=["m3u8"], - url="https://github.com/globocom/m3u8", - description="Python m3u8 parser", - long_description=long_description, - long_description_content_type="text/markdown", - python_requires=">=3.7", -)