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

Python 2+3 version variable and test macros #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Python 2+3 version variable and test macros #63

wants to merge 1 commit into from

Conversation

kyrios123
Copy link
Contributor

Variable Macros (used in the below macros)

  • %python2_version% returns 2.7 for Python 2.7.x
  • %python2_version% returns 3.6 for Python 3.6.x

Actionable Macros (python unit tests)
%python_test and %python3_test

If the PYTHONPATH environment variable is not set, the macro will do it
The following cases are handled:

  1. The macro is called without parameters -> use default test function
    e.g.: %python_test -> python setup.py test

  2. The macro is called with a python script (.py) as parameter -> execute the script with the specified version of python
    e.g.: %python3_test selftest.py -v -> python3 selftest.py -v

  3. The macro is called with something else as parameter -> execute the command "as it is"
    e.g.: %python_test py.test -k 'not this_test' -> py.test -k 'not this_test'

The macros will look for the "standard" build directories py2build or py3build and be executed in the current directory if they can't find it, so they can also be used in packages build with autotools for example.

Signed-off-by: Pierre-Yves [email protected]

**Variable Macros** (used in the below macros)
- `%python2_version%` returns **2.7** for Python 2.7.x
- `%python2_version%` returns **3.6** for Python 3.6.x

**Actionable Macros** (python unit tests)
`%python_test` and `%python3_test`

If the `PYTHONPATH` environment variable is not set, the macro will do it
The following cases are handled:

1. The macro is called without parameters -> use default test function
e.g.: `%python_test` -> `python setup.py test`

2. The macro is called with a python script (`.py`) as parameter -> execute the script with the specified version of python
e.g.: `%python3_test selftest.py -v` -> `python3 selftest.py -v`

3. The macro is called with something else as parameter -> execute the command "as it is"
e.g.: `%python_test py.test -k 'not this_test'` -> `py.test -k 'not this_test'`

The macros will look for the "standard" build directories `py2build` or `py3build` and be executed in the current directory if they can't find it, so they can also be used in packages build with autotools for example.

Signed-off-by: Pierre-Yves <[email protected]>
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.

1 participant