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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

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.

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