Open Zhaoyilunnn opened 3 months ago
I made some changes to existing config files https://github.com/openqasm/qe-compiler/compare/main...Zhaoyilunnn:qe-compiler:zhaoyilun-local-conan-package
Then a local conan package can be built through conan create . zhaoyilun/qe-compiler --build=outdated -pr:h default -pr:b default -o qss-compiler:pythonlib=False
Hi @Zhaoyilunnn, thank you for writing up this issue. The qe-compiler is still in its infancy of being an opensource project and we certainly have a lot of work to do in migrating documentation that needs to be resumed.
Note that I can seamlessly build qe-compiler locally, but I just cannot build a conan package of it and then make my own project dependent on qe-compiler.
In particular, we have not attempted this path to development yet, but are very interested in this. Internally, we are using the project as a submodule with integration through the Cmake build system.
I made some changes to existing config files https://github.com/openqasm/qe-compiler/compare/main...Zhaoyilunnn:qe-compiler:zhaoyilun-local-conan-package Then a local conan package can be built through conan create . zhaoyilun/qe-compiler --build=outdated -pr:h default -pr:b default -o qss-compiler:pythonlib=False
We would be very interested if you could make a draft PR demonstrating this work so that we could discuss how it might be incorporated in-tree.
An obfuscated version of our top-level CMakeLists to integrate the project
cmake_minimum_required(VERSION 3.25)
project(target-compiler)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/cmake ${CMAKE_MODULE_PATH})
set(QSSC_SYSTEMS_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/targets/systems"
CACHE STRING
"The directory containing the common systems"
)
option(QSSC_WITH_MOCK_TARGET "Available targets include the built-in mock target" ON)
option(QSSC_WITH_SYSTEM_CONFIG "Use system_config to retrieve configuration for targets" OFF)
option(QSSC_BUILD_DOCS "Build the documentation for the compiler" ON)
# List of directories containing compiler targets. Subtargets should be
# listed first so that they are built before top-level targets
set(QSSC_TARGET_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/targets/systems/YourTarget;
CACHE PATH
"List of directories containing compiler targets."
)
set(QSSC_TARGET_TEST_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/targets/systems/YourTarget/test;
CACHE PATH
"List of directories containing compiler LIT test suites."
)
set(QSSC_TARGET_PYTHON_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/targets/systems/YourTarget/python_lib/
CACHE PATH
"List of directories containing compiler target python additions."
)
# Build type
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
# Here is the submodule which we integrate through
# the Cmake build system with
add_subdirectory(qe-compiler)
In this way our internal project contains our targets in a very similar way to https://github.com/openqasm/qe-compiler/tree/main/targets/systems/mock with a top-level cmake file which we use to generate internal binaries. The rough project structure is
target-compiler/
qe-compiler/
(submodule)targets/systems/YourTarget/
CMakeLists.txt
We could be very interested in enabling the pathway to remove the qe-compiler
submodule and replace it with a Conan dependency.
An obfuscated version of our top-level CMakeLists to integrate the project
cmake_minimum_required(VERSION 3.25) project(target-compiler) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/cmake ${CMAKE_MODULE_PATH}) set(QSSC_SYSTEMS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/targets/systems" CACHE STRING "The directory containing the common systems" ) option(QSSC_WITH_MOCK_TARGET "Available targets include the built-in mock target" ON) option(QSSC_WITH_SYSTEM_CONFIG "Use system_config to retrieve configuration for targets" OFF) option(QSSC_BUILD_DOCS "Build the documentation for the compiler" ON) # List of directories containing compiler targets. Subtargets should be # listed first so that they are built before top-level targets set(QSSC_TARGET_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/targets/systems/YourTarget; CACHE PATH "List of directories containing compiler targets." ) set(QSSC_TARGET_TEST_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/targets/systems/YourTarget/test; CACHE PATH "List of directories containing compiler LIT test suites." ) set(QSSC_TARGET_PYTHON_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/targets/systems/YourTarget/python_lib/ CACHE PATH "List of directories containing compiler target python additions." ) # Build type if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() set(CMAKE_COMPILE_WARNING_AS_ERROR ON) # Here is the submodule which we integrate through # the Cmake build system with add_subdirectory(qe-compiler)
In this way our internal project contains our targets in a very similar way to https://github.com/openqasm/qe-compiler/tree/main/targets/systems/mock with a top-level cmake file which we use to generate internal binaries. The rough project structure is
target-compiler/
qe-compiler/
(submodule)targets/systems/YourTarget/
CMakeLists.txt
We could be very interested in enabling the pathway to remove the
qe-compiler
submodule and replace it with a Conan dependency.
@taalexander Thanks a lot for your example CMakeLists.txt, actually I gave up making qe-compiler a conan package and adopted a similar top-level CMakeLists.txt ^_^
I am still in the progress of finding the correct way to make it a Conan package. I will make a PR once I figure it out
Thank you @Zhaoyilunnn, happy to help however you might like. In general, as you're making progress I'd love to chat to understand better what you are trying to do and how to enable it.
Hi Team,
Currently I still cannot figure out how to make this project dependent on qe-compiler.
qe-compiler
is an excellent project, I believe many users would like to develop their own full compilers based on this framework. Thus it would be helpful if you could provide some instructions on how to achieve this. I am also very willing to contribute if it requires more effort to make this project a conan package that other projects can depend on.Here are two ways I have tried but failed. Note that I can seamlessly build qe-compiler locally, but I just cannot build a conan package of it and then make my own project dependent on qe-compiler.
01 Manually
This is done by copying
conandata.yml
andconanfile.py
to the path./conan/qec
and create aconan_deps.sh
, which essentially callsconan export
Steps
Manually create a conan package and export it to local cache and then build it
Then install qe-compiler through conan
This method finally results in
02 Conan
Then I tried using
conan create
to create a local conan package.In the root directory of qe-compiler
Initially, I met following error
The root cause is that conan will not copy
.git
directory into the local cache, resulting in the error ofsetuptools_scm
. After checking the CMakeLists.txt, I found that I can explicitly setVERSION_STRING
to avoid usingsetuptools_scm
.After fixing the above error, it results in a cyclic dependency error
System info