mirror of https://github.com/KLayout/klayout.git
Tired of patching around __version__ ...
This doesn't work. Either Python is too old, import_metadata isn't there or Azure pipelines do not support that. Stopping that. Good old plain C++ is still the best solution. Take that dynamic language hackers!
This commit is contained in:
parent
c5d6889721
commit
6db6e77458
9
setup.py
9
setup.py
|
|
@ -542,10 +542,12 @@ config.add_extension(_gsi)
|
|||
_pya_path = os.path.join("src", "pya", "pya")
|
||||
_pya_sources = set(glob.glob(os.path.join(_pya_path, "*.cc")))
|
||||
|
||||
_version_path = os.path.join("src", "version")
|
||||
|
||||
_pya = Library(
|
||||
config.root + "._pya",
|
||||
define_macros=config.macros() + [("MAKE_PYA_LIBRARY", 1)],
|
||||
include_dirs=[_tl_path, _gsi_path],
|
||||
define_macros=config.macros() + [("MAKE_PYA_LIBRARY", 1), ("KLAYOUT_VERSION", config.version())],
|
||||
include_dirs=[_version_path, _tl_path, _gsi_path],
|
||||
extra_objects=[config.path_of("_tl", _tl_path), config.path_of("_gsi", _gsi_path)],
|
||||
language="c++",
|
||||
libraries=config.libraries('_pya'),
|
||||
|
|
@ -974,9 +976,6 @@ if __name__ == "__main__":
|
|||
package_data={config.root: ["src/pymod/distutils_src/klayout/*.pyi"]},
|
||||
data_files=[(config.root, ["src/pymod/distutils_src/klayout/py.typed"])],
|
||||
include_package_data=True,
|
||||
install_requires = [
|
||||
'importlib-metadata <= 4.8.3 ; python_version < "3.8"',
|
||||
],
|
||||
ext_modules=[_tl, _gsi, _pya, _rba, _db, _lib, _rdb, _lym, _laybasic, _layview, _ant, _edt, _img]
|
||||
+ db_plugins
|
||||
+ [tl, db, lib, rdb, lay],
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@
|
|||
#include "pyaInternal.h"
|
||||
#include "pyaCallables.h"
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace pya
|
||||
|
|
@ -148,7 +150,7 @@ PythonModule::init (const char *mod_name, const char *description)
|
|||
memcpy ((void *) mp_mod_def, (const void *) &mod_def, sizeof (PyModuleDef));
|
||||
|
||||
module = PyModule_Create ((PyModuleDef *) mp_mod_def);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
mp_module = PythonRef (module);
|
||||
|
|
@ -663,7 +665,13 @@ PythonModule::make_classes (const char *mod_name)
|
|||
all_list = PythonRef (PyObject_GetAttrString (module, "__all__"));
|
||||
}
|
||||
|
||||
// Establish __doc__
|
||||
PyObject_SetAttrString (module, "__doc__", PythonRef (c2python (m_mod_description)).get ());
|
||||
PyList_Append (all_list.get (), PythonRef (c2python ("__doc__")).get ());
|
||||
|
||||
// Establish __version__
|
||||
PyObject_SetAttrString (module, "__version__", PythonRef (c2python (prg_version)).get ());
|
||||
PyList_Append (all_list.get (), PythonRef (c2python ("__version__")).get ());
|
||||
|
||||
// Build a class for descriptors for static attributes
|
||||
PYAStaticAttributeDescriptorObject::make_class (module);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,3 @@
|
|||
import sys
|
||||
if sys.version_info >= (3, 8):
|
||||
from importlib import metadata
|
||||
else:
|
||||
import importlib_metadata as metadata
|
||||
|
||||
try:
|
||||
__version__ = metadata.version('klayout')
|
||||
except Exception:
|
||||
__version__ = 'unknown'
|
||||
from .tl import __version__
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue