Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Python 3 compatibility, sort of, maybe #103

Merged
merged 12 commits into from
Feb 13, 2017
Merged

Python 3 compatibility, sort of, maybe #103

merged 12 commits into from
Feb 13, 2017

Conversation

eevee
Copy link
Contributor

@eevee eevee commented Aug 25, 2016

The first commit is entirely automated, using futurize --stage1 (a subset of 2to3 that avoids doing anything that would break 2). Looks like it accidentally nuked the CRs from a couple files, which has made this diff look much worse than it actually is.

Successfully builds both pokered and pokeyellow using CPython 2.7 and CPython 3.5 and maybe even a PyPy in there somewhere. Makes me happy since bare python is Python 3 on Arch.

The test suite appears to be on fire, which makes it hard to tell if I broke anything. May keep poking at this, though.

Mostly xrange (screw it, just use range), spurious tabs, and division.
- Use the with statement, so it works with pypy (dies with "too many
  open files" otherwise)

- Nuke dem tabs

- Get rid of the global, yikes
Turns out that uselessly importing the 7300-line crystal.py on every
single invocation adds up!
Mostly division.  Also cleaned up a couple uses of bare open().
@kanzure
Copy link
Member

kanzure commented Aug 25, 2016

Well, one way to fix the test suites is to keep deleting code and tests until everything is "passing". I guess we should setup travis-ci, since we are trying to not live in the dark ages and such.

@eevee
Copy link
Contributor Author

eevee commented Aug 25, 2016

Oho, believe me, I love deleting stuff that no one can justify keeping around. :D

@yenatch yenatch merged commit 979c98a into pret:master Feb 13, 2017
@PikalaxALT
Copy link

Relative imports render poketools unusable as a git submodule.

@eevee
Copy link
Contributor Author

eevee commented Feb 18, 2017

That sounds backwards; relative imports exist for cases like submodules.

@Sanqui
Copy link
Member

Sanqui commented Mar 16, 2017

This is probably the issue @PikalaxALT ran into.

sanky@suguri:~/romhacking/gb/pokered$ make PYTHON=python2
rgbasm -D _RED -h -o audio_red.o audio.asm
Traceback (most recent call last):
  File "extras/pokemontools/gfx.py", line 7, in <module>
    from . import png
ValueError: Attempted relative import in non-package
Makefile:51: recipe for target 'gfx/AB.2bpp' failed
make: *** [gfx/AB.2bpp] Error 1
sanky@suguri:~/romhacking/gb/pokered$ make PYTHON=python3
Traceback (most recent call last):
  File "extras/pokemontools/gfx.py", line 7, in <module>
    from . import png
SystemError: Parent module '' not loaded, cannot perform relative import
Makefile:51: recipe for target 'gfx/AB.2bpp' failed
make: *** [gfx/AB.2bpp] Error 1

@kemenaran
Copy link

@PikalaxALT For reference, and for other people reading this page, I worked around this "can't relative import" error by invoking the tools as python -m pokemontools.gbz80disasm (rather than for instance python pokemontools/gbz80disasm.py).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants