44import sys
55import re
66from distutils .core import Extension
7+ from pathlib import Path
78
89import setuptools
910from setuptools .command .build_ext import build_ext
1011
1112"""
13+ NOTE: This project uses more than one version of a 'setup.py' file:
14+ * 'setup.py', and
15+ * 'setup_ci.py'
16+
1217Based on:
1318 https://github.com/popatam/gopy_build_wheel_example/blob/main/setup_ci.py
1419"""
1520
21+
1622def normalize (name ): # https://peps.python.org/pep-0503/#normalized-names
1723 return re .sub (r"[-_.]+" , "-" , name ).lower ()
1824
19- # PACKAGE_PATH="simple_go_timer"
20- # PACKAGE_NAME=PACKAGE_PATH.split("/")[-1]
2125
22- PACKAGE_PATH = "gotdf_python"
23- PACKAGE_NAME = "otdf_python"
26+ PACKAGE_PATH = "gotdf_python"
27+ PACKAGE_NAME = "otdf_python"
2428
25- if sys .platform == ' darwin' :
29+ if sys .platform == " darwin" :
2630 # PYTHON_BINARY_PATH is setting explicitly for 310 and 311, see build_wheel.yml
2731 # on macos PYTHON_BINARY_PATH must be python bin installed from python.org or from brew
2832 PYTHON_BINARY = os .getenv ("PYTHON_BINARY_PATH" , sys .executable )
2933 if PYTHON_BINARY == sys .executable :
30- subprocess .check_call ([sys .executable , '-m' , ' pip' , ' install' , ' pybindgen' ])
34+ subprocess .check_call ([sys .executable , "-m" , " pip" , " install" , " pybindgen" ])
3135else :
3236 # linux & windows
3337 PYTHON_BINARY = sys .executable
34- subprocess .check_call ([sys .executable , '-m' , 'pip' , 'install' , 'pybindgen' ])
38+ subprocess .check_call ([sys .executable , "-m" , "pip" , "install" , "pybindgen" ])
39+
3540
3641def _generate_path_with_gopath () -> str :
3742 go_path = subprocess .check_output (["go" , "env" , "GOPATH" ]).decode ("utf-8" ).strip ()
@@ -42,9 +47,14 @@ def _generate_path_with_gopath() -> str:
4247class CustomBuildExt (build_ext ):
4348 def build_extension (self , ext : Extension ):
4449 bin_path = _generate_path_with_gopath ()
45- go_env = json .loads (subprocess .check_output (["go" , "env" , "-json" ]).decode ("utf-8" ).strip ())
50+ go_env = json .loads (
51+ subprocess .check_output (["go" , "env" , "-json" ]).decode ("utf-8" ).strip ()
52+ )
4653
47- destination = os .path .dirname (os .path .abspath (self .get_ext_fullpath (ext .name ))) + f"/{ PACKAGE_NAME } "
54+ destination = (
55+ os .path .dirname (os .path .abspath (self .get_ext_fullpath (ext .name )))
56+ + f"/{ PACKAGE_NAME } "
57+ )
4858
4959 subprocess .check_call (
5060 [
@@ -65,15 +75,17 @@ def build_extension(self, ext: Extension):
6575 with open (f"{ destination } /__init__.py" , "w" ) as f :
6676 f .write (f"from .{ PACKAGE_PATH } import *" )
6777
68- with open ("README.md" , "r" ) as fh :
69- long_description = fh .read ()
78+
79+ this_directory = Path (__file__ ).parent
80+ long_description = (this_directory / "README.md" ).read_text ()
7081
7182setuptools .setup (
7283 name = "otdf_python" ,
73- version = "0.0.10 " ,
84+ version = "0.0.11 " ,
7485 author = "b-long" ,
75- long_description = long_description ,
7686 description = "Unofficial OpenTDF SDK for Python." ,
87+ long_description_content_type = "text/markdown" ,
88+ long_description = long_description ,
7789 url = "https://github.com/b-long/opentdf-python-sdk" ,
7890 classifiers = [
7991 "Programming Language :: Python :: 3" ,
@@ -85,6 +97,9 @@ def build_extension(self, ext: Extension):
8597 "build_ext" : CustomBuildExt ,
8698 },
8799 ext_modules = [
88- Extension (PACKAGE_NAME , [PACKAGE_PATH ],)
100+ Extension (
101+ PACKAGE_NAME ,
102+ [PACKAGE_PATH ],
103+ )
89104 ],
90105)
0 commit comments