From eb536f722e3ef398d98e956ca6db22d39ca7c991 Mon Sep 17 00:00:00 2001 From: Martin Bernstorff Date: Tue, 7 Feb 2023 11:21:21 +0100 Subject: [PATCH] build: remove poetry (#294) * build: init stab at removing poetry * build: fix typo in toml * build: fix typos in toml * build: remove poetry from build command * chore: prune pre-commit --- .github/actions/test/action.yml | 41 +++-------- .github/workflows/main_test_and_release.yml | 4 - .gitignore | 10 +-- .pre-commit-config.yaml | 29 ++------ pyproject.toml | 81 +++++++++++---------- 5 files changed, 59 insertions(+), 106 deletions(-) diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml index 825b0e6e..6e44293b 100644 --- a/.github/actions/test/action.yml +++ b/.github/actions/test/action.yml @@ -1,16 +1,10 @@ -name: 'Run tests' -description: 'Run tests' +name: "Run tests" +description: "Run tests" inputs: python-version: description: "Which Python version to run on" required: true default: 3.9 - poetry-version: - description: "Which version of Poetry to install" - default: 1.1.15 - cache-version: - description: "Cache version for invalidation" - default: 0.0.0 runs: using: "composite" @@ -20,32 +14,19 @@ runs: uses: actions/setup-python@v4 with: python-version: ${{ inputs.python-version }} - - ### Caching - - name: Cache poetry and venv - id: cache-poetry-and-venv - uses: MartinBernstorff/cache-poetry-and-venv@latest - with: - poetry-version: ${{ inputs.poetry-version }} - cache-version: ${{ inputs.cache-version }} - python-version: ${{ inputs.python-version }} - - # Installing - - name: Install Poetry - if: steps.cache-poetry-and-venv.outputs.poetry-cache-hit != 'true' - uses: snok/install-poetry@v1 - with: - version: ${{ inputs.poetry-version }} - virtualenvs-create: true - virtualenvs-in-project: true + cache: "pip" + cache-dependency-path: "**/pyproject.toml" - name: Install Project - if: steps.cache-poetry-and-venv.outputs.venv-cache-hit != 'true' shell: bash - run: poetry install -vvv - + run: | + python -m pip install --upgrade pip + pip install -e ".[dev]" + ### Run tests - name: Run pytest shell: bash run: | - poetry run pytest --cov=src --cov-report term-missing --color=yes + set -o pipefail + ls -la + pytest --cov=src --cov-report term-missing --color=yes -n 2 diff --git a/.github/workflows/main_test_and_release.yml b/.github/workflows/main_test_and_release.yml index ae94e9a3..2e38c064 100644 --- a/.github/workflows/main_test_and_release.yml +++ b/.github/workflows/main_test_and_release.yml @@ -10,8 +10,6 @@ jobs: test: runs-on: ${{ matrix.os }} env: - poetry-version: 1.1.15 - cache-version: 0.0.2 python-version: 3.9 strategy: @@ -26,8 +24,6 @@ jobs: uses: ./.github/actions/test with: python-version: ${{ env.python-version }} - poetry-version: ${{ env.poetry-version }} - cache-version: ${{ env.cache-version }} release: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index b1f7695c..c787a0be 100644 --- a/.gitignore +++ b/.gitignore @@ -88,14 +88,7 @@ ipython_config.py # However, in case of collaboration, if having platform-specific dependencies or dependencies # having no cross-platform support, pipenv may install dependencies that don't work, or not # install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -poetry.lock +Pipfile.lock # PEP 582; used by e.g. github.com/David-OConnor/pyflow __pypackages__/ @@ -158,6 +151,5 @@ pytest-coverage.txt #other *test_load_data.py -poetry.lock *.html dist* \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f6581d77..af1c9ded 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,4 @@ -default_stages: [commit, push] +default_stages: [push] repos: - repo: https://github.com/pycqa/isort @@ -13,22 +13,10 @@ repos: hooks: - id: pyupgrade - - repo: https://github.com/MartinBernstorff/pybetter-without-emojis - rev: 1208357bcc569b86a4a0dc69b108cbe28f190f54 - hooks: - - id: pybetter - args: [--select, "B002,B007"] - - repo: https://github.com/bwhmather/ssort rev: v0.11.6 hooks: - - id: ssort - - - repo: https://github.com/myint/docformatter - rev: v1.5.0 - hooks: - - id: docformatter - args: [--in-place] + - id: ssort - repo: https://github.com/asottile/add-trailing-comma rev: v2.2.3 @@ -40,21 +28,14 @@ repos: hooks: - id: black - - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 - hooks: - - id: flake8 - args: [--config, .flake8] - - repo: https://github.com/pycqa/pylint rev: v2.15.2 hooks: - id: pylint types: [python] - args: - [ + args: [ "-rn", # Only display messages "-sn", # Don't display the score - "--disable=R,import-error" # Refactors are not important enough to block a commit. - # Unused-imports aren't testable by the github action, so don't test that here. + "--disable=R,import-error", # Refactors are not important enough to block a commit. ] +# Unused-imports aren't testable by the github action, so don't test that here. diff --git a/pyproject.toml b/pyproject.toml index cf99002e..e7084cf6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,13 @@ -[tool.poetry] +[project] name = "psycopmlutils" version = "0.3.1" description = "A collection of machine-learning utilities used across the psycop-projects." -authors = ["Martin Bernstorff "] +authors = [{name = "Martin Bernstorff", email = "martinbernstorff@gmail.com"}, + {name = "Lasse Hansen", email = "lasseh0310@gmail.com"}, + {name = "Kenneth Enevoldsen"}] + +requires-python = ">=3.8.0" + classifiers = [ "Environment :: Console", "Intended Audience :: Developers", @@ -15,41 +20,39 @@ classifiers = [ "Programming Language :: Python :: 3.9", ] -[tool.poetry.dependencies] -# Manually specify catalogue dependencies -pydantic = ">=1.9.0" - -# Other dependencies -python = ">=3.9,<3.11" -numpy = ">=1.23.3,<1.25.0" -scipy = ">=1.8.1,<1.10.0" -pandas = ">=1.4.4,<1.6.0" -catalogue = ">=2.0.8, <2.1.0" -wasabi = ">=0.9.0,<1.2.0" -scikit-learn = ">=1.1.2,<1.3.0" -srsly = ">=2.4.4, <2.5.0" -wandb = ">=0.12.7,<0.13.8" -psutil = ">=5.9.1, <6.0.0" -dill = ">=0.3.5,<0.3.7" -SQLAlchemy = ">=1.4.40,<1.4.46" -pyodbc = ">=4.0.34, <=4.1.0" -transformers = ">=4.22.0,<4.26.0" - -[tool.poetry.dev-dependencies] -black = "22.12.*" -pytest = "7.2.*" -pytest-cov = "4.0.*" -Sphinx = "5.3.*" -furo = ">=2022.6.4,<2022.12.8" -sphinx-copybutton = "0.5.*" -sphinxext-opengraph = "0.7.*" -myst-parser = "0.18.*" -flake8 = "6.0.*" -docformatter = ">=1.4.0,<1.5.2" -mypy = ">=0.971,<0.992" -pytest-xdist = "^3.0.2" -pre-commit = ">=2.20.0,<2.22.0" +dependencies = [ + "pydantic>=1.9.0", + "numpy>=1.23.3,<1.25.0", + "scipy>=1.8.1,<1.10.0", + "pandas>=1.4.4,<1.6.0", + "catalogue>=2.0.8, <2.1.0", + "wasabi>=0.9.0,<1.2.0", + "scikit-learn>=1.1.2,<1.3.0", + "srsly>=2.4.4, <2.5.0", + "wandb>=0.12.7,<0.13.8", + "psutil>=5.9.1, <6.0.0", + "dill>=0.3.5,<0.3.7", + "SQLAlchemy>=1.4.40,<1.4.46", + "pyodbc>=4.0.34, <=4.1.0", + "transformers>=4.22.0,<4.26.0", +] +[project.optional-dependencies] +dev = [ + "black>=22.12.0", + "pytest>=7.2.0", + "pytest-cov>=4.0.0", + "Sphinx>=5.3.0", + "furo>=2022.6.4,<2022.12.8", + "sphinx-copybutton>=0.5.0", + "sphinxext-opengraph>=0.7.0", + "myst-parser>=0.18.0", + "flake8>=6.0.0", + "docformatter>=1.4.0,<1.5.2", + "mypy>=0.971,<0.992", + "pytest-xdist>=3.0.2", + "pre-commit>=2.20.0,<2.22.0", +] [tool.coverage.run] omit = [ @@ -59,8 +62,8 @@ omit = [ ] [build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" +requires = ["setuptools>=61.0.0", "wheel", "setuptools_scm"] +build-backend = "setuptools.build_meta" [tool.isort] known_third_party = ["wandb"] @@ -72,7 +75,7 @@ version_variable = [ ] upload_to_pypi = true upload_to_release = true -build_command = "pip install poetry && poetry build" +build_command = "python -m pip install build; python -m build" [tool.pylint] load-plugins = "pylint.extensions.docparams,pylint.extensions.code_style,pylint.extensions.for_any_all,pylint.extensions.typing"