Move d2to1 more into the source tree
When we merged in d2to1, we kept it separate, but I don't think there is a great benefit to doing that. Change-Id: I3972b3132619e8e2dd7e362ca5fe9d1e3add43b8
This commit is contained in:
@@ -46,7 +46,7 @@ import warnings
|
|||||||
|
|
||||||
from setuptools import dist
|
from setuptools import dist
|
||||||
|
|
||||||
from pbr.d2to1 import util
|
from pbr import util
|
||||||
|
|
||||||
|
|
||||||
core.Distribution = dist._get_unpatched(core.Distribution)
|
core.Distribution = dist._get_unpatched(core.Distribution)
|
||||||
|
|||||||
@@ -1,86 +0,0 @@
|
|||||||
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
# Copyright (C) 2013 Association of Universities for Research in Astronomy
|
|
||||||
# (AURA)
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
|
||||||
# modification, are permitted provided that the following conditions are met:
|
|
||||||
#
|
|
||||||
# 1. Redistributions of source code must retain the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer.
|
|
||||||
#
|
|
||||||
# 2. Redistributions in binary form must reproduce the above
|
|
||||||
# copyright notice, this list of conditions and the following
|
|
||||||
# disclaimer in the documentation and/or other materials provided
|
|
||||||
# with the distribution.
|
|
||||||
#
|
|
||||||
# 3. The name of AURA and its representatives may not be used to
|
|
||||||
# endorse or promote products derived from this software without
|
|
||||||
# specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY AURA ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
||||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
# DISCLAIMED. IN NO EVENT SHALL AURA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import fixtures
|
|
||||||
import testtools
|
|
||||||
|
|
||||||
|
|
||||||
class D2to1TestCase(testtools.TestCase):
|
|
||||||
def setUp(self):
|
|
||||||
super(D2to1TestCase, self).setUp()
|
|
||||||
self.temp_dir = self.useFixture(fixtures.TempDir()).path
|
|
||||||
self.package_dir = os.path.join(self.temp_dir, 'testpackage')
|
|
||||||
shutil.copytree(os.path.join(os.path.dirname(__file__), 'testpackage'),
|
|
||||||
self.package_dir)
|
|
||||||
self.addCleanup(os.chdir, os.getcwd())
|
|
||||||
os.chdir(self.package_dir)
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
# Remove d2to1.testpackage from sys.modules so that it can be freshly
|
|
||||||
# re-imported by the next test
|
|
||||||
for k in list(sys.modules):
|
|
||||||
if (k == 'd2to1_testpackage' or
|
|
||||||
k.startswith('d2to1_testpackage.')):
|
|
||||||
del sys.modules[k]
|
|
||||||
super(D2to1TestCase, self).tearDown()
|
|
||||||
|
|
||||||
def run_setup(self, *args):
|
|
||||||
return self._run_cmd(sys.executable, ('setup.py',) + args)
|
|
||||||
|
|
||||||
def _run_cmd(self, cmd, args):
|
|
||||||
"""Run a command in the root of the test working copy.
|
|
||||||
|
|
||||||
Runs a command, with the given argument list, in the root of the test
|
|
||||||
working copy--returns the stdout and stderr streams and the exit code
|
|
||||||
from the subprocess.
|
|
||||||
"""
|
|
||||||
|
|
||||||
os.chdir(self.package_dir)
|
|
||||||
p = subprocess.Popen([cmd] + list(args), stdout=subprocess.PIPE,
|
|
||||||
stderr=subprocess.PIPE)
|
|
||||||
|
|
||||||
streams = tuple(s.decode('latin1').strip() for s in p.communicate())
|
|
||||||
print(streams)
|
|
||||||
return (streams) + (p.returncode,)
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
# Copyright 2010-2011 OpenStack Foundation
|
# Copyright 2010-2011 OpenStack Foundation
|
||||||
|
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# 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
|
# not use this file except in compliance with the License. You may obtain
|
||||||
@@ -13,10 +14,37 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
# Copyright (C) 2013 Association of Universities for Research in Astronomy
|
||||||
|
# (AURA)
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# 2. Redistributions in binary form must reproduce the above
|
||||||
|
# copyright notice, this list of conditions and the following
|
||||||
|
# disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
#
|
||||||
|
# 3. The name of AURA and its representatives may not be used to
|
||||||
|
# endorse or promote products derived from this software without
|
||||||
|
# specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY AURA ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
# DISCLAIMED. IN NO EVENT SHALL AURA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
|
||||||
"""Common utilities used in testing"""
|
"""Common utilities used in testing"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
import testresources
|
import testresources
|
||||||
@@ -51,3 +79,38 @@ class BaseTestCase(testtools.TestCase, testresources.ResourcedTestCase):
|
|||||||
|
|
||||||
self.useFixture(fixtures.NestedTempfile())
|
self.useFixture(fixtures.NestedTempfile())
|
||||||
self.useFixture(fixtures.FakeLogger())
|
self.useFixture(fixtures.FakeLogger())
|
||||||
|
|
||||||
|
self.temp_dir = self.useFixture(fixtures.TempDir()).path
|
||||||
|
self.package_dir = os.path.join(self.temp_dir, 'testpackage')
|
||||||
|
shutil.copytree(os.path.join(os.path.dirname(__file__), 'testpackage'),
|
||||||
|
self.package_dir)
|
||||||
|
self.addCleanup(os.chdir, os.getcwd())
|
||||||
|
os.chdir(self.package_dir)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
# Remove pbr.testpackage from sys.modules so that it can be freshly
|
||||||
|
# re-imported by the next test
|
||||||
|
for k in list(sys.modules):
|
||||||
|
if (k == 'pbr_testpackage' or
|
||||||
|
k.startswith('pbr_testpackage.')):
|
||||||
|
del sys.modules[k]
|
||||||
|
super(BaseTestCase, self).tearDown()
|
||||||
|
|
||||||
|
def run_setup(self, *args):
|
||||||
|
return self._run_cmd(sys.executable, ('setup.py',) + args)
|
||||||
|
|
||||||
|
def _run_cmd(self, cmd, args):
|
||||||
|
"""Run a command in the root of the test working copy.
|
||||||
|
|
||||||
|
Runs a command, with the given argument list, in the root of the test
|
||||||
|
working copy--returns the stdout and stderr streams and the exit code
|
||||||
|
from the subprocess.
|
||||||
|
"""
|
||||||
|
|
||||||
|
os.chdir(self.package_dir)
|
||||||
|
p = subprocess.Popen([cmd] + list(args), stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE)
|
||||||
|
|
||||||
|
streams = tuple(s.decode('latin1').strip() for s in p.communicate())
|
||||||
|
print(streams)
|
||||||
|
return (streams) + (p.returncode,)
|
||||||
|
|||||||
@@ -40,10 +40,10 @@
|
|||||||
|
|
||||||
from testtools import content
|
from testtools import content
|
||||||
|
|
||||||
from pbr.d2to1 import tests
|
from pbr import tests
|
||||||
|
|
||||||
|
|
||||||
class TestCommands(tests.D2to1TestCase):
|
class TestCommands(tests.BaseTestCase):
|
||||||
def test_custom_build_py_command(self):
|
def test_custom_build_py_command(self):
|
||||||
"""Test custom build_py command.
|
"""Test custom build_py command.
|
||||||
|
|
||||||
@@ -42,10 +42,10 @@ import glob
|
|||||||
import os
|
import os
|
||||||
import tarfile
|
import tarfile
|
||||||
|
|
||||||
from pbr.d2to1 import tests
|
from pbr import tests
|
||||||
|
|
||||||
|
|
||||||
class TestCore(tests.D2to1TestCase):
|
class TestCore(tests.BaseTestCase):
|
||||||
|
|
||||||
def test_setup_py_keywords(self):
|
def test_setup_py_keywords(self):
|
||||||
"""setup.py --keywords.
|
"""setup.py --keywords.
|
||||||
@@ -41,22 +41,22 @@
|
|||||||
import os
|
import os
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from pbr.d2to1 import tests
|
from pbr import tests
|
||||||
from pbr.d2to1.tests import util
|
from pbr.tests import util
|
||||||
|
|
||||||
|
|
||||||
class TestHooks(tests.D2to1TestCase):
|
class TestHooks(tests.BaseTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestHooks, self).setUp()
|
super(TestHooks, self).setUp()
|
||||||
with util.open_config(
|
with util.open_config(
|
||||||
os.path.join(self.package_dir, 'setup.cfg')) as cfg:
|
os.path.join(self.package_dir, 'setup.cfg')) as cfg:
|
||||||
cfg.set('global', 'setup-hooks',
|
cfg.set('global', 'setup-hooks',
|
||||||
'd2to1_testpackage._setup_hooks.test_hook_1\n'
|
'pbr_testpackage._setup_hooks.test_hook_1\n'
|
||||||
'd2to1_testpackage._setup_hooks.test_hook_2')
|
'pbr_testpackage._setup_hooks.test_hook_2')
|
||||||
cfg.set('build_ext', 'pre-hook.test_pre_hook',
|
cfg.set('build_ext', 'pre-hook.test_pre_hook',
|
||||||
'd2to1_testpackage._setup_hooks.test_pre_hook')
|
'pbr_testpackage._setup_hooks.test_pre_hook')
|
||||||
cfg.set('build_ext', 'post-hook.test_post_hook',
|
cfg.set('build_ext', 'post-hook.test_post_hook',
|
||||||
'd2to1_testpackage._setup_hooks.test_post_hook')
|
'pbr_testpackage._setup_hooks.test_post_hook')
|
||||||
|
|
||||||
def test_global_setup_hooks(self):
|
def test_global_setup_hooks(self):
|
||||||
"""Test setup_hooks.
|
"""Test setup_hooks.
|
||||||
@@ -84,10 +84,8 @@ class TestHooks(tests.D2to1TestCase):
|
|||||||
stdout, _, return_code = self.run_setup('build_ext')
|
stdout, _, return_code = self.run_setup('build_ext')
|
||||||
assert textwrap.dedent("""
|
assert textwrap.dedent("""
|
||||||
running build_ext
|
running build_ext
|
||||||
running pre_hook d2to1_testpackage._setup_hooks.test_pre_hook for command build_ext
|
running pre_hook pbr_testpackage._setup_hooks.test_pre_hook for command build_ext
|
||||||
build_ext pre-hook
|
build_ext pre-hook
|
||||||
""") in stdout # flake8: noqa
|
""") in stdout # flake8: noqa
|
||||||
assert stdout.endswith('build_ext post-hook')
|
assert stdout.endswith('build_ext post-hook')
|
||||||
assert return_code == 0
|
assert return_code == 0
|
||||||
|
|
||||||
|
|
||||||
@@ -5,7 +5,7 @@ projects; specifically those projects that comprise stsci_python_ and
|
|||||||
Astrolib_.
|
Astrolib_.
|
||||||
|
|
||||||
It currently consists mostly of some setup_hook scripts meant for use with
|
It currently consists mostly of some setup_hook scripts meant for use with
|
||||||
`distutils2/packaging`_ and/or d2to1_, and a customized easy_install command
|
`distutils2/packaging`_ and/or pbr_, and a customized easy_install command
|
||||||
meant for use with distribute_.
|
meant for use with distribute_.
|
||||||
|
|
||||||
This package is not meant for general consumption, though it might be worth
|
This package is not meant for general consumption, though it might be worth
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = d2to1_testpackage
|
name = pbr_testpackage
|
||||||
version = 0.1.dev
|
version = 0.1.dev
|
||||||
author = Erik M. Bray
|
author = OpenStack
|
||||||
author-email = embray@stsci.edu
|
author-email = openstack-dev@lists.openstack.org
|
||||||
home-page = http://www.stsci.edu/resources/software_hardware/stsci_python
|
home-page = http://pypi.python.org/pypi/pbr
|
||||||
summary = Test package for testing d2to1
|
summary = Test package for testing pbr
|
||||||
description-file =
|
description-file =
|
||||||
README.txt
|
README.txt
|
||||||
CHANGES.txt
|
CHANGES.txt
|
||||||
@@ -26,21 +26,21 @@ classifier =
|
|||||||
keywords = packaging, distutils, setuptools
|
keywords = packaging, distutils, setuptools
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
packages = d2to1_testpackage
|
packages = pbr_testpackage
|
||||||
package-data = testpackage = package_data/*.txt
|
package-data = testpackage = package_data/*.txt
|
||||||
data-files = testpackage/data_files = data_files/*.txt
|
data-files = testpackage/data_files = data_files/*.txt
|
||||||
extra-files = extra-file.txt
|
extra-files = extra-file.txt
|
||||||
|
|
||||||
[extension=d2to1_testpackage.testext]
|
[extension=pbr_testpackage.testext]
|
||||||
sources = src/testext.c
|
sources = src/testext.c
|
||||||
optional = True
|
optional = True
|
||||||
|
|
||||||
[global]
|
[global]
|
||||||
#setup-hooks =
|
#setup-hooks =
|
||||||
# d2to1_testpackage._setup_hooks.test_hook_1
|
# pbr_testpackage._setup_hooks.test_hook_1
|
||||||
# d2to1_testpackage._setup_hooks.test_hook_2
|
# pbr_testpackage._setup_hooks.test_hook_2
|
||||||
commands = d2to1_testpackage._setup_hooks.test_command
|
commands = pbr_testpackage._setup_hooks.test_command
|
||||||
|
|
||||||
[build_ext]
|
[build_ext]
|
||||||
#pre-hook.test_pre_hook = d2to1_testpackage._setup_hooks.test_pre_hook
|
#pre-hook.test_pre_hook = pbr_testpackage._setup_hooks.test_pre_hook
|
||||||
#post-hook.test_post_hook = d2to1_testpackage._setup_hooks.test_post_hook
|
#post-hook.test_post_hook = pbr_testpackage._setup_hooks.test_post_hook
|
||||||
@@ -265,7 +265,7 @@ def cfg_to_args(path='setup.cfg'):
|
|||||||
# monkey-patch the manifest_maker class
|
# monkey-patch the manifest_maker class
|
||||||
@monkeypatch_method(manifest_maker)
|
@monkeypatch_method(manifest_maker)
|
||||||
def add_defaults(self, extra_files=extra_files, log=log):
|
def add_defaults(self, extra_files=extra_files, log=log):
|
||||||
log.info('[d2to1] running patched manifest_maker command '
|
log.info('[pbr] running patched manifest_maker command '
|
||||||
'with extra_files support')
|
'with extra_files support')
|
||||||
add_defaults._orig(self)
|
add_defaults._orig(self)
|
||||||
self.filelist.extend(extra_files)
|
self.filelist.extend(extra_files)
|
||||||
2
setup.py
2
setup.py
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
import setuptools
|
import setuptools
|
||||||
|
|
||||||
from pbr.d2to1 import util
|
from pbr import util
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
**util.cfg_to_args())
|
**util.cfg_to_args())
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ for PROJECT in $PROJECTS ; do
|
|||||||
|
|
||||||
# TODO(mordred): need to implement egg filtering
|
# TODO(mordred): need to implement egg filtering
|
||||||
# Because install will have caused eggs to be locally downloaded
|
# Because install will have caused eggs to be locally downloaded
|
||||||
# pbr and d2to1 can get excluded from being in the actual venv
|
# pbr can get excluded from being in the actual venv
|
||||||
# test that this did not happen
|
# test that this did not happen
|
||||||
# $tempvenv/bin/python -c 'import pkg_resources as p; import sys; pbr=p.working_set.find(p.Requirement.parse("pbr")) is None; sys.exit(pbr or 0)'
|
# $tempvenv/bin/python -c 'import pkg_resources as p; import sys; pbr=p.working_set.find(p.Requirement.parse("pbr")) is None; sys.exit(pbr or 0)'
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user