Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PDM for dependency and environment management #397

Closed
wants to merge 15 commits into from
78 changes: 46 additions & 32 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,82 +152,96 @@ jobs:
- ubuntu-latest
- macos-latest
steps:
- name: Check out source
- name: 📥 Check out source
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
- name: 🐍 Set up Python
uses: actions/setup-python@v5
id: pyinstall
with:
python-version: ${{matrix.python}}
cache: 'pip'

- name: Install build tools
- name: 🛠️ Install build tools
run: |
"$PYTHON" -m pip install -U 'uv>=0.1.15'
"$PYTHON" -m pip install -U pdm
env:
PYTHON: ${{ steps.pyinstall.outputs.python-path }}

- name: Set up Python deps
run: uv pip install --python "$PYTHON" -e '.[test]'
env:
PYTHON: ${{ steps.pyinstall.outputs.python-path }}
- name: 📦 Set up Python deps
run: |
pdm venv create "${{matrix.python}}"
pdm lock -S no_cross_platform
pdm install -dG test -v

- name: Inspect environment
- name: 🔍 Inspect environment
run: |
pip list
pdm info
pdm list

- name: Run tests
- name: 🏃🏽‍♀️‍➡️ Run tests
run: |
"$PYTHON" -m pytest --cov=lenskit --cov-report=xml --log-file=test.log
env:
PYTHON: ${{ steps.pyinstall.outputs.python-path }}
pdm run python -m pytest --cov=lenskit --cov-report=xml --log-file=test.log

- name: Process test results
uses: lenskit/lkbuild/actions/save-test-results@main
- name: 🥼 Aggreagate coverage data
run: pdm run coverage xml

- name: 🪵 Upload logs
uses: actions/upload-artifact@v3
with:
artifact-name: test-vanilla-${{matrix.platform}}-py${{matrix.python}}
name: test-vanilla-${{matrix.platform}}-py${{matrix.python}}
path: |
test*.log
coverage.xml

mindep:
name: Minimal Supported Dependencies
runs-on: ubuntu-latest
steps:
- name: Check out source
- name: 📥 Check out source
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
- name: 🐍 Set up Python
uses: actions/setup-python@v5
id: pyinstall
with:
python-version: '3.10'

- name: Install build tools
- name: 🛠️ Install build tools
run: |
"$PYTHON" -m pip install -U 'uv>=0.1.15'
"$PYTHON" -m pip install -U pdm
env:
PYTHON: ${{ steps.pyinstall.outputs.python-path }}

- name: Set up Python deps
run: uv pip install --python "$PYTHON" --resolution=lowest-direct -e '.[test]'
env:
PYTHON: ${{ steps.pyinstall.outputs.python-path }}
- name: 📦 Set up Python deps
run: |
pdm venv create 3.10
pdm lock -S direct_minimal_versions -S no_cross_platform
pdm install -dG test

- name: Inspect environment
- name: 🔍 Inspect environment
run: |
pip list
pdm info
pdm list

- name: Run tests
- name: 🏃🏽‍♀️‍➡️ Run tests
run: |
python -m pytest --cov=lenskit --cov-report=xml --log-file test.log
pdm run python -m pytest --cov=lenskit --cov-report=xml --log-file=test.log

- name: Process Test Results
uses: lenskit/lkbuild/actions/save-test-results@main
- name: 🥼 Aggreagate coverage data
run: pdm run coverage xml

- name: 🪵 Upload logs
uses: actions/upload-artifact@v3
with:
artifact-name: test-mindeps
name: test-vanilla-min-deps
path: |
test*.log
coverage.xml

results:
name: Test Suite Results
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ lenskit/**/*.c
conda-lock.yml
*.lock
*.lock.yml
pdm.lock
.pdm-build/
.pdm-plugins/

# ignore local pdm config
.pdm-python
pdm.toml

# Editor and OS cruft
.DS_Store
Expand Down
80 changes: 55 additions & 25 deletions 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 = ["pdm-backend"]
build-backend = "pdm.backend"

[project]
name = "lenskit"
Expand All @@ -23,7 +23,7 @@ license = { file = "LICENSE.md" }
dynamic = ["version"]
dependencies = [
"pandas >=1.5, <3",
"numpy >= 1.23",
"numpy >= 1.23,<2",
"scipy >= 1.9.0",
"numba >= 0.56, < 0.59",
"torch ~=2.1", # p2c: -s pytorch==2.*
Expand All @@ -36,6 +36,32 @@ dependencies = [
]

[project.optional-dependencies]
sklearn = ["scikit-learn >= 1.1"]

[project.urls]
homepage = "https://lenskit.org"
documentation = "https://lkpy.lenskit.org"
source = "https://github.com/lenskit/lkpy"

# configure build tools
[tool.pdm]
distribution = true

[tool.pdm.version]
source = "scm"

[tool.pdm.build]
includes = [
"lenskit",
]
source-includes = [
"CITATION.cff",
"tests/*",
"docs/*",
"conftest.py",
]

[tool.pdm.dev-dependencies]
dev = [
"setuptools>=64",
"setuptools_scm>=8",
Expand Down Expand Up @@ -71,32 +97,36 @@ demo = [
"nbformat >=5.2",
"ipython >= 7",
]
sklearn = ["scikit-learn >= 1.1"]

[project.urls]
homepage = "https://lenskit.org"
documentation = "https://lkpy.lenskit.org"
source = "https://github.com/lenskit/lkpy"

# configure build tools
[tool.flit.sdist]
include = ["tests/*"]
exclude = [
".github",
"*.ipynb",
"docs",
"data",
"examples",
"build-tools",
"lkbuild",
"tasks.py",
[tool.pdm.conda]
solver = "libmamba"
as-default-manager = true
# auto-excludes = true
runner = "conda"
batched-commands = true
channels = [
"conda-forge",
"pytorch",
"nodefaults",
]
dependencies = [
"tbb",
]
excludes = [
"manylog",
"progress-api",
"seedbank",
"unbeheader",
]

[tool.setuptools]
packages = ["lenskit"]
[tool.pdm.conda.pypi-mapping]
download-dir = "/tmp"

[tool.pdm.conda.dev-dependencies]
dev = [
"just==1.*",
]

[tool.setuptools_scm]
version_scheme = "release-branch-semver"

# settings for generating conda environments for dev & CI, when needed
[tool.pyproject2conda]
Expand Down
Loading