-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bootstrap tox.ini from tox-pyenv.ini
- Loading branch information
Showing
8 changed files
with
117 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
tox.ini | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,7 +90,15 @@ to see the available make targets. If you cannot use ``make``, but want to use | |
$ tox -av | ||
to see a list of tox environments and a description. | ||
to see a list of tox environments and a description. For the initial | ||
configuration of tox environments, you may have to run | ||
|
||
.. code-block:: console | ||
$ tox -e bootstrap | ||
in order to set up the ``tox.ini`` configuration file. | ||
|
||
|
||
If you are a member of the `qucontrol organization`_, there is no need to fork | ||
``krotov`` - you can directly pull and push to ``[email protected]:qucontrol/krotov.git``. | ||
|
@@ -128,7 +136,8 @@ that you may run into occasional binary incompatibilities between conda packages | |
If you want to use `conda`, you must use the ``tox-conda.ini`` configuration | ||
file. That is, run all ``make`` comands as e.g. | ||
``make TOXINI=tox-conda.ini test`` and ``tox`` commands as e.g. | ||
``tox -c tox-conda.ini -e py35-test,py36-test,py37-test`` | ||
``tox -c tox-conda.ini -e py35-test,py36-test,py37-test``. Alternatively, | ||
make ``tox-conda.ini`` the default by copying it to ``tox.ini``. | ||
|
||
.. _pyenv: https://github.com/pyenv/pyenv | ||
.. _pyenv-win: https://github.com/pyenv-win/pyenv-win | ||
|
@@ -258,7 +267,7 @@ Testing | |
|
||
The Krotov package includes a full test-suite using pytest_. We strive for a `test coverage`_ above 90%. | ||
|
||
From a checkout of the ``krotov`` repository, assuming conda_ is installed, you can use | ||
From a checkout of the ``krotov`` repository, you can use | ||
|
||
.. code-block:: console | ||
|
@@ -315,8 +324,9 @@ requirements. These hooks are managed through the `pre-commit framework`_. | |
|
||
.. warning:: | ||
After cloning the ``krotov`` repository, you should run | ||
``make bootstrap``, or ``tox -e run-cmd -- pre-commit install`` | ||
from within the project root folder. | ||
``make bootstrap``, ``tox -e bootstrap``, or ``python scripts/bootstrap.py`` | ||
from within the project root folder. These set up ``tox``, and the | ||
pre-commit hooks | ||
|
||
.. _pre-commit framework: https://pre-commit.com | ||
|
||
|
@@ -373,8 +383,7 @@ Also see :ref:`math-in-example-notebooks`. | |
|
||
You may use the BibTeX_ plugin for citations. | ||
|
||
At any point, from a checkout of the ``krotov`` repository (and | ||
assuming you have conda_ installed), you may run | ||
At any point, from a checkout of the ``krotov`` repository, you may run | ||
|
||
.. code-block:: console | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env python | ||
"""Bootstrap script for setting up tox and pre-commit hooks | ||
This scripts is called either by any invocation of the Makefile, or by the tox | ||
configuration in setup.cvg, if there is no tox.ini. | ||
It sets up the main tox.ini file and the pre-commit hooks. | ||
""" | ||
import os | ||
import pathlib | ||
import shutil | ||
import sys | ||
|
||
|
||
_TOX_ERR_MSG = r''' | ||
tox is not available. See https://tox.readthedocs.io for installation | ||
instructions. | ||
''' | ||
|
||
|
||
def main(argv=None): | ||
"""Main function""" | ||
if argv is None: | ||
argv = sys.argv | ||
root = pathlib.Path(__file__).parent.parent | ||
|
||
# 1. Bootstrap the tox.ini file | ||
if not (root / 'tox.ini').is_file(): | ||
tox_ini = os.environ.get('TOXINI', 'tox-pyenv.ini') | ||
if not (root / tox_ini).is_file(): | ||
tox_ini = 'tox-pyenv.ini' | ||
tox_src = root / tox_ini | ||
tox_dst = root / "tox.ini" | ||
print("Copying %s to %s" % (tox_src, tox_dst)) | ||
shutil.copyfile(tox_src, tox_dst) | ||
|
||
# 2. Ensure tox is installed | ||
try: | ||
import tox | ||
except ImportError: | ||
print(_TOX_ERR_MSG) | ||
sys.exit(1) | ||
|
||
# 3. Ensure pre-commit hooks are installed | ||
if not (root / ".git" / "hooks" / "pre-commit").is_file(): | ||
# we're using the tox.ini environments that we got from step 1 | ||
print("bootstrapping pre-commit hook") | ||
cmdline = ['-e', 'run-cmd', '--', 'pre-commit', 'install'] | ||
print("tox " + " ".join(cmdline)) | ||
tox.cmdline(cmdline) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters