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

Introduce python_version in tests[0].python #1170

Merged
merged 9 commits into from
Nov 15, 2024

Conversation

hadim
Copy link
Contributor

@hadim hadim commented Nov 7, 2024

It's a proposal to fix #1168

Please let me know if you would prefer another approach.

@hadim
Copy link
Contributor Author

hadim commented Nov 7, 2024

Here is the kind of recipe that now works:

package:
  name: test-with-custom-deps
  version: 0.0.1

build:
  number: 0
  noarch: python
  script: touch $PREFIX/test-with-custom-deps

requirements:
  run:
    - python

tests:
  - python:
      imports:
        - pandas
      pip_check: true
      requirements:
        run:
          - pandas

@hadim
Copy link
Contributor Author

hadim commented Nov 7, 2024

Recipe format PR at prefix-dev/recipe-format#43

@hadim
Copy link
Contributor Author

hadim commented Nov 11, 2024

@wolfv what do you think about this approach?

@wolfv
Copy link
Member

wolfv commented Nov 13, 2024

Excellent PR, really awesome!

Hmm I am a bit conflicted about this. The python check is pretty simplistic anyways and one can also relatively easy make better tests using the script tests. One can even write Python scripts directly in the scripts test, e.g.

- script:
    interpreter: python
    content:
      - import foo
      - import bar
      - print("hello world")
    requirements:
      run:
        - python
        - foo

Although it's clearly a bit more verbose.

Instead of the total flexibility of requirements we could also add a python version field to the python test as another idea:

python:
  imports:
     - foo
  python_version: 3.8  # or [3.8, 3.9, ...]

So in general I am a bit on the fence.

@hadim
Copy link
Contributor Author

hadim commented Nov 13, 2024

The python check is pretty simplistic anyways and one can also relatively easy make better tests using the script tests.

Yes, I understand your point here.

Instead of the total flexibility of requirements we could also add a python version field to the python test as another idea

This is an alternative solution I also proposed at #1168.

I think that one is better since it's specific to python and, as you said, for a more complex scenarios, the user already has other options.


So would you be okay if I give it a try to python_version: 3.8 # or [3.8, 3.9, ...]?

@hadim hadim changed the title Add python test run requirements Introduce python_version in tests[0].python Nov 13, 2024
@hadim
Copy link
Contributor Author

hadim commented Nov 13, 2024

@wolfv I gave it a try to python_version.

No stress if you still don't want that feature. Just let me know.

@wolfv wolfv merged commit 5bfd56e into prefix-dev:main Nov 15, 2024
19 checks passed
wolfv pushed a commit to prefix-dev/recipe-format that referenced this pull request Nov 15, 2024
@hadim hadim deleted the python_test_deps branch November 15, 2024 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python tests should allow custom requirements
2 participants