0

I know the general idea of how to make a Python 2.7 script compatible with Python 3, but how would I go about making it compatible when it uses the imported bzrlib toolbox modules that are not supported by Python 3?

I am importing:

from bzrlib.branch import Branch

  • 2
    It's not that you are making a Python 2.7 script compatible with Python 3, but that you make a script that is compatible with both. If the `bzrlib` module you want to use is not compatible with Python 3, then any script that imports it is, by definition, *also* not compatible with Python 3. This is one of the things that slowed the adoption of Python 3, the lack of Python 3 compatibility of certain "important" 3rd-party libraries. – chepner Jun 22 '20 at 19:54
  • So there would be no way to create an interface in which I could use the script with the imported modules in python 3? – newtopython Jun 22 '20 at 20:27
  • 1
    No, because the script is the sum of any modules it imports. If `bzrlib` isn't Python 3-compatible, then neither is your script. Your only option is to fork the library and *make it* compatible with Python 3. – chepner Jun 22 '20 at 20:32

1 Answers1

1

There is a fork of Bazaar project with an API that is mostly backwards compatible and that works with Python 3 called Breezy. See https://code.launchpad.net/brz and https://www.breezy-vcs.org/.

It supports all Bazaar file formats and network protocols.

Protocol documentation is available at https://www.breezy-vcs.org/developers/api/

jelmer
  • 2,405
  • 14
  • 27
  • Okay so first off it's pretty cool you're one of the developers of Breezy. I have been looking and I do not see any API documentation for brz like there is for the bzrlib. Do you call the modules and methods in the same manner and if so how can I adapt my script and know which brz module to use in place of my bzr modules? – newtopython Jun 23 '20 at 20:19
  • I am importing `from bzrlib.branch import Branch` and then calling upon Branch a few different items in my script such as `dotted_revno_to_revision_id` `repository.get_revision().timestamp` `repository.get_revision(c).properties.get('branch-nick')` `iter_merge_sorted_revisions`. So where or how can I find the proper way to substitute these methods with Breezy? – newtopython Jun 24 '20 at 13:42
  • 1
    The main package is called ``breezy`` rather than ``bzrlibbb``, but otherwise most of the APIs are the same. Documentation can be found at https://www.breezy-vcs.org/developers/api/. – jelmer Jun 25 '20 at 01:49
  • I solved my problem. I was previously doing this `from breezy.branch import Branch` but after I tried `from breezy.bzr.branch import Branch` it worked perfectly. Thank you for all your help! – newtopython Jun 25 '20 at 15:09