Skip to content

Commit

Permalink
Merge pull request #498 from mdekstrand/tweak/hatchling
Browse files Browse the repository at this point in the history
Switch package builds to Hatchling
  • Loading branch information
mdekstrand authored Oct 26, 2024
2 parents 1b8ac5b + f2872fc commit a2f9eb5
Show file tree
Hide file tree
Showing 20 changed files with 338 additions and 260 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ jobs:
python -m lenskit.data.fetch ml-100k ml-20m
- name: Run Eval Tests
run: |
python -m pytest --cov=lenskit/lenskit --cov=lenskit-funksvd/lenskit --cov=lenskit-implicit/lenskit --cov=lenskit-hpf/lenskit -m 'eval or realdata' --log-file test-eval.log */tests
pytest --cov=lenskit/lenskit --cov=lenskit-funksvd/lenskit --cov=lenskit-implicit/lenskit --cov=lenskit-hpf/lenskit -m 'eval or realdata' --log-file test-eval.log */tests
- name: "📐 Coverage results"
run: |
coverage xml
Expand Down Expand Up @@ -520,7 +520,7 @@ jobs:
python -m lenskit.data.fetch ml-100k ml-1m ml-10m ml-20m
- name: "📕 Validate documentation examples"
run: |
python -m pytest --cov=lenskit/lenskit --cov=lenskit-funksvd/lenskit --cov=lenskit-implicit/lenskit --cov=lenskit-hpf/lenskit --nbval-lax --doctest-glob='*.rst' --log-file test-docs.log docs */lenskit
pytest --cov=lenskit/lenskit --cov=lenskit-funksvd/lenskit --cov=lenskit-implicit/lenskit --cov=lenskit-hpf/lenskit --nbval-lax --doctest-glob='*.rst' --log-file test-docs.log docs */lenskit
- name: "📐 Coverage results"
run: |
coverage xml
Expand Down Expand Up @@ -570,6 +570,8 @@ jobs:
log-level: vv
locked: false
frozen: true
- name: "🔨 Build _version.py"
run: pipx run build lenskit
- name: "📥 Download test artifacts"
uses: actions/download-artifact@v4
with:
Expand All @@ -593,7 +595,7 @@ jobs:
if: github.event_name == 'pull_request'
run: |
diff-cover --json-report diff-cover.json --markdown-report diff-cover.md \
coverage.xml |tee diff-cover.txt
coverage.xml |tee diff-cover.txt
- name: ± Measure and report coverage
run: |
echo $PR_NUMBER > ./lenskit-coverage/pr-number
Expand Down
1 change: 1 addition & 0 deletions .vscode/ltex.dictionary.en-US.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Scikit-Learn
unpickle
rerankers
LKPY
FunkSVD
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ correct modified version of LensKit until your changes make it in to a release.
## Resources

- [Documentation](https://lkpy.lenskit.org)
- [Mailing list, etc.](https://lenskit.org/connect)
- [Discussion and Announcements](https://github.com/orgs/lenskit/discussions)

## Acknowledgements

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Throughout this documentation, we use the notation of :cite:t:`ekstrand:notation
Resources
---------

- `Mailing list, etc. <https://lenskit.org/connect>`_
- `Discussion and Announcements <https://github.com/orgs/lenskit/discussions>`_
- `Source and issues on GitHub <https://github.com/lenskit/lkpy>`_

.. toctree::
Expand Down
1 change: 1 addition & 0 deletions lenskit-funksvd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# FunkSVD package for LensKit
20 changes: 13 additions & 7 deletions lenskit-funksvd/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"
requires = ["hatchling ~=1.0", "hatch-vcs ~=0.4.0"]
build-backend = "hatchling.build"

[project]
name = "lenskit-funksvd"
Expand All @@ -26,9 +26,15 @@ documentation = "https://lkpy.lenskit.org"
source = "https://github.com/lenskit/lkpy"

# configure build tools
[tool.setuptools.packages.find]
include = ["lenskit*"]
[tool.hatch.metadata]
allow-direct-references = true

[tool.setuptools_scm]
version_scheme = "release-branch-semver"
root = ".."
[tool.hatch.build.targets.sdist]
include = ["/lenskit", "LICENSE.md", "README.md"]

[tool.hatch.build.targets.wheel]
packages = ["lenskit"]

[tool.hatch.version]
source = "vcs"
raw-options = { root = "..", version_scheme = "release-branch-semver" }
20 changes: 20 additions & 0 deletions lenskit-hpf/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2018–2023 Boise State University
Copyright (c) 2023-2024 Drexel University and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
20 changes: 13 additions & 7 deletions lenskit-hpf/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"
requires = ["hatchling ~=1.0", "hatch-vcs ~=0.4.0"]
build-backend = "hatchling.build"

[project]
name = "lenskit-hpf"
Expand All @@ -22,9 +22,15 @@ homepage = "https://lenskit.org"
documentation = "https://lkpy.lenskit.org"
source = "https://github.com/lenskit/lkpy"

[tool.setuptools.packages.find]
include = ["lenskit*"]
[tool.hatch.metadata]
allow-direct-references = true

[tool.setuptools_scm]
version_scheme = "release-branch-semver"
root = ".."
[tool.hatch.build.targets.sdist]
include = ["/lenskit", "LICENSE.md", "README.md"]

[tool.hatch.build.targets.wheel]
packages = ["lenskit"]

[tool.hatch.version]
source = "vcs"
raw-options = { root = "..", version_scheme = "release-branch-semver" }
20 changes: 20 additions & 0 deletions lenskit-implicit/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2018–2023 Boise State University
Copyright (c) 2023-2024 Drexel University and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
20 changes: 13 additions & 7 deletions lenskit-implicit/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"
requires = ["hatchling ~=1.0", "hatch-vcs ~=0.4.0"]
build-backend = "hatchling.build"

[project]
name = "lenskit-implicit"
Expand All @@ -23,9 +23,15 @@ documentation = "https://lkpy.lenskit.org"
source = "https://github.com/lenskit/lkpy"

# configure build tools
[tool.setuptools.packages.find]
include = ["lenskit*"]
[tool.hatch.metadata]
allow-direct-references = true

[tool.setuptools_scm]
version_scheme = "release-branch-semver"
root = ".."
[tool.hatch.build.targets.sdist]
include = ["/lenskit", "LICENSE.md", "README.md"]

[tool.hatch.build.targets.wheel]
packages = ["lenskit"]

[tool.hatch.version]
source = "vcs"
raw-options = { root = "..", version_scheme = "release-branch-semver" }
1 change: 1 addition & 0 deletions lenskit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lenskit/_version.py
52 changes: 0 additions & 52 deletions lenskit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,58 +41,6 @@ To use the latest development version, install directly from GitHub:

Then see [Getting Started](https://lkpy.lenskit.org/en/latest/GettingStarted.html)

## Developing

[issues]: https://github.com/lenskit/lkpy/issues
[workflow]: https://github.com/lenskit/lkpy/wiki/DevWorkflow

To contribute to LensKit, clone or fork the repository, get to work, and submit
a pull request. We welcome contributions from anyone; if you are looking for a
place to get started, see the [issue tracker][issues].

Our development workflow is documented in [the wiki][workflow]; the wiki also
contains other information on *developing* LensKit. User-facing documentation is
at <https://lkpy.lenskit.org>.

[conda-lock]: https://github.com/conda-incubator/conda-lock
[lkdev]: https://github.com/lenskit/lkdev

We recommend using an Anaconda environment for developing LensKit. We provide a
tool to automate setting up Conda environments from the LensKit dependencies; to
create a dev environment, checkout LensKit, then run:

pipx ./utils/conda-tool.py --env -n lkpy pyproject.toml dev-requirements.txt

That will create an environment named `lkpy` with all the LensKit dependencies.

## Testing Changes

You should always test your changes by running the LensKit test suite:

python -m pytest

If you want to use your changes in a LensKit experiment, you can locally install
your modified LensKit into your experiment's environment. We recommend using
separate environments for LensKit development and for each experiment; you will
need to install the modified LensKit into your experiment's repository:

conda activate my-exp
conda install -c conda-forge
cd /path/to/lkpy
pip install -e . --no-deps

You may need to first uninstall LensKit from your experiment repo; make sure that
LensKit's dependencies are all still installed.

Once you have pushed your code to a GitHub branch, you can use a Git repository as
a Pip dependency in an `environment.yml` for your experiment, to keep using the
correct modified version of LensKit until your changes make it in to a release.

## Resources

- [Documentation](https://lkpy.lenskit.org)
- [Mailing list, etc.](https://lenskit.org/connect)

## Acknowledgements

This material is based upon work supported by the National Science Foundation
Expand Down
23 changes: 16 additions & 7 deletions lenskit/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"
requires = ["hatchling ~=1.0", "hatch-vcs ~=0.4.0"]
build-backend = "hatchling.build"

[project]
name = "lenskit"
Expand Down Expand Up @@ -49,9 +49,18 @@ documentation = "https://lkpy.lenskit.org"
source = "https://github.com/lenskit/lkpy"

# configure build tools
[tool.setuptools.packages.find]
include = ["lenskit*"]
[tool.hatch.metadata]
allow-direct-references = true

[tool.setuptools_scm]
version_scheme = "release-branch-semver"
root = ".."
[tool.hatch.build.targets.sdist]
include = ["/lenskit", "LICENSE.md", "README.md"]

[tool.hatch.build.targets.wheel]
packages = ["lenskit"]

[tool.hatch.version]
source = "vcs"
raw-options = { root = "..", version_scheme = "release-branch-semver" }

[tool.hatch.build.hooks.vcs]
version-file = "lenskit/_version.py"
5 changes: 4 additions & 1 deletion lenskit/tests/pipeline/test_save_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# SPDX-License-Identifier: MIT

import logging
import re
from types import NoneType

import numpy as np
Expand Down Expand Up @@ -107,7 +108,9 @@ def test_config_single_node():
assert len(cfg.inputs) == 1
assert len(cfg.components) == 1

assert cfg.components["return"].code == "lenskit.tests.pipeline.test_save_load:msg_ident"
assert re.match(
r"((lenskit\.)?tests\.)?pipeline\.test_save_load:msg_ident", cfg.components["return"].code
)
assert cfg.components["return"].config is None
assert cfg.components["return"].inputs == {"msg": "msg"}

Expand Down
Loading

0 comments on commit a2f9eb5

Please sign in to comment.