Compare commits

...

11 Commits

Author SHA1 Message Date
Robert Taylor 7825ae9eb3 Add version and author to pyproject.toml 2022-12-06 13:58:49 +00:00
Robert Taylor 08fe3a10fd Fix errors when building clean 2022-12-06 13:53:40 +00:00
Robert Taylor e55484b101 install helpers at top level 2022-12-06 13:53:40 +00:00
Robert Taylor 24aeffd8f0 Add bin files as scripts 2022-12-06 13:53:40 +00:00
Robert Taylor a2236debb9 Fix Python linking issues 2022-12-06 13:53:40 +00:00
Robert Taylor aa60c8c9af Give same import semantics for now, fix rpath issue 2022-12-06 13:53:40 +00:00
Robert Taylor d60a2603dd Add Coriolis dir that poetry needs, along with base __init__.py 2022-12-06 13:53:40 +00:00
Robert Taylor f511097298 Poetry package build working for most of coriolis 2022-12-06 13:53:40 +00:00
Robert Taylor d93d76d5e7 Move to packaging requiring no changes to CMake 2022-12-06 13:53:40 +00:00
Robert Taylor bc69b3f013 Initial Poetry infrastructure 2022-12-06 13:53:40 +00:00
Robert Taylor fe0057149a Move decprecated components out of the way, to avoice confusion 2022-12-06 13:53:40 +00:00
2353 changed files with 357 additions and 59 deletions

33
Coriolis/__init__.py Normal file
View File

@ -0,0 +1,33 @@
#This is needed for poetry to recognise the top level module
import os
import sys
import subprocess
#TODO not PEP302 complient -probably a big porting job
coriolis_package_dir = os.path.abspath(os.path.dirname(__file__))
os.environ["CORIOLIS_TOP"] = coriolis_package_dir
CORIOLIS_DATA = os.path.join(os.path.dirname(__file__), 'data')
CORIOLIS_BIN = os.path.join(CORIOLIS_DATA,"bin")
def _program(name, args):
return subprocess.call([os.path.join(CORIOLIS_BIN, name)] + args, close_fds=False)
def blif2vst():
raise SystemExit(_program("blif2vst.py", sys.argv[1:]))
def cx2y():
raise SystemExit(_program("cx2y", sys.argv[1:]))
def cyclop():
raise SystemExit(_program("cyclop", sys.argv[1:]))
def tutorial():
raise SystemExit(_program("tutorial", sys.argv[1:]))
def unittests():
raise SystemExit(_program("unittests", sys.argv[1:]))
def yosys_coriolis():
raise SystemExit(_program("yosys.py", sys.argv[1:]))

View File

@ -7,6 +7,9 @@
if(COMMAND CMAKE_POLICY) if(COMMAND CMAKE_POLICY)
cmake_policy(SET CMP0003 NEW) cmake_policy(SET CMP0003 NEW)
cmake_policy(SET CMP0005 NEW) cmake_policy(SET CMP0005 NEW)
cmake_policy(SET CMP0079 NEW)
cmake_policy(SET CMP0022 NEW)
cmake_policy(SET CMP0060 NEW)
#if(NOT (CMAKE_VERSION VERSION_LESS 2.8.0)) #if(NOT (CMAKE_VERSION VERSION_LESS 2.8.0))
# cmake_policy(SET CMP0014 OLD) # cmake_policy(SET CMP0014 OLD)
#endif() #endif()

View File

@ -1,5 +1,4 @@
if(UNIX AND NOT POETRY)
if(UNIX)
if(NOT Python_FOUND) if(NOT Python_FOUND)
message(FATAL_ERROR "Python has not been found, maybe forgot to call find_package(Python). ") message(FATAL_ERROR "Python has not been found, maybe forgot to call find_package(Python). ")
endif() endif()
@ -46,4 +45,4 @@ if(UNIX)
else(FindPythonSitePackages_FOUND) else(FindPythonSitePackages_FOUND)
message ( FATAL_ERROR "Python site packages directory was not found (pythonV.R/site-packages/)." ) message ( FATAL_ERROR "Python site packages directory was not found (pythonV.R/site-packages/)." )
endif(FindPythonSitePackages_FOUND) endif(FindPythonSitePackages_FOUND)
endif(UNIX) endif(UNIX AND NOT POETRY)

View File

@ -119,7 +119,7 @@ Development files for the Coriolis 2 package.
%dir %{coriolisTop}/%{_lib} %dir %{coriolisTop}/%{_lib}
%dir %{coriolisTop}/%{python_sitedir} %dir %{coriolisTop}/%{python_sitedir}
%dir %{coriolisTop}/%{python_sitedir}/crlcore %dir %{coriolisTop}/%{python_sitedir}/crlcore
%dir %{coriolisTop}/%{python_sitedir}/crlcore/helpers %dir %{coriolisTop}/%{python_sitedir}/helpers
%dir %{coriolisTop}/%{python_sitedir}/cumulus %dir %{coriolisTop}/%{python_sitedir}/cumulus
%dir %{coriolisTop}/%{python_sitedir}/stratus %dir %{coriolisTop}/%{python_sitedir}/stratus
%{coriolisTop}/bin/* %{coriolisTop}/bin/*
@ -130,7 +130,7 @@ Development files for the Coriolis 2 package.
%{coriolisTop}/%{python_sitedir}/cumulus/plugins/*/*.py* %{coriolisTop}/%{python_sitedir}/cumulus/plugins/*/*.py*
%{coriolisTop}/%{python_sitedir}/stratus/*.py* %{coriolisTop}/%{python_sitedir}/stratus/*.py*
%{coriolisTop}/%{python_sitedir}/crlcore/*.py* %{coriolisTop}/%{python_sitedir}/crlcore/*.py*
%{coriolisTop}/%{python_sitedir}/crlcore/helpers/*.py* %{coriolisTop}/%{python_sitedir}/helpers/*.py*
%{coriolisTop}/%{python_sitedir}/kite/*.py* %{coriolisTop}/%{python_sitedir}/kite/*.py*
%{coriolisTop}/%{python_sitedir}/unicorn/*.py* %{coriolisTop}/%{python_sitedir}/unicorn/*.py*
%{_sysconfdir}/coriolis2/*.py %{_sysconfdir}/coriolis2/*.py

128
build.py Normal file
View File

@ -0,0 +1,128 @@
import os
import platform
import re
import subprocess
import sys
import sysconfig
from distutils.version import LooseVersion
from distutils.dir_util import copy_tree, remove_tree
from typing import Any, Dict
from setuptools.command.build_ext import build_ext
from setuptools.extension import Extension
class CMakeExtension(Extension):
name: str # exists, even though IDE doesn't find it
def __init__(self, name: str, sourcedir: str="") -> None:
super().__init__(name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
self.sourcedir_rel = sourcedir
class ExtensionBuilder(build_ext):
def run(self) -> None:
self.validate_cmake()
super().run()
def build_extension(self, ext: Extension) -> None:
if isinstance(ext, CMakeExtension):
self.build_cmake_extension(ext)
else:
super().build_extension(ext)
def validate_cmake(self) -> None:
cmake_extensions = [x for x in self.extensions if isinstance(x, CMakeExtension)]
if len(cmake_extensions) > 0:
try:
out = subprocess.check_output(["cmake", "--version"])
except OSError:
raise RuntimeError(
"CMake must be installed to build the following extensions: "
+ ", ".join(e.name for e in cmake_extensions)
)
if platform.system() == "Windows":
cmake_version = LooseVersion(re.search(r"version\s*([\d.]+)", out.decode()).group(1)) # type: ignore
if cmake_version < "3.1.0":
raise RuntimeError("CMake >= 3.1.0 is required on Windows")
def build_cmake_extension(self, ext: CMakeExtension) -> None:
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
cmake_args = []
cfg = "Debug" if self.debug else "Release"
# cfg = 'Debug'
build_args = ["--config", cfg]
install_args = ["--config", cfg]
if platform.system() == "Windows":
if sys.maxsize > 2 ** 32:
cmake_args += ["-A", "x64"]
build_args += ["--", "/m"]
else:
cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg]
build_args += ["--", "-j4", "VERBOSE=1"]
cmake_args += ["-DPYTHON_INCLUDE_DIR={}".format(sysconfig.get_path("include"))]
env = os.environ.copy()
env["CXXFLAGS"] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get("CXXFLAGS", ""), self.distribution.get_version())
build_dir = os.path.join(self.build_temp, ext.sourcedir_rel)
os.makedirs(build_dir,exist_ok=True)
cmake_args += [f"-DCMAKE_MODULE_PATH={os.path.abspath('bootstrap/cmake_modules')};"
f"{os.path.join(extdir, 'share/cmake/Modules')}"]
cmake_args += [f"-DCMAKE_INSTALL_PREFIX={extdir}"]
cmake_args += [f"-DPython_CORIOLISLIB={extdir}"]
cmake_args += [f"-DPython_CORIOLISARCH={extdir}"]
cmake_args += [f"-DSYS_CONF_DIR={extdir}"]
cmake_args += [f"-DCORIOLIS_TOP={extdir}"]
cmake_args += [f"-DCORIOLIS_USER_TOP={extdir}"]
cmake_args += [f"-DPOETRY=1"]
cmake_args += [f"-DWITH_QT5=1"]
cmake_args += [f"-DCMAKE_BUILD_RPATH_USE_ORIGIN=1"]
cmake_args += ["-DCMAKE_SKIP_BUILD_RPATH=FALSE"]
cmake_args += ["-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"]
cmake_args += ["-DCMAKE_INSTALL_RPATH=\${ORIGIN}/lib"]
cmake_args += ["-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE"]
subprocess.check_call(["cmake", "--debug-find", "--trace-redirect=build.cmake.trace", "--trace-expand", ext.sourcedir] + cmake_args, cwd=build_dir, env=env)
subprocess.check_call(["cmake", "--build", "."] + build_args, cwd=build_dir)
subprocess.check_call(["cmake", "--install", ".", "--prefix", extdir] + install_args, cwd=build_dir)
if os.path.exists(os.path.join(extdir, "bin")):
copy_tree(os.path.join(extdir, "bin"), os.path.join(extdir,"data/bin"))
remove_tree(os.path.join(extdir, "bin"))
def build(setup_kwargs: Dict[str, Any]) -> None:
cmake_modules = [
CMakeExtension("coloquinte", sourcedir="coloquinte"),
CMakeExtension("Hurricane", sourcedir="hurricane"),
CMakeExtension("crlcore", sourcedir="crlcore"),
CMakeExtension("flute", sourcedir="flute"),
CMakeExtension("etesian", sourcedir="etesian"),
CMakeExtension("anabatic", sourcedir="anabatic"),
CMakeExtension("katana", sourcedir="katana"),
CMakeExtension("equinox", sourcedir="equinox"),
CMakeExtension("solstice", sourcedir="solstice"),
CMakeExtension("oroshi", sourcedir="oroshi"),
CMakeExtension("bora", sourcedir="bora"),
CMakeExtension("karakaze", sourcedir="karakaze"),
#CMakeExtension("knik", sourcedir="knik"),
#CMakeExtension("unicorn", sourcedir="unicorn"),
CMakeExtension("tutorial", sourcedir="tutorial"),
CMakeExtension("cumulus", sourcedir="cumulus"),
CMakeExtension("stratus1", sourcedir="stratus1"),
CMakeExtension("documentation", sourcedir="documentation"),
CMakeExtension("unittests", sourcedir="unittests")
]
ext_modules = cmake_modules
setup_kwargs.update(
{
"ext_modules": ext_modules,
"cmdclass": dict(build_ext=ExtensionBuilder),
"zip_safe": False,
}
)

View File

@ -1,7 +1,7 @@
install( FILES helpers/__init__.py DESTINATION ${Python_CORIOLISLIB}/crlcore/helpers ) install( FILES helpers/__init__.py DESTINATION ${Python_CORIOLISLIB}/helpers )
install( FILES helpers/io.py DESTINATION ${Python_CORIOLISLIB}/crlcore/helpers ) install( FILES helpers/io.py DESTINATION ${Python_CORIOLISLIB}/helpers )
install( FILES helpers/utils.py DESTINATION ${Python_CORIOLISLIB}/crlcore/helpers ) install( FILES helpers/utils.py DESTINATION ${Python_CORIOLISLIB}/helpers )
install( FILES helpers/overlay.py DESTINATION ${Python_CORIOLISLIB}/crlcore/helpers ) install( FILES helpers/overlay.py DESTINATION ${Python_CORIOLISLIB}/helpers )
install( FILES helpers/analogtechno.py DESTINATION ${Python_CORIOLISLIB}/crlcore/helpers ) install( FILES helpers/analogtechno.py DESTINATION ${Python_CORIOLISLIB}/helpers )
install( FILES helpers/technology.py DESTINATION ${Python_CORIOLISLIB}/crlcore/helpers ) install( FILES helpers/technology.py DESTINATION ${Python_CORIOLISLIB}/helpers )

View File

@ -49,7 +49,7 @@
# ${QtX_LIBRARIES} # ${QtX_LIBRARIES}
# ${Boost_LIBRARIES} # ${Boost_LIBRARIES}
# ${LIBXML2_LIBRARIES} # ${LIBXML2_LIBRARIES}
# ${PYTHON_LIBRARIES} -lutil # ${Python_LIBRARIES} -lutil
# ) # )
install( TARGETS libmanager DESTINATION lib${LIB_SUFFIX} ) install( TARGETS libmanager DESTINATION lib${LIB_SUFFIX} )

View File

@ -303,18 +303,18 @@
${openaccess_cpps} ${openaccess_cpps}
) )
set_target_properties ( crlcore PROPERTIES VERSION 1.0 SOVERSION 1 ) set_target_properties ( crlcore PROPERTIES VERSION 1.0 SOVERSION 1 )
# target_link_libraries ( crlcore ${HURRICANE_PYTHON_NEW_LIBRARIES} target_link_libraries ( crlcore ${HURRICANE_PYTHON_NEW_LIBRARIES}
# ${HURRICANE_PYTHON_LIBRARIES} ${HURRICANE_PYTHON_LIBRARIES}
# ${HURRICANE_GRAPHICAL_LIBRARIES} ${HURRICANE_GRAPHICAL_LIBRARIES}
# ${HURRICANE_LIBRARIES} ${HURRICANE_LIBRARIES}
# ${BOOKSHELF_LIBRARY} ${BOOKSHELF_LIBRARY}
# ${LEFDEF_LIBRARIES} ${LEFDEF_LIBRARIES}
# ${OA_LIBRARIES} ${OA_LIBRARIES}
# ${QtX_LIBRARIES} ${QtX_LIBRARIES}
# ${Boost_LIBRARIES} ${Boost_LIBRARIES}
# ${LIBXML2_LIBRARIES} ${LIBXML2_LIBRARIES}
# ${PYTHON_LIBRARIES} -lutil ${Python_LIBRARIES} -lutil
# ) )
install ( TARGETS crlcore DESTINATION lib${LIB_SUFFIX} ) install ( TARGETS crlcore DESTINATION lib${LIB_SUFFIX} )
install ( FILES ${includes} ${mocincludes} DESTINATION include/coriolis2/crlcore ) install ( FILES ${includes} ${mocincludes} DESTINATION include/coriolis2/crlcore )

View File

@ -21,6 +21,17 @@
${Boost_INCLUDE_DIR} ${Boost_INCLUDE_DIR}
${QtX_INCLUDE_DIRS} ${QtX_INCLUDE_DIRS}
) )
set (LINK_LIBS ${HURRICANE_PYTHON_NEW_LIBRARIES}
${HURRICANE_PYTHON_LIBRARIES}
${HURRICANE_GRAPHICAL_LIBRARIES}
${HURRICANE_LIBRARIES}
${BOOKSHELF_LIBRARY}
${OA_LIBRARIES}
${Boost_LIBRARIES}
${LIBXML2_LIBRARIES}
${Python_LIBRARIES} -lutil
)
add_definitions( -DCORIOLIS_TOP="${CORIOLIS_TOP}" add_definitions( -DCORIOLIS_TOP="${CORIOLIS_TOP}"
-DSYS_CONF_DIR="${SYS_CONF_DIR}" -DSYS_CONF_DIR="${SYS_CONF_DIR}"
@ -77,16 +88,7 @@
crlcore/PyLefExport.h crlcore/PyLefExport.h
crlcore/PyDefExport.h crlcore/PyDefExport.h
) )
# target_link_libraries ( crlcore ${HURRICANE_PYTHON_NEW_LIBRARIES} target_link_libraries ( crlcore ${LINK_LIBS} )
# ${HURRICANE_PYTHON_LIBRARIES}
# ${HURRICANE_GRAPHICAL_LIBRARIES}
# ${HURRICANE_LIBRARIES}
# ${BOOKSHELF_LIBRARY}
# ${OA_LIBRARIES}
# ${Boost_LIBRARIES}
# ${LIBXML2_LIBRARIES}
# ${PYTHON_LIBRARIES} -lutil
# )
set( depLibs crlcore set( depLibs crlcore
${HURRICANE_GRAPHICAL_LIBRARIES} ${HURRICANE_GRAPHICAL_LIBRARIES}
@ -94,7 +96,7 @@
${HURRICANE_PYTHON_LIBRARIES} ${HURRICANE_PYTHON_LIBRARIES}
${HURRICANE_LIBRARIES} ${HURRICANE_LIBRARIES}
${LEFDEF_LIBRARIES} ${LEFDEF_LIBRARIES}
${PYTHON_LIBRARIES} ${Python_LIBRARIES}
${QtX_LIBRARIES} ${QtX_LIBRARIES}
-lutil -lutil
) )
@ -106,6 +108,7 @@
"${depLibs}" "${depLibs}"
include/coriolis2/crlcore include/coriolis2/crlcore
) )
add_python_module( "${pyConstCpps}" add_python_module( "${pyConstCpps}"
"crlcore/PyRoutingLayerGauge.h" "crlcore/PyRoutingLayerGauge.h"
"pycrlconst;1.0;1" "pycrlconst;1.0;1"
@ -113,3 +116,4 @@
"${depLibs}" "${depLibs}"
include/coriolis2/crlcore include/coriolis2/crlcore
) )

View File

@ -1,5 +1,5 @@
# -*- explicit-buffer-name: "CMakeLists.txt<crlcore/src/x2y> -*- # -*- explicit-buffer-name: "CMakeLists.txt<crlcore/src/x2y> -*-
include_directories ( ${CRLCORE_SOURCE_DIR}/src/ccore include_directories ( ${CRLCORE_SOURCE_DIR}/src/ccore
${HURRICANE_INCLUDE_DIR} ${HURRICANE_INCLUDE_DIR}
${UTILITIES_INCLUDE_DIR} ${UTILITIES_INCLUDE_DIR}
@ -26,6 +26,5 @@
${BZIP2_LIBRARIES} ${BZIP2_LIBRARIES}
${LIBEXECINFO_LIBRARIES} ${LIBEXECINFO_LIBRARIES}
${LIBBFD_LIBRARIES} ${LIBBFD_LIBRARIES}
z
) )
install ( TARGETS cx2y DESTINATION bin ) install ( TARGETS cx2y DESTINATION bin )

View File

Before

Width:  |  Height:  |  Size: 125 B

After

Width:  |  Height:  |  Size: 125 B

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 676 B

After

Width:  |  Height:  |  Size: 676 B

View File

Before

Width:  |  Height:  |  Size: 147 B

After

Width:  |  Height:  |  Size: 147 B

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Some files were not shown because too many files have changed in this diff Show More