Skip to content

Commit

Permalink
Universal pathmagic returns app dir; activated in setup for python3
Browse files Browse the repository at this point in the history
  • Loading branch information
g1itch committed Feb 17, 2021
1 parent f8844f4 commit d052556
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
3 changes: 3 additions & 0 deletions setup.py
Expand Up @@ -48,6 +48,9 @@ def run(self):

def unittest_discover():
"""Explicit test suite creation"""
if sys.hexversion >= 0x3000000:
from pybitmessage import pathmagic
pathmagic.setup()
return unittest.TestLoader().discover('pybitmessage.tests')


Expand Down
9 changes: 5 additions & 4 deletions src/bitmessagemain.py
Expand Up @@ -12,10 +12,11 @@
import os
import sys

app_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(app_dir)
sys.path.insert(0, app_dir)

try:
import pathmagic
except ImportError:
from pybitmessage import pathmagic
app_dir = pathmagic.setup()

import depends
depends.check_dependencies()
Expand Down
10 changes: 10 additions & 0 deletions src/pathmagic.py
@@ -0,0 +1,10 @@
import os
import sys


def setup():
"""Add path to this file to sys.path"""
app_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(app_dir)
sys.path.insert(0, app_dir)
return app_dir

0 comments on commit d052556

Please sign in to comment.