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:
parent
d09372e59e
commit
71bea435b6
|
@ -46,7 +46,7 @@ import warnings
|
|||
|
||||
from setuptools import dist
|
||||
|
||||
from pbr.d2to1 import util
|
||||
from pbr import util
|
||||
|
||||
|
||||
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
|
||||
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
|
||||
"""Common utilities used in testing"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import fixtures
|
||||
import testresources
|
||||
|
@ -51,3 +79,38 @@ class BaseTestCase(testtools.TestCase, testresources.ResourcedTestCase):
|
|||
|
||||
self.useFixture(fixtures.NestedTempfile())
|
||||
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 pbr.d2to1 import tests
|
||||
from pbr import tests
|
||||
|
||||
|
||||
class TestCommands(tests.D2to1TestCase):
|
||||
class TestCommands(tests.BaseTestCase):
|
||||
def test_custom_build_py_command(self):
|
||||
"""Test custom build_py command.
|
||||
|
|
@ -42,10 +42,10 @@ import glob
|
|||
import os
|
||||
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):
|
||||
"""setup.py --keywords.
|
|
@ -41,22 +41,22 @@
|
|||
import os
|
||||
import textwrap
|
||||
|
||||
from pbr.d2to1 import tests
|
||||
from pbr.d2to1.tests import util
|
||||
from pbr import tests
|
||||
from pbr.tests import util
|
||||
|
||||
|
||||
class TestHooks(tests.D2to1TestCase):
|
||||
class TestHooks(tests.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestHooks, self).setUp()
|
||||
with util.open_config(
|
||||
os.path.join(self.package_dir, 'setup.cfg')) as cfg:
|
||||
cfg.set('global', 'setup-hooks',
|
||||
'd2to1_testpackage._setup_hooks.test_hook_1\n'
|
||||
'd2to1_testpackage._setup_hooks.test_hook_2')
|
||||
'pbr_testpackage._setup_hooks.test_hook_1\n'
|
||||
'pbr_testpackage._setup_hooks.test_hook_2')
|
||||
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',
|
||||
'd2to1_testpackage._setup_hooks.test_post_hook')
|
||||
'pbr_testpackage._setup_hooks.test_post_hook')
|
||||
|
||||
def test_global_setup_hooks(self):
|
||||
"""Test setup_hooks.
|
||||
|
@ -84,10 +84,8 @@ class TestHooks(tests.D2to1TestCase):
|
|||
stdout, _, return_code = self.run_setup('build_ext')
|
||||
assert textwrap.dedent("""
|
||||
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
|
||||
""") in stdout # flake8: noqa
|
||||
assert stdout.endswith('build_ext post-hook')
|
||||
assert return_code == 0
|
||||
|
||||
|
|
@ -5,7 +5,7 @@ projects; specifically those projects that comprise stsci_python_ and
|
|||
Astrolib_.
|
||||
|
||||
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_.
|
||||
|
||||
This package is not meant for general consumption, though it might be worth
|
|
@ -1,10 +1,10 @@
|
|||
[metadata]
|
||||
name = d2to1_testpackage
|
||||
name = pbr_testpackage
|
||||
version = 0.1.dev
|
||||
author = Erik M. Bray
|
||||
author-email = embray@stsci.edu
|
||||
home-page = http://www.stsci.edu/resources/software_hardware/stsci_python
|
||||
summary = Test package for testing d2to1
|
||||
author = OpenStack
|
||||
author-email = openstack-dev@lists.openstack.org
|
||||
home-page = http://pypi.python.org/pypi/pbr
|
||||
summary = Test package for testing pbr
|
||||
description-file =
|
||||
README.txt
|
||||
CHANGES.txt
|
||||
|
@ -26,21 +26,21 @@ classifier =
|
|||
keywords = packaging, distutils, setuptools
|
||||
|
||||
[files]
|
||||
packages = d2to1_testpackage
|
||||
packages = pbr_testpackage
|
||||
package-data = testpackage = package_data/*.txt
|
||||
data-files = testpackage/data_files = data_files/*.txt
|
||||
extra-files = extra-file.txt
|
||||
|
||||
[extension=d2to1_testpackage.testext]
|
||||
[extension=pbr_testpackage.testext]
|
||||
sources = src/testext.c
|
||||
optional = True
|
||||
|
||||
[global]
|
||||
#setup-hooks =
|
||||
# d2to1_testpackage._setup_hooks.test_hook_1
|
||||
# d2to1_testpackage._setup_hooks.test_hook_2
|
||||
commands = d2to1_testpackage._setup_hooks.test_command
|
||||
# pbr_testpackage._setup_hooks.test_hook_1
|
||||
# pbr_testpackage._setup_hooks.test_hook_2
|
||||
commands = pbr_testpackage._setup_hooks.test_command
|
||||
|
||||
[build_ext]
|
||||
#pre-hook.test_pre_hook = d2to1_testpackage._setup_hooks.test_pre_hook
|
||||
#post-hook.test_post_hook = d2to1_testpackage._setup_hooks.test_post_hook
|
||||
#pre-hook.test_pre_hook = pbr_testpackage._setup_hooks.test_pre_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
|
||||
@monkeypatch_method(manifest_maker)
|
||||
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')
|
||||
add_defaults._orig(self)
|
||||
self.filelist.extend(extra_files)
|
2
setup.py
2
setup.py
|
@ -16,7 +16,7 @@
|
|||
|
||||
import setuptools
|
||||
|
||||
from pbr.d2to1 import util
|
||||
from pbr import util
|
||||
|
||||
setuptools.setup(
|
||||
**util.cfg_to_args())
|
||||
|
|
|
@ -151,7 +151,7 @@ for PROJECT in $PROJECTS ; do
|
|||
|
||||
# TODO(mordred): need to implement egg filtering
|
||||
# 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
|
||||
# $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
|
||||
|
|
Loading…
Reference in New Issue