Universal pathmagic returns app dir; activated in setup for python3

This commit is contained in:
Dmitri Bogomolov 2021-01-31 22:23:55 +02:00
parent f8844f4d74
commit d05255625b
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
3 changed files with 18 additions and 4 deletions

View File

@ -48,6 +48,9 @@ class InstallCmd(install):
def unittest_discover(): def unittest_discover():
"""Explicit test suite creation""" """Explicit test suite creation"""
if sys.hexversion >= 0x3000000:
from pybitmessage import pathmagic
pathmagic.setup()
return unittest.TestLoader().discover('pybitmessage.tests') return unittest.TestLoader().discover('pybitmessage.tests')

View File

@ -12,10 +12,11 @@ The PyBitmessage startup script
import os import os
import sys import sys
app_dir = os.path.dirname(os.path.abspath(__file__)) try:
os.chdir(app_dir) import pathmagic
sys.path.insert(0, app_dir) except ImportError:
from pybitmessage import pathmagic
app_dir = pathmagic.setup()
import depends import depends
depends.check_dependencies() depends.check_dependencies()

10
src/pathmagic.py Normal file
View File

@ -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