From 8252703f56d394743199e702c38f1ecc1db590e5 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Wed, 15 Jul 2015 09:02:50 -0700 Subject: [PATCH 1/4] Unblock migrate (py26 and py3* testing issues) There are two changes which have to go together to pass the gate tests: 1. Update pbr and mock requirements from global-requirements mock 1.2 supports py26 again so make that the minimum version. The same change is being made in g-r with: Ic6b9e18eaec9c81bbbbc57129e024904be928e09 Sync up with latest pbr in global-requirements while we're at it. Closes-Bug: #1474925 2. Fix the importpath module to work with python >= 3.3 where the __import__ built-in is raising an ImportError on a temporary file that is added to the system path. Closes-Bug: #1475339 Change-Id: Ie98938ba75f3983094dd540b7d26a7ec46be4f6e --- migrate/versioning/util/importpath.py | 32 ++++++++++++++++++--------- requirements.txt | 2 +- setup.py | 10 ++++++++- test-requirements.txt | 2 +- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/migrate/versioning/util/importpath.py b/migrate/versioning/util/importpath.py index 5ab7128..529be89 100644 --- a/migrate/versioning/util/importpath.py +++ b/migrate/versioning/util/importpath.py @@ -1,18 +1,30 @@ import os import sys -from six.moves import reload_module as reload +PY33 = sys.version_info >= (3, 3) + +if PY33: + from importlib import machinery +else: + from six.moves import reload_module as reload + def import_path(fullpath): """ Import a file with full path specification. Allows one to import from anywhere, something __import__ does not do. """ - # http://zephyrfalcon.org/weblog/arch_d7_2002_08_31.html - path, filename = os.path.split(fullpath) - filename, ext = os.path.splitext(filename) - sys.path.append(path) - module = __import__(filename) - reload(module) # Might be out of date during tests - del sys.path[-1] - return module - + if PY33: + name = os.path.splitext(os.path.basename(fullpath))[0] + return machinery.SourceFileLoader( + name, fullpath).load_module(name) + else: + # http://zephyrfalcon.org/weblog/arch_d7_2002_08_31.html + path, filename = os.path.split(fullpath) + filename, ext = os.path.splitext(filename) + sys.path.append(path) + try: + module = __import__(filename) + reload(module) # Might be out of date during tests + return module + finally: + del sys.path[-1] diff --git a/requirements.txt b/requirements.txt index d475532..e4da828 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -pbr>=0.11,<2.0 +pbr>=1.3,<2.0 # never put a cap on this, *ever*, sqla versions are handled via # tox, and if SQLA is capped it will only make it so we aren't testing diff --git a/setup.py b/setup.py index c0a24ea..f8fcdec 100644 --- a/setup.py +++ b/setup.py @@ -16,6 +16,14 @@ import setuptools +# In python < 2.7.4, a lazy loading of package `pbr` will break +# setuptools if some other modules registered functions in `atexit`. +# solution from: http://bugs.python.org/issue15881#msg170215 +try: + import multiprocessing # noqa +except ImportError: + pass + setuptools.setup( - setup_requires=['pbr'], + setup_requires=['pbr>=1.3'], pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt index cd5cb69..b4bba70 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -8,7 +8,7 @@ coverage>=3.6 discover feedparser fixtures>=0.3.14 -mock>=1.0 +mock>=1.2 mox>=0.5.3 psycopg2 python-subunit>=0.0.18 From fb55b01a9a32549b450b0f1fecddbed1c18b435b Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Wed, 15 Jul 2015 11:21:04 +0200 Subject: [PATCH 2/4] Fixes usage function for Py3 The usage function of migrate_repository.py isn't Python 3 compatible, and this hasn't be caught by unit tests. This patch fixes the function, so at least the file can be compiled in Py3. Change-Id: Ib9333e46e7526e82acde573d4b2046b2bf9a7ae0 --- migrate/versioning/migrate_repository.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/migrate/versioning/migrate_repository.py b/migrate/versioning/migrate_repository.py index 53833bb..22bba47 100644 --- a/migrate/versioning/migrate_repository.py +++ b/migrate/versioning/migrate_repository.py @@ -13,13 +13,9 @@ log = logging.getLogger(__name__) def usage(): """Gives usage information.""" - print """Usage: %(prog)s repository-to-migrate - - Upgrade your repository to the new flat format. - - NOTE: You should probably make a backup before running this. - """ % {'prog': sys.argv[0]} - + print("Usage: %s repository-to-migrate" % sys.argv[0]) + print("Upgrade your repository to the new flat format.") + print("NOTE: You should probably make a backup before running this.") sys.exit(1) From 1384e901b00ab8c802c47a3db7ddeb1df5604457 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 28 Jul 2015 12:55:39 +0200 Subject: [PATCH 3/4] Add VerNum.__index__() for Python 3 support On Python 3, some functions like range() don't try to call the __int__() method to cast an object to integer, but try instead the __index__() method. Add an __index__() method to mimick correctly the int type on Python 3. Change-Id: I8df116d80e201778714a59367600eaef644266ed --- migrate/tests/versioning/test_version.py | 7 +++++++ migrate/versioning/version.py | 3 +++ 2 files changed, 10 insertions(+) diff --git a/migrate/tests/versioning/test_version.py b/migrate/tests/versioning/test_version.py index 00ce695..df50072 100644 --- a/migrate/tests/versioning/test_version.py +++ b/migrate/tests/versioning/test_version.py @@ -69,6 +69,13 @@ class TestVerNum(fixture.Base): self.assertTrue(VerNum(2) >= 1) self.assertFalse(VerNum(1) >= 2) + def test_int_cast(self): + ver = VerNum(3) + # test __int__ + self.assertEqual(int(ver), 3) + # test __index__: range() doesn't call __int__ + self.assertEqual(list(range(ver, ver)), []) + class TestVersion(fixture.Pathed): diff --git a/migrate/versioning/version.py b/migrate/versioning/version.py index de7008f..3ab814c 100644 --- a/migrate/versioning/version.py +++ b/migrate/versioning/version.py @@ -65,6 +65,9 @@ class VerNum(object): def __int__(self): return int(self.value) + def __index__(self): + return int(self.value) + if six.PY3: def __hash__(self): return hash(self.value) From 5cf4071e3784ae017585e19a523e7d69c25468cf Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 17 Apr 2015 09:31:18 +0200 Subject: [PATCH 4/4] Update URLs in documentation * online doc moved from http://packages.python.org/sqlalchemy-migrate/ to https://sqlalchemy-migrate.readthedocs.org/ * source code moved from http://code.google.com/p/sqlalchemy-migrate/ to https://github.com/stackforge/sqlalchemy-migrate * bug tracker moved from http://code.google.com/p/sqlalchemy-migrate/issues/list to https://bugs.launchpad.net/sqlalchemy-migrate Change-Id: I2db594d279e1229e5b1600cecad86fe0c3612115 --- README.rst | 22 ++++++++++----------- doc/source/download.rst | 43 ++++++++++++----------------------------- doc/source/index.rst | 11 ++++++----- 3 files changed, 28 insertions(+), 48 deletions(-) diff --git a/README.rst b/README.rst index 192cc5a..052c8b8 100644 --- a/README.rst +++ b/README.rst @@ -14,15 +14,16 @@ well as from inside python code. Help ---- -Sphinx documentation is available at the project page `packages.python.org -`_. +Sphinx documentation is available at the project page `readthedocs.org +`_. -Users and developers can be found at #sqlalchemy-migrate on Freenode IRC +Users and developers can be found at #openstack-dev on Freenode IRC network and at the public users mailing list `migrate-users `_. New releases and major changes are announced at the public announce mailing -list `migrate-announce `_ +list `openstack-dev +`_ and at the Python package index `sqlalchemy-migrate `_. @@ -37,13 +38,10 @@ Tests and Bugs To run automated tests: -* Copy test_db.cfg.tmpl to test_db.cfg -* Edit test_db.cfg with database connection strings suitable for running tests. - (Use empty databases.) -* $ pip install -r requirements.txt -r test-requirements.txt -* $ python setup.py develop -* $ testr run --parallel +* install tox: ``pip install -U tox`` +* run tox: ``tox`` +* to test only a specific Python version: ``tox -e py27`` (Python 2.7) Please report any issues with sqlalchemy-migrate to the issue tracker at -`code.google.com issues -`_ +`Launchpad issues +`_ diff --git a/doc/source/download.rst b/doc/source/download.rst index d2d66de..c9e2bec 100644 --- a/doc/source/download.rst +++ b/doc/source/download.rst @@ -21,51 +21,32 @@ command use:: $ migrate help COMMAND If you'd like to be notified when new versions of SQLAlchemy Migrate -are released, subscribe to `migrate-announce`_. +are released, subscribe to `openstack-dev`_. .. _pip: http://pip.openplans.org/ .. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall#installing-easy-install .. _sqlalchemy: http://www.sqlalchemy.org/download.html -.. _`project's download page`: http://code.google.com/p/sqlalchemy-migrate/downloads/list .. _`cheese shop`: http://pypi.python.org/pypi/sqlalchemy-migrate -.. _`migrate-announce`: http://groups.google.com/group/migrate-announce +.. _`openstack-dev`: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev .. _development: Development ----------- -Migrate's Mercurial_ repository is located at `Google Code`_. +If you would like to contribute to the development of OpenStack, +you must follow the steps in this page: -To get the latest trunk:: + http://docs.openstack.org/infra/manual/developers.html - $ hg clone http://sqlalchemy-migrate.googlecode.com/hg/ +Once those steps have been completed, changes to OpenStack +should be submitted for review via the Gerrit tool, following +the workflow documented at: -Patches should be submitted to the `issue tracker`_. You are free to create -your own clone to provide your patches. We are open to pull requests in our -`issue tracker`_. + http://docs.openstack.org/infra/manual/developers.html#development-workflow -If you want to work on sqlalchemy-migrate you might want to use a `virtualenv`. +Pull requests submitted through GitHub will be ignored. -To run the included test suite you have to copy :file:`test_db.cfg.tmpl` to -:file:`test_db.cfg` and put SQLAlchemy database URLs valid for your environment -into that file. We use `nose`_ for our tests and include a test requirements -file for pip. You might use the following commands to install the test -requirements and run the tests:: +Bugs should be filed on Launchpad, not GitHub: - $ pip install -r test-req.pip - $ python setup.py develop - $ python setup.py nosetests - -If you are curious about status changes of sqlalchemy-migrate's issues you -might want to subscribe to `sqlalchemy-migrate-issues`_. - -We use a `Jenkins CI`_ continuous integration tool installation to -help us run tests on most of the databases that migrate supports. - -.. _Mercurial: http://www.mercurial-scm.org/ -.. _Google Code: http://sqlalchemy-migrate.googlecode.com/hg/ -.. _issue tracker: http://code.google.com/p/sqlalchemy-migrate/issues/list -.. _sqlalchemy-migrate-issues: http://groups.google.com/group/sqlalchemy-migrate-issues -.. _Jenkins CI: http://jenkins.gnuviech-server.de/job/sqlalchemy-migrate-all/ -.. _nose: http://readthedocs.org/docs/nose/ + https://bugs.launchpad.net/sqlalchemy-migrate diff --git a/doc/source/index.rst b/doc/source/index.rst index 8af19d7..c143b77 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -7,9 +7,9 @@ :Author: Evan Rosson :Maintainer: Domen Kožar :Maintainer: Jan Dittberner -:Issues: http://code.google.com/p/sqlalchemy-migrate/issues/list -:Source Code: http://code.google.com/p/sqlalchemy-migrate/ -:CI Tool: http://jenkins.gnuviech-server.de/job/sqlalchemy-migrate-all/ +:Source Code: https://github.com/stackforge/sqlalchemy-migrate +:Documentation: https://sqlalchemy-migrate.readthedocs.org/ +:Issues: https://bugs.launchpad.net/sqlalchemy-migrate :Generated: |today| :License: MIT :Version: |release| @@ -24,7 +24,7 @@ mentored by Jonathan LaCour. The project was taken over by a small group of volunteers when Evan had no - free time for the project. It is now hosted as a `Google Code project`_. + free time for the project. It is now hosted as a `Github project`_. During the hosting change the project was renamed to SQLAlchemy Migrate. Currently, sqlalchemy-migrate supports Python versions from 2.6 to 2.7. @@ -64,6 +64,7 @@ Dialect support - :ref:`oracle ` - :ref:`firebird ` - mssql + - DB2 * - :ref:`ALTER TABLE RENAME TABLE ` - yes - yes @@ -160,7 +161,7 @@ SQLAlchemy Migrate is split into two parts, database schema versioning glossary .. _`google's summer of code`: http://code.google.com/soc -.. _`Google Code project`: http://code.google.com/p/sqlalchemy-migrate +.. _`Github project`: https://github.com/stackforge/sqlalchemy-migrate .. _sqlalchemy: http://www.sqlalchemy.org