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

add scipy-typed output #5

Merged
merged 21 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .ci_support/linux_64_.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,14 @@ channel_targets:
- conda-forge main
docker_image:
- quay.io/condaforge/linux-anvil-x86_64:alma9
pin_run_as_build:
python:
min_pin: x.x
max_pin: x.x
python:
- 3.10.* *_cpython
lucascolley marked this conversation as resolved.
Show resolved Hide resolved
- 3.11.* *_cpython
- 3.12.* *_cpython
- 3.9.* *_cpython
python_min:
- '3.9'
47 changes: 44 additions & 3 deletions README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions recipe/.mypyignore-extra
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scipy\._lib\.test_conda_forge_packaging
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I'll happily take PRs that make this test compatible with whatever basedmypy is doing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, the script does import scipy.fft.tests - should mypy pick up the stubs from scipy-stubs @jorenham ? If so, maybe this would work?

import pytest


+ def test_output_separation() -> NoReturn:
- def test_output_separation():
    need_to_warn = False
    try:
        # check if we can import a test folder that's deleted in `scipy`
        # but present in `scipy-tests`; if this passes, skip the test
        import scipy.fft.tests
        pytest.skip("Can be ignored when `scipy-tests` is installed")
    except ModuleNotFoundError:
        # don't re-raise directly to reduce stacktrace, i.e. avoid
        # "During handling of the above exception, another exception occurred:"
        need_to_warn = True

    if need_to_warn:
        raise ImportError(
            "conda-forge builds of `scipy` do not package the tests by default "
            "to reduce the package footprint; you can ensure they're present by "
            "installing `scipy-tests` (resp. adding that to your dependencies)."
        )

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm not sure what you mean @lucascolley 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stubtest complains about no stubs for the script which scipy-feedstock adds, so instead of ignoring the file could we also annotate it inline? Or give it its own stub file? At first I wasn't sure whether it would pick up stubs for the import from scipy, but I think it should given that we have scipy-stubs installed at test-time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either way that's a minor point and doesn't need to block this from being merged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yea, sure. In that case, it should probably return -> None, as it doesn't always raise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I agree that stubbing it instead of ignoring it would a nice flex

76 changes: 51 additions & 25 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,62 @@
{% set name = "scipy-stubs" %}
{% set version = "1.14.1.6" %}
{% set scipy_version = version.rsplit('.', 1)[0] %}
{% set python_min = "3.10" %}

package:
name: {{ name|lower }}
name: scipy-stubs-split
version: {{ version }}

source:
url: https://pypi.org/packages/source/{{ name[0] }}/{{ name }}/scipy_stubs-{{ version }}.tar.gz
sha256: 7505ea8a1624ab4c72516a04eb2838f5ae43e33ba100fc2d5c44103003dd414a
url: https://github.com/jorenham/scipy-stubs/archive/refs/tags/v{{ version }}.tar.gz
sha256: f2394a021c48e0a4a0e9ac96db13603a0d6c2e152b88e1f2f57ad719a1152a58

build:
noarch: python
script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation
number: 0

requirements:
host:
- python {{ python_min }}
- hatchling
- pip
run:
- python >={{ python_min }},<4.0.0
- optype >=0.7.3
run_constrained:
- scipy >=1.10

test:
commands:
- pip check
requires:
- python {{ python_min }}
- pip
number: 1

outputs:
- name: scipy-stubs
build:
noarch: python
script: pip install . -vv --no-deps --no-build-isolation
requirements:
host:
- python {{ python_min }}
- hatchling
- pip
run:
- python >={{ python_min }},<4.0.0
- optype >=0.7.3
run_constrained:
- scipy >=1.10
test:
commands:
- pip check
requires:
- python {{ python_min }}
- pip

- name: scipy-typed
build:
noarch: python
requirements:
host:
- python
lucascolley marked this conversation as resolved.
Show resolved Hide resolved
run:
- python
- scipy =={{ scipy_version }}
- {{ pin_subpackage('scipy-stubs', exact=True) }}
test:
lucascolley marked this conversation as resolved.
Show resolved Hide resolved
requires:
- basedmypy
imports:
- scipy
files:
- .mypyignore-extra
source_files:
- pyproject.toml
- .mypyignore
commands:
- stubtest --mypy-config-file=pyproject.toml --allowlist=.mypyignore --allowlist=.mypyignore-extra --ignore-unused-allowlist scipy

about:
home: https://github.com/jorenham/scipy-stubs/
Expand All @@ -51,3 +76,4 @@ extra:
recipe-maintainers:
- lucascolley
- jorenham
feedstock-name: scipy-stubs