1- from build import SRC_DIR , OTS_SRC_DIR
21from distutils .dir_util import mkpath , remove_tree
32from distutils import log
43import io
54import os
65import re
7- from setuptools import setup , find_packages , Extension , Command
6+ from pathlib import Path
7+ from setuptools import setup , Extension , Command
88from setuptools .command import build_py
99from setuptools .command .egg_info import egg_info
1010import subprocess
1111import sys
1212
1313PY = sys .executable
1414
15+ # Define paths (previously imported from build.py)
16+ try :
17+ ROOT = Path (__file__ ).parent .resolve ()
18+ except NameError :
19+ # Fallback for when __file__ is not defined
20+ ROOT = Path .cwd ()
21+ SRC_DIR = ROOT / "src"
22+ OTS_SRC_DIR = SRC_DIR / "ots"
23+
1524BUILD_DIR = OTS_SRC_DIR / "build" / "meson"
1625BUILD_SUB_DIR = BUILD_DIR / "subprojects"
1726SRC_SUB_DIR = OTS_SRC_DIR / "subprojects"
@@ -47,7 +56,7 @@ def _get_extra_objects():
4756 # xo.append(BUILD_SUB_DIR / f"woff2-{WOFF2_TAG}" / "libwoff2_decoder.a")
4857 # xo.append(BUILD_SUB_DIR / f"woff2-{WOFF2_TAG}" / "libwoff2_common.a")
4958
50- return [str (p ) for p in xo ]
59+ return [str (p . relative_to ( ROOT ) ) for p in xo ]
5160
5261
5362def _get_include_dirs ():
@@ -69,7 +78,7 @@ def _get_include_dirs():
6978 # woff2
7079 ip .append (SRC_SUB_DIR / f"woff2-{ WOFF2_TAG } " / "include" )
7180
72- return [str (p ) for p in ip ]
81+ return [str (p . relative_to ( ROOT ) ) for p in ip ]
7382
7483
7584def _get_sources ():
@@ -87,7 +96,7 @@ def _get_sources():
8796 sp .append (SRC_SUB_DIR / f"woff2-{ WOFF2_TAG } " / "src" / "woff2_dec.cc" )
8897 sp .append (SRC_SUB_DIR / f"woff2-{ WOFF2_TAG } " / "src" / "woff2_out.cc" )
8998
90- return [str (p ) for p in sp ]
99+ return [str (p . relative_to ( ROOT ) ) for p in sp ]
91100
92101
93102class BuildStaticLibs (Command ):
@@ -271,37 +280,7 @@ def run(self):
271280 sources = _get_sources (),
272281)
273282
274- with io .open ("README.md" , encoding = "utf-8" ) as readme :
275- long_description = readme .read ()
276-
277- classifiers = [
278- 'Development Status :: 4 - Beta' ,
279- 'Intended Audience :: Developers' ,
280- 'Topic :: Software Development :: Testing' ,
281- 'License :: OSI Approved :: BSD License' ,
282- 'Programming Language :: Python :: 3.9' ,
283- 'Programming Language :: Python :: 3.10' ,
284- 'Programming Language :: Python :: 3.11' ,
285- 'Programming Language :: Python :: 3.12' ,
286- 'Operating System :: MacOS :: MacOS X' ,
287- 'Operating System :: POSIX :: Linux' ,
288- ]
289-
290283setup (
291- author = 'Adobe Type team & friends' ,
292- author_email = 'afdko@adobe.com' ,
293284 cmdclass = custom_commands ,
294- classifiers = classifiers ,
295- description = 'Python wrapper for ot-sanitizer' ,
296285 ext_modules = [pyots_mod ],
297- long_description_content_type = 'text/markdown' ,
298- long_description = long_description ,
299- name = 'pyots' ,
300- packages = find_packages ('src' ),
301- package_dir = {'' : 'src' },
302- python_requires = '>=3.9' ,
303- url = 'https://github.com/adobe-type-tools/pyots' ,
304- use_scm_version = True ,
305- setup_requires = ['setuptools_scm' ],
306- zip_safe = False ,
307286)
0 commit comments