Skip to content

Commit

Permalink
Merge eb22fdd into 97a11b6
Browse files Browse the repository at this point in the history
  • Loading branch information
arcivanov committed Apr 6, 2020
2 parents 97a11b6 + eb22fdd commit 7219fbb
Show file tree
Hide file tree
Showing 21 changed files with 344 additions and 50 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Expand Up @@ -39,7 +39,7 @@ jobs:
- os: windows
env: PYTHON_VERSION="pypy3.6-7.3.0"
allow_failures:
- if: env(PYTHON_VERSION) =~ /^pypy.+$/ OR os = osx
- if: env(PYTHON_VERSION) =~ /^pypy.+$/

cache:
directories:
Expand All @@ -49,5 +49,5 @@ notifications:
urls:
- https://webhooks.gitter.im/e/3e07f25a6c20d8c6c172
on_cancel: never # default: always
install: python travis/travis_shim.py install
script: python travis/travis_shim.py build
install: travis_wait 30 python travis/travis_shim.py install
script: travis_wait 60 python travis/travis_shim.py build
8 changes: 1 addition & 7 deletions build.py
@@ -1,6 +1,4 @@
#!/usr/bin/env python
#

# -*- coding: utf-8 -*-
#
# This file is part of PyBuilder
Expand Down Expand Up @@ -150,13 +148,9 @@ def initialize(project):
# Also Windows needs PATH for DLL loading in all Pythons
project.set_property("integrationtest_inherit_environment", True)

# enable this to build a bdist on vagrant
# project.set_property("distutils_issue8876_workaround_enabled", True)

project.set_property_if_unset("distutils_commands", ["bdist_wheel"])

project.set_property("distutils_readme_description", True)
project.set_property("distutils_description_overwrite", True)
project.set_property("distutils_upload_skip_existing", True)
project.set_property("distutils_console_scripts", ["pyb = pybuilder.cli:main"])
project.set_property("distutils_classifiers", [
"Programming Language :: Python",
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
@@ -0,0 +1,4 @@
[build-system]
requires = []
build-backend = "pybuilder.pep517"
backend-path = ["src/main/python"]
2 changes: 0 additions & 2 deletions setup.py
@@ -1,6 +1,4 @@
#!/usr/bin/env python
#

# -*- coding: utf-8 -*-
#
# This file is part of PyBuilder
Expand Down
Expand Up @@ -95,6 +95,7 @@ def run(self):
version = '1.0.dev0',
description = '',
long_description = '',
long_description_content_type = None,
author = '',
author_email = '',
license = '',
Expand Down
Expand Up @@ -103,6 +103,7 @@ def run(self):
version = '1.0.dev0',
description = '',
long_description = '',
long_description_content_type = None,
author = '',
author_email = '',
license = '',
Expand Down
Expand Up @@ -95,6 +95,7 @@ def run(self):
version = '1.0.dev0',
description = '',
long_description = '',
long_description_content_type = None,
author = '',
author_email = '',
license = '',
Expand Down
27 changes: 26 additions & 1 deletion src/integrationtest/python/smoke_itest_support.py
Expand Up @@ -19,7 +19,7 @@
import sys
from os import chdir, getcwd
from os.path import join as jp, dirname, exists, isfile, isdir
from runpy import run_path
from runpy import run_path, run_module
from shutil import copytree, copy2

import base_itest_support
Expand Down Expand Up @@ -83,6 +83,31 @@ def smoke_test(self, *args):
sys.meta_path.extend(old_meta_path)
chdir(old_cwd)

def smoke_test_module(self, module, *args):
old_argv = list(sys.argv)
del sys.argv[:]
sys.argv.append("bogus")
sys.argv.extend(args)

old_modules = dict(sys.modules)
old_meta_path = list(sys.meta_path)
old_cwd = getcwd()
chdir(self.tmp_directory)
try:
return run_module(module, run_name="__main__")
except SystemExit as e:
self.assertEqual(e.code, 0, "Test did not exit successfully")
finally:
del sys.argv[:]
sys.argv.extend(old_argv)

sys.modules.clear()
sys.modules.update(old_modules)

del sys.meta_path[:]
sys.meta_path.extend(old_meta_path)
chdir(old_cwd)

def tearDown(self):
try:
pass
Expand Down
32 changes: 32 additions & 0 deletions src/integrationtest/python/smoke_pep517_tests.py
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
#
# This file is part of PyBuilder
#
# Copyright 2011-2020 PyBuilder Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest

from smoke_itest_support import SmokeIntegrationTestSupport


class PEP517SmokeTest(SmokeIntegrationTestSupport):
PROJECT_FILES = list(SmokeIntegrationTestSupport.PROJECT_FILES) + ["pyproject.toml"]

def test_smoke_pep517_install(self):
self.smoke_test_module("pip", "-vvvvvvvvvvvvvv", "install", ".")


if __name__ == "__main__":
unittest.main()
32 changes: 32 additions & 0 deletions src/integrationtest/python/smoke_setup_tests.py
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
#
# This file is part of PyBuilder
#
# Copyright 2011-2020 PyBuilder Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest

from smoke_itest_support import SmokeIntegrationTestSupport


class SetupSmokeTest(SmokeIntegrationTestSupport):
PROJECT_FILES = list(SmokeIntegrationTestSupport.PROJECT_FILES) + ["setup.py"]

def test_smoke_setup_install(self):
self.smoke_test_module("pip", "-vvvvvvvvvvvvvv", "install", ".")


if __name__ == "__main__":
unittest.main()
18 changes: 18 additions & 0 deletions src/integrationtest/python/smoke_sphinx_tests.py
@@ -1,3 +1,21 @@
# -*- coding: utf-8 -*-
#
# This file is part of PyBuilder
#
# Copyright 2011-2020 PyBuilder Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest

from smoke_itest_support import SmokeIntegrationTestSupport
Expand Down
18 changes: 18 additions & 0 deletions src/integrationtest/python/smoke_vendorize_tests.py
@@ -1,3 +1,21 @@
# -*- coding: utf-8 -*-
#
# This file is part of PyBuilder
#
# Copyright 2011-2020 PyBuilder Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest

from smoke_itest_support import SmokeIntegrationTestSupport
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
60 changes: 60 additions & 0 deletions src/main/python/pybuilder/pep517.py
@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
#
# This file is part of PyBuilder
#
# Copyright 2011-2020 PyBuilder Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import unicode_literals

import os
import shutil


def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
def artifact_filter(artifact_name):
return artifact_name.lower().endswith(".whl")

return build_with_pyb(wheel_directory, "Wheel", artifact_filter, config_settings, metadata_directory)


def build_sdist(sdist_directory, config_settings=None):
def artifact_filter(artifact_name):
return artifact_name.lower().endswith(".tar.gz")

return build_with_pyb(sdist_directory, "SDist", artifact_filter, config_settings)


def build_with_pyb(target_dir, artifact_name, artifact_filter, config_settings=None, metadata_directory=None):
from pybuilder.cli import main
# verbose, debug, skip all optional...
if main("-v", "-X", "-o", "--reset-plugins", "clean", "publish"):
raise RuntimeError("PyBuilder build failed")

from pybuilder.reactor import Reactor
from pybuilder.plugins.python.distutils_plugin import _get_generated_artifacts
reactor = Reactor.current_instance()
project = reactor.project
logger = reactor.logger
dist_dir, artifacts = _get_generated_artifacts(project, logger)

filtered = list(filter(artifact_filter, artifacts))
if len(filtered) > 1:
raise RuntimeError("Multiple project %ss found, don't know which to install: %r" % (artifact_name, filtered,))
if not filtered:
raise RuntimeError("Project did not generate any %ss install: %r" % (artifact_name, artifacts,))
artifact = filtered[0]
shutil.copy2(artifact, target_dir)

return os.path.basename(artifact)

0 comments on commit 7219fbb

Please sign in to comment.