diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 39d9f89..89438c9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,10 @@ name: Tests and Codecov on: push: + branches: + - master + - main + - "release/*" pull_request: workflow_dispatch: @@ -23,8 +27,8 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install tox tox-gh-actions + python -m pip install uv + uv pip install --system tox tox-gh-actions - name: Test with tox run: tox @@ -38,9 +42,8 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install poetry - poetry install --with dev + python -m pip install uv poetry + uv pip install --system .[dev] - name: Calculate coverage run: poetry run coverage run --source=pipreqs -m unittest discover diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..34657ab --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,96 @@ +ci: + autoupdate_commit_msg: "chore: update pre-commit hooks" + autofix_commit_msg: "style: pre-commit fixes" + autoupdate_schedule: quarterly + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-added-large-files + args: [ '--maxkb=1000' ] + - id: check-case-conflict + - id: check-merge-conflict + - id: check-symlinks + - id: check-yaml + - id: check-toml + - id: check-json + - id: debug-statements + - id: end-of-file-fixer + - id: mixed-line-ending + - id: requirements-txt-fixer + - id: trailing-whitespace + files: ".*\\.(?:tex|py)$" + args: [ --markdown-linebreak-ext=md ] + exclude: (^notebooks/|^tests/truth/) + - id: detect-private-key + - id: fix-byte-order-marker + - id: check-ast + - id: check-docstring-first + - id: debug-statements + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.10.0 + hooks: + - id: python-use-type-annotations + - id: python-check-mock-methods + - id: python-no-eval + - id: rst-backticks + - id: rst-directive-colons + + - repo: https://github.com/asottile/pyupgrade + rev: v3.3.1 + hooks: + - id: pyupgrade + args: [ --py38-plus ] + + # Notebook formatting + - repo: https://github.com/nbQA-dev/nbQA + rev: 1.9.1 + hooks: + - id: nbqa-isort + additional_dependencies: [ isort ] + + - id: nbqa-pyupgrade + additional_dependencies: [ pyupgrade ] + args: [ --py38-plus ] + + + - repo: https://github.com/kynan/nbstripout + rev: 0.8.1 + hooks: + - id: nbstripout + + - repo: https://github.com/sondrelg/pep585-upgrade + rev: 'v1.0' + hooks: + - id: upgrade-type-hints + args: [ '--futures=true' ] + + - repo: https://github.com/MarcoGorelli/auto-walrus + rev: 0.3.4 + hooks: + - id: auto-walrus + + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.30.0 + hooks: + - id: check-github-workflows + - id: check-github-actions + - id: check-dependabot + - id: check-readthedocs + + - repo: https://github.com/dannysepler/rm_unneeded_f_str + rev: v0.2.0 + hooks: + - id: rm-unneeded-f-str + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: "v0.8.6" + hooks: + - id: ruff + types_or: [ python, pyi, jupyter ] + args: [ --fix, --show-fixes , --line-length=120 ] # --unsafe-fixes, + # Run the formatter. + - id: ruff-format + types_or: [ python, pyi, jupyter ] diff --git a/README.rst b/README.rst index 0b5433e..e166dc6 100644 --- a/README.rst +++ b/README.rst @@ -2,8 +2,8 @@ ``pipreqs`` - Generate requirements.txt file for any project based on imports ============================================================================= -.. image:: https://img.shields.io/travis/bndr/pipreqs.svg - :target: https://travis-ci.org/bndr/pipreqs +.. image:: https://github.com/bndr/pipreqs/actions/workflows/tests.yml/badge.svg + :target: https://github.com/bndr/pipreqs/actions/workflows/tests.yml .. image:: https://img.shields.io/pypi/v/pipreqs.svg diff --git a/pipreqs/mapping b/pipreqs/mapping index 3e0dc37..8edacdd 100644 --- a/pipreqs/mapping +++ b/pipreqs/mapping @@ -36,6 +36,7 @@ Pyxides:astro_pyxis QtCore:PySide S3:s3cmd SCons:pystick +speech_recognition:SpeechRecognition Shared:Zope2 Signals:Zope2 Stemmer:PyStemmer @@ -582,6 +583,7 @@ ctff:tff cups:pycups curator:elasticsearch_curator curl:pycurl +cv2:opencv-python daemon:python_daemon dare:DARE dateutil:python_dateutil @@ -720,6 +722,7 @@ jaraco:jaraco.util jinja2:Jinja2 jiracli:jira_cli johnny:johnny_cache +jose:python_jose jpgrid:python_geohash jpiarea:python_geohash jpype:JPype1 @@ -975,6 +978,7 @@ pysynth_samp:PySynth pythongettext:python_gettext pythonjsonlogger:python_json_logger pyutilib:PyUtilib +pywintypes:pywin32 pyximport:Cython qs:qserve quadtree:python_geohash diff --git a/pipreqs/pipreqs.py b/pipreqs/pipreqs.py index b969ab4..93dcf77 100644 --- a/pipreqs/pipreqs.py +++ b/pipreqs/pipreqs.py @@ -31,7 +31,7 @@ Options: --clean Clean up requirements.txt by removing modules that are not imported in project --mode Enables dynamic versioning with , - or schemes. + or schemes. | e.g. Flask~=1.1.2 | e.g. Flask>=1.1.2 | e.g. Flask @@ -110,6 +110,7 @@ def get_all_imports(path, encoding="utf-8", extra_ignore_dirs=None, follow_links "__pycache__", "env", "venv", + ".venv", ".ipynb_checkpoints", ] diff --git a/pyproject.toml b/pyproject.toml index 0d5909c..9685b7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,16 @@ -[tool.poetry] +[project] name = "pipreqs" version = "0.5.0" description = "Pip requirements.txt generator based on imports in project" -authors = ["Vadim Kravcenko "] +authors = [ + { name = "Vadim Kravcenko", email = "vadim.kravcenko@gmail.com" } +] +maintainers = [ + {name = "Jonas Eschle", email = "jonas.eschle@gmail.com"} +] license = "Apache-2.0" -readme = ["README.rst", "HISTORY.rst"] -packages = [{include = "pipreqs"}] +readme = "README.rst" +packages = [{ include = "pipreqs" }] repository = "https://github.com/bndr/pipreqs" keywords = ["pip", "requirements", "imports"] classifiers = [ @@ -14,30 +19,35 @@ classifiers = [ "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python :: 3", - "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", - "Programming Language :: Python :: 3.13" + "Programming Language :: Python :: 3.13", ] - -[tool.poetry.scripts] -pipreqs = "pipreqs.pipreqs:main" - -[tool.poetry.dependencies] -python = ">=3.8.1,<3.14" -yarg = "0.1.9" -docopt = "0.6.2" -nbconvert = "^7.11.0" -ipython = "8.12.3" - -[tool.poetry.group.dev.dependencies] +requires-python = ">=3.9, <3.14" +dependencies = [ + "yarg>=0.1.9", + "docopt>=0.6.2", + "nbconvert>=7.11.0", + "ipython>=8.12.3", +] +[project.optional-dependencies] +dev = [ + "flake8>=6.1.0", + "tox>=4.11.3", + "coverage>=7.3.2", + "sphinx>=7.2.6;python_version>='3.9'", +] +[tool.poetry.group.dev.dependencies] # for legacy usage flake8 = "^6.1.0" tox = "^4.11.3" coverage = "^7.3.2" sphinx = { version = "^7.2.6", python = ">=3.9" } +[project.scripts] +pipreqs = "pipreqs.pipreqs:main" + [build-system] -requires = ["poetry-core"] +requires = ["poetry-core>=2.0.0,<3.0.0"] build-backend = "poetry.core.masonry.api" diff --git a/tox.ini b/tox.ini index 193f243..49d5bcb 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,9 @@ [tox] isolated_build = true -envlist = py38, py39, py310, py311, py312, py313, pypy3, flake8 +envlist = py39, py310, py311, py312, py313, pypy3, flake8 [gh-actions] python = - 3.8: py38 3.9: py39 3.10: py310 3.11: py311 @@ -15,7 +14,7 @@ python = [testenv] setenv = PYTHONPATH = {toxinidir}:{toxinidir}/pipreqs -commands = +commands = python -m unittest discover [testenv:flake8]