Skip to content

Commit

Permalink
Update min versions of dependencies and drop 3.7 (NicolasHug#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug committed Aug 21, 2022
1 parent c505e10 commit 3a387e1
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
branches: [ "master" ]

jobs:
build:
Benchmark:

runs-on: ubuntu-latest
strategy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ jobs:
make html
- uses: actions/upload-artifact@v3
with:
name: my-artifact
name: the-docs
path: doc/build/html
87 changes: 87 additions & 0 deletions .github/workflows/build_sdist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# This workflow builds the sdist on 3.8 and then installs that same sdist on
# clean envs from all python versions, then runs tests.
# We also try to replace numpy with oldest-supported-numpy as install-time
# dependency (install-time == installing from the sdist with the .c files
# present). I'm not sure this is the intended use for the package, but this is
# the only way I can find to test on an "old" version of numpy, instead of the
# latest available like the regular `numpy>=X` constraint would do.

name: Build sdist and test

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
use-oldest-numpy: [true, false]

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: "3.8"

- name: Force min dep
if: ${{ matrix.use-oldest-numpy}}
run: |
sed -i "s/numpy.*/oldest-supported-numpy/g" requirements.txt
cat requirements*.txt
- name: Build sdist
run: |
set -x
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
pip freeze
python setup.py sdist
- uses: actions/upload-artifact@v3
with:
name: the-sdist-${{ matrix.use-oldest-numpy }}
path: dist/scikit-surprise-1.1.1.tar.gz

install-and-test:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
use-oldest-numpy : [true, false]
needs: build
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: the-sdist-${{ matrix.use-oldest-numpy}}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install sdist
run: |
set -x
python -m pip install --upgrade pip
pip install scikit-surprise-1.1.1.tar.gz -v
- name: Pip freeze
run: |
pip freeze
- name: Run unit tests
run: |
pip install pytest pandas
pytest -v
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
branches: [ "master" ]

jobs:
build:
lint:

runs-on: ubuntu-latest
strategy:
Expand Down
37 changes: 0 additions & 37 deletions .github/workflows/unit-tests.yml

This file was deleted.

7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
joblib>=0.11
numpy>=1.11.2
scipy>=1.0.0
# Lower bounds for deps are as in scikit-learn in Aug 22, 1.2.dev
joblib>=1.0.0
numpy>=1.17.3 # also in setup.py
scipy>=1.3.2
14 changes: 7 additions & 7 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Requirements file for development
Cython>=0.24.1
joblib>=0.11
numpy>=1.11.2
# Lower bounds for deps are as in scikit-learn in Aug 22, 1.2.dev
Cython>=0.29.24
joblib>=1.0.0
numpy>=1.17.3 # also in setup.py
scipy>=1.3.2
pandas
pytest>=3.0.3
scipy>=1.0.0
sphinx>=1.4.9
pytest
sphinx
sphinx_rtd_theme
sphinxcontrib-bibtex
sphinxcontrib-spelling
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[metadata]
description-file=README.md
description_file=README.md
52 changes: 30 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,33 @@
"""
Release instruction:
Upate changelog and contributors list.
Update changelog and contributors list. If you ever change the
`requirements[_dev].txt`, also update the hardcoded numpy version here down
below. Or find a way to always keep both consistent.
Check that tests run correctly for 36 and 27 and doc compiles without warning
(make clean first).
Basic local checks:
- tests run correctly
- doc compiles without warning (make clean first).
change __version__ in setup.py to new version name.
Check that the latest RTD build was OK: https://readthedocs.org/projects/surprise/builds/
First upload to test pypi:
mktmpenv (Python version should not matter)
pip install numpy cython twine
python setup.py sdist
twine upload dist/blabla.tar.gz -r testpypi
Change __version__ in setup.py to new version name. Also update the hardcoded
version in build_sdist.yml, otherwise the GA jobs will fail.
The sdist is built on 3.8 by GA:
- check the sdist building process. It should compile pyx files and the C files
should be included in the archive
- check the install jobs. Look for compilation warnings. Make sure Cython isn't
needed and only C files are compiled.
- check test jobs for warnings etc.
It's best to just get the sdist artifact from the job instead of re-building it
locally. Get the "false" sdist: false == with `numpy>=` constraint, not with
`oldest-supported-numpy`. We don't want `oldest-supported-numpy` as the uploaded
sdist because it's more restrictive.
Then upload to test pypi:
twine upload blabla.tar.gz -r testpypi
Check that install works on testpypi, then upload to pypi and check again.
to install from testpypi:
Expand Down Expand Up @@ -45,12 +60,12 @@

from setuptools import dist # Install numpy right now

dist.Distribution().fetch_build_eggs(["numpy>=1.11.2"])
dist.Distribution().fetch_build_eggs(["numpy>=1.17.3"])

try:
import numpy as np
except ImportError:
exit("Please install numpy>=1.11.2 first.")
exit("Please install numpy>=1.17.3 first.")

try:
from Cython.Build import cythonize
Expand All @@ -70,12 +85,7 @@

# get the dependencies and installs
with open(path.join(here, "requirements.txt"), encoding="utf-8") as f:
all_reqs = f.read().split("\n")

install_requires = [x.strip() for x in all_reqs if "git+" not in x]
dependency_links = [
x.strip().replace("git+", "") for x in all_reqs if x.startswith("git+")
]
install_requires = [line.strip() for line in f.read().split("\n")]

cmdclass = {}

Expand Down Expand Up @@ -110,7 +120,8 @@
]

if USE_CYTHON:
ext_modules = cythonize(
# See https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#distributing-cython-modules
extensions = cythonize(
extensions,
compiler_directives={
"language_level": 3,
Expand All @@ -121,8 +132,6 @@
},
)
cmdclass.update({"build_ext": build_ext})
else:
ext_modules = extensions

setup(
name="scikit-surprise",
Expand Down Expand Up @@ -150,9 +159,8 @@
packages=find_packages(exclude=["tests*"]),
python_requires=">=3.7",
include_package_data=True,
ext_modules=ext_modules,
ext_modules=extensions,
cmdclass=cmdclass,
install_requires=install_requires,
dependency_links=dependency_links,
entry_points={"console_scripts": ["surprise = surprise.__main__:main"]},
)

0 comments on commit 3a387e1

Please sign in to comment.