Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ os:
osx_image: xcode11.3
env:
jobs:
- PYTHON_VERSION="3.8.3"
- PYTHON_VERSION="3.8.5"
- PYTHON_VERSION="2.7.18"
- PYTHON_VERSION="3.7.7"
- PYTHON_VERSION="3.7.9"
- PYTHON_VERSION="3.6.8"
- PYTHON_VERSION="3.5.4"
- PYTHON_VERSION="3.9-dev"
- PYTHON_VERSION="3.10-dev"
- PYTHON_VERSION="pypy3.6-7.3.0"
- PYTHON_VERSION="pypy2.7-7.3.0"
- PYTHON_VERSION="pypy3.6-7.3.1"
- PYTHON_VERSION="pypy2.7-7.3.1"
- PYTHON_VERSION="pypy3.5-7.0.0"
global:
- DEPLOY_BRANCHES: "'master 0.11'"
- DEPLOY_PYTHONS: "'2.7.18 3.8.3'"
- DEPLOY_PYTHONS: "'2.7.18 3.8.5'"
- DEPLOY_OSES: "'linux'"
- PYB_ARGS: "'-E ci -v -X analyze install'"
- TWINE_USERNAME: pybuilder-travis2
- secure: D49QJr9Z4v9yz9VObFw0q44o2fy3YBjI48b6+Vb1qr2RNMF5GpVj+xWFTr9j1qMw7ilfwWCEKlHytKmh/OSOStUcd1vTlasGz8YefBCP8iIbvp9M6qcBKqMlp8f/6uxwUxak+OMvj5WuKwtyIUy8L9JwDxd02Q12MUW6SNtu2Lo=
jobs:
exclude:
- os: windows
env: PYTHON_VERSION="pypy2.7-7.3.0"
env: PYTHON_VERSION="pypy2.7-7.3.1"
- os: windows
env: PYTHON_VERSION="pypy3.5-7.0.0"
- os: windows
env: PYTHON_VERSION="pypy3.6-7.3.0"
env: PYTHON_VERSION="pypy3.6-7.3.1"
- os: windows
if: env(PYTHON_VERSION) =~ /^.+-dev$/
allow_failures:
Expand Down
5 changes: 4 additions & 1 deletion src/main/python/pybuilder/extern/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# limitations under the License.

import sys
from os.path import basename

import pybuilder._vendor

Expand Down Expand Up @@ -93,4 +94,6 @@ def install(self):
sys.modules.pop(p, None)


VendorImporter(__name__, pybuilder._vendor.__names__, pybuilder._vendor.__name__).install()
# Don't run if we're actually in PDoc
if not (sys.version_info[0] == 2 and basename(sys.argv[0]) == "pdoc"):
VendorImporter(__name__, pybuilder._vendor.__names__, pybuilder._vendor.__name__).install()
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def run_single_test(logger, project, reactor, reports_dir, test, output_test_nam
"success": True
}
if return_code != 0:
logger.error("Integration test failed: %s", test)
logger.error("Integration test failed: %s, exit code %d", test, return_code)
report_item["success"] = False

if project.get_property("verbose") or project.get_property("integrationtest_always_verbose"):
Expand Down
35 changes: 27 additions & 8 deletions src/main/python/pybuilder/plugins/python/pdoc_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

from pybuilder.core import task, init, depends, dependents, optional, after, use_plugin
from pybuilder.errors import BuildFailedException
from pybuilder.python_utils import PY2
from pybuilder.utils import tail_log

__author__ = "Arcadiy Ivanov"

Expand All @@ -33,9 +35,18 @@

@init
def pdoc_init(project):
project.plugin_depends_on("pdoc")
project.set_property_if_unset("pdoc_command_args",
["--html", "--all-submodules", "--overwrite", "--external-links"])
if PY2:
project.plugin_depends_on("pdoc")
else:
project.plugin_depends_on("pdoc3", ">=0.8.3")

if PY2:
project.set_property_if_unset("pdoc_command_args",
["--html", "--all-submodules", "--overwrite", "--external-links"])
else:
project.set_property_if_unset("pdoc_command_args",
["--html", "--overwrite", "--external-links", "--skip-errors"])

project.set_property_if_unset("pdoc_source", "$dir_source_main_python")
project.set_property_if_unset("pdoc_output_dir", "$dir_target/pdocs")
project.set_property_if_unset("pdoc_module_name", None)
Expand All @@ -58,7 +69,7 @@ def pdoc_prepare(project, logger, reactor):
@depends("compile_sources", "verify")
@dependents(optional("publish"))
def pdoc_compile_docs(project, logger, reactor):
logger.info("Generating pdoc documentation")
logger.info("Generating PDoc documentation")

if not project.get_property("pdoc_module_name"):
raise BuildFailedException("'pdoc_module_name' must be specified")
Expand All @@ -75,7 +86,15 @@ def pdoc_compile_docs(project, logger, reactor):
environment = {"PYTHONPATH": source_directory,
"PATH": reactor.pybuilder_venv.environ["PATH"]}

logger.debug("Executing pdoc as: %s", command_and_arguments)
reactor.pybuilder_venv.execute_command(command_and_arguments,
outfile_name=project.expand_path("$dir_reports", "pdoc"), env=environment,
cwd=pdoc_output_dir)
report_file = project.expand_path("$dir_reports", "pdoc.err")
logger.debug("Executing PDoc as: %s", command_and_arguments)
return_code = reactor.pybuilder_venv.execute_command(command_and_arguments,
outfile_name=project.expand_path("$dir_reports", "pdoc"),
error_file_name=report_file,
env=environment,
cwd=pdoc_output_dir)

if return_code:
error_str = "PDoc failed! See %s for full details:\n%s" % (report_file, tail_log(report_file))
logger.error(error_str)
raise BuildFailedException(error_str)
25 changes: 15 additions & 10 deletions src/unittest/python/plugins/python/pdoc_plugin_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def setUp(self):
self.reactor = Mock()
pyb_env = Mock()
pyb_env.environ = {"PATH": "a"}
pyb_env.execute_command.return_value = 0
self.reactor.python_env_registry = {"pybuilder": pyb_env}
self.reactor.pybuilder_venv = pyb_env

Expand All @@ -53,40 +54,44 @@ def test_pdoc_prepare_works(self, os_path_exists, os_mkdir):

self.assertEqual(self.reactor.pybuilder_venv.verify_can_execute.call_count, 2)

@patch("pybuilder.plugins.python.pdoc_plugin.tail_log")
@patch("pybuilder.plugins.python.pdoc_plugin.os.mkdir")
@patch("pybuilder.plugins.python.pdoc_plugin.os.path.exists")
def test_pdoc_requires_module_name(self, os_path_exists, os_mkdir):
def test_pdoc_requires_module_name(self, *_):
pdoc_init(self.project)

self.assertRaises(BuildFailedException, pdoc_compile_docs, self.project, self.logger, self.reactor)

@patch("pybuilder.plugins.python.pdoc_plugin.tail_log")
@patch("pybuilder.plugins.python.pdoc_plugin.os.mkdir")
@patch("pybuilder.plugins.python.pdoc_plugin.os.path.exists")
def test_pdoc_html_adds_html_dir(self, os_path_exists, os_mkdir):
def test_pdoc_html_adds_html_dir(self, *_):
pdoc_init(self.project)
self.project.set_property("pdoc_module_name", "pdoc_module_name_value")

self.project.set_property("pdoc_command_args", [])
pdoc_compile_docs(self.project, self.logger, self.reactor)
pyb_env = self.reactor.pybuilder_venv
pyb_env.execute_command.assert_called_with(
['pdoc', "pdoc_module_name_value"],
["pdoc", "pdoc_module_name_value"],
cwd=self.project.expand_path("$dir_target", "pdocs"),
env={
'PYTHONPATH': self.project.expand_path("$dir_source_main_python"),
'PATH': pyb_env.environ['PATH']
"PYTHONPATH": self.project.expand_path("$dir_source_main_python"),
"PATH": pyb_env.environ["PATH"]
},
outfile_name=self.project.expand_path('$dir_reports', 'pdoc'))
outfile_name=self.project.expand_path("$dir_reports", "pdoc"),
error_file_name=self.project.expand_path("$dir_reports", "pdoc.err"))

self.project.set_property("pdoc_command_args", ["--html"])
pdoc_compile_docs(self.project, self.logger, self.reactor)
pyb_env.execute_command.assert_called_with(
['pdoc', "--html", "--html-dir", self.project.expand_path('$dir_target', 'pdocs'),
["pdoc", "--html", "--html-dir", self.project.expand_path("$dir_target", "pdocs"),
"pdoc_module_name_value"],
cwd=self.project.expand_path("$dir_target", "pdocs"),
env={
'PYTHONPATH': self.project.expand_path("$dir_source_main_python"),
'PATH': pyb_env.environ['PATH']
"PYTHONPATH": self.project.expand_path("$dir_source_main_python"),
"PATH": pyb_env.environ["PATH"]
},
outfile_name=self.project.expand_path('$dir_reports', 'pdoc')
outfile_name=self.project.expand_path("$dir_reports", "pdoc"),
error_file_name=self.project.expand_path("$dir_reports", "pdoc.err")
)
14 changes: 9 additions & 5 deletions travis/travis_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ set -eu
git clone https://github.com/pyenv/pyenv.git ~/.pyenv || true
git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv || true
git clone https://github.com/pyenv/pyenv-update.git ~/.pyenv/plugins/pyenv-update || true
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bash_profile
echo 'export PYENV_ROOT="$HOME/.pyenv"' >>~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >>~/.bash_profile
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >>~/.bash_profile
echo 'eval "$(pyenv virtualenv-init -)"' >>~/.bash_profile

set +eu
source ~/.bash_profile
Expand All @@ -18,7 +18,11 @@ rm -rf ~/.pyenv/versions/pyb-$PYTHON_VERSION || true
rm -rf ~/.pyenv/versions/$PYTHON_VERSION/envs/pyb-$PYTHON_VERSION || true

pyenv update
pyenv install $PYTHON_VERSION -s
INSTALL_OPTION="-s"
if [[ "$PYTHON_VERSION" =~ -dev ]]; then
INSTALL_OPTION="-f"
fi
pyenv install $PYTHON_VERSION $INSTALL_OPTION
pyenv virtualenv $PYTHON_VERSION pyb-$PYTHON_VERSION

set +eu
Expand Down