From: Robin Jarry <robin@jarry.cc>
Date: Wed, 3 Nov 2021 14:21:00 +0100
Subject: setup: use absolute paths

This allows running the setup.py script from another directory. It is
required because pybuild runs tests into a temp dir which is a sub
folder of the sources.

Signed-off-by: Robin Jarry <robin@jarry.cc>
---
 setup.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/setup.py b/setup.py
index df80287..92f5111 100755
--- a/setup.py
+++ b/setup.py
@@ -113,10 +113,13 @@ def readfile(filename):
     with open(filename, 'r') as f: # pylint:disable=unspecified-encoding
         return f.read()
 
-GREENLET_SRC_DIR = 'src/greenlet/'
+def abspath(rel):
+    return os.path.join(os.path.dirname(__file__), rel)
+
+GREENLET_SRC_DIR = abspath('src/greenlet/')
 GREENLET_HEADER_DIR = GREENLET_SRC_DIR
 GREENLET_HEADER = GREENLET_HEADER_DIR + 'greenlet.h'
-GREENLET_TEST_DIR = 'src/greenlet/tests/'
+GREENLET_TEST_DIR = abspath('src/greenlet/tests/')
 # The location of the platform specific assembly files
 # for switching.
 GREENLET_PLATFORM_DIR = GREENLET_SRC_DIR + 'platform/'
@@ -193,7 +196,7 @@ else:
 
 
 def get_greenlet_version():
-    with open('src/greenlet/__init__.py') as f: # pylint:disable=unspecified-encoding
+    with open(abspath('src/greenlet/__init__.py')) as f:
         looking_for = '__version__ = \''
         for line in f:
             if line.startswith(looking_for):
@@ -206,7 +209,7 @@ setup(
     name="greenlet",
     version=get_greenlet_version(),
     description='Lightweight in-process concurrent programming',
-    long_description=readfile("README.rst"),
+    long_description=readfile(abspath("README.rst")),
     long_description_content_type="text/x-rst",
     url="https://greenlet.readthedocs.io/",
     keywords="greenlet coroutine concurrency threads cooperative",
