From 07abb9310eca82145403c72ec034688f3e2c937f Mon Sep 17 00:00:00 2001 From: Cory Todd Date: Tue, 20 Jun 2023 11:49:18 -0700 Subject: [PATCH 1/2] packaging: switch back to requirements.txt The pyproject.toml spec is highly opinionated about installing dependencies. As such, locally development is unpleasant when running pip install . since it will always install the package, not just our depends. This complicates testing "the right changes". To promote a better experience, return to using requirements files and make pyproject.toml depend on them dynamically so we don't have to maintain the information in multiple places. Signed-off-by: Cory Todd --- README.rst | 23 +++++++++++++++++++++++ pyproject.toml | 15 +++++---------- requirements-dev.txt | 2 ++ requirements.txt | 1 + 4 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 requirements-dev.txt create mode 100644 requirements.txt diff --git a/README.rst b/README.rst index 65b5f63..8be2218 100644 --- a/README.rst +++ b/README.rst @@ -94,3 +94,26 @@ Examples: $ jdiff a.json b.json -i 2 -s symmetric $ jdiff a.yaml b.yaml -f yaml -s symmetric + +Development +----------- + +Install development dependencies and test locally with + +.. code-block:: bash + + pip install -r requirements-dev.txt + # ... do your work ... add tests ... + pytest + +Installing From Source +---------------------- + +To install from source run + +.. code-block:: bash + + pip install . + +This will install the library and cli for `jsondiff` as well as its runtime +dependencies. diff --git a/pyproject.toml b/pyproject.toml index 1245398..2c822cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "jsondiff" description = "Diff JSON and JSON-like structures in Python" -dynamic = ["version"] +dynamic = ["version", "dependencies", "optional-dependencies"] readme = "README.rst" license= {file = "LICENSE" } requires-python = ">=3.8" @@ -17,15 +17,6 @@ classifiers = [ 'License :: OSI Approved :: MIT License', 'Programming Language :: Python :: 3', ] -dependencies = [ - "pyyaml" -] - -[project.optional-dependencies] -test = [ - "hypothesis", - "pytest" -] [project.urls] "Homepage" = "https://github.com/xlwings/jsondiff" @@ -40,3 +31,7 @@ exclude = ["tests*"] [tool.setuptools.dynamic] version = {attr = "jsondiff.__version__"} +dependencies = {file=["requirements.txt"]} + +[tool.setuptools.dynamic.optional-dependencies] +dev = {file=["requirements-dev.txt"]} diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..9a54149 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,2 @@ +hypothesis +pytest diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c3726e8 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pyyaml From 8f0563ebc037a914cfcd810c446eb563febaa1e7 Mon Sep 17 00:00:00 2001 From: Cory Todd Date: Tue, 20 Jun 2023 12:14:38 -0700 Subject: [PATCH 2/2] ci: update test prep setup The dependencies are now more generically named as dev instead of just test. Signed-off-by: Cory Todd --- .github/workflows/pr_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr_check.yml b/.github/workflows/pr_check.yml index 41155fb..e3d5558 100644 --- a/.github/workflows/pr_check.yml +++ b/.github/workflows/pr_check.yml @@ -19,7 +19,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install Dependencies run: | - pip install .[test] + pip install .[dev] - name: Run Tests run: | python -m pytest