Skip to content

Commit 1d517e6

Browse files
committed
Fix Many Things
1 parent 68e07bd commit 1d517e6

13 files changed

Lines changed: 34 additions & 91 deletions

File tree

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@ A Template of Python Project in Visual Studio Code with Github Actions CI/CD (Es
33

44
## How to Build
55

6+
Create a new conda environment:
7+
68
```bash
79
conda create -n pytemplate python=3.12
810
conda activate pytemplate
9-
pip install .
1011
```
1112

12-
`torch.ops.example_package.vector_add` will be available after installation.
13+
Install `example_package`:
14+
15+
```bash
16+
pip3 install .
17+
```
18+
19+
`torch.ops.example_package.vector_add` will be available after installation; See [test.py](test/test.py) for usage.
1320

1421
## How to Test
1522

csrc/CMakeLists.txt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.30)
55
project(VSC-CMAKE-CXX-TEMPLATE VERSION 1.0.0)
66

77
####################################################################################################
8-
# [!] All CMake Options and Variables MAY Affect the Build Process
8+
# [NOTE] All CMake Options and Variables MAY Affect the Build Process
99
#
1010
# In "cmake/utils/logging.cmake":
1111
# - `LOG_PREFIX`: The prefix for logging messages
@@ -31,8 +31,8 @@ project(VSC-CMAKE-CXX-TEMPLATE VERSION 1.0.0)
3131
# - `BUILD_SHARED_LIBS`: Whether to build shared libraries
3232
####################################################################################################
3333

34-
# Utility functions for setting values:
35-
include(${PROJECT_SOURCE_DIR}/cmake/utils/variables.cmake)
34+
# Common utility functions
35+
include(${PROJECT_SOURCE_DIR}/cmake/utils/common.cmake)
3636

3737
# @see "./cmake/utils/variables.cmake"
3838
set_default_values(
@@ -53,8 +53,4 @@ include(${PROJECT_SOURCE_DIR}/cmake/compilers/cuda-compiler-configs.cmake)
5353
include(${PROJECT_SOURCE_DIR}/cmake/libraries/libpython.cmake)
5454
include(${PROJECT_SOURCE_DIR}/cmake/libraries/libtorch.cmake)
5555

56-
57-
add_subdirectory(${PROJECT_SOURCE_DIR}/lib)
58-
59-
# # [FIXME] Not support linking modules to an executable target
60-
# add_subdirectory(${PROJECT_SOURCE_DIR}/test)
56+
add_subdirectory(${PROJECT_SOURCE_DIR}/lib)

csrc/cmake/utils/lib-install.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
include(GNUInstallDirs)
22
include(CMakePackageConfigHelpers)
33

4-
# ==============================================================================
54
# @breif Install target libraries
65
function(install_libraries LIB_COMPONENT LIB_NAMESPACE LIB_LIST)
76
log_info("Libraries to install:")

csrc/cmake/utils/logging.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# @note This file shoule NEVER include any other file (to avoid circular dependencies).
66
# @note Several parameters SHOULD be set BEFORE including this file:
7-
# - `LOG_PREFIX`: Prefix for logging. Default: "ᓚᘏᗢ".
7+
# - `LOG_PREFIX`: Prefix for logging. Default: "LogPrefix".
88
# ==================================================================================================
99

1010
string(ASCII 27 Esc)

csrc/cmake/utils/run-python.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
include(${PROJECT_SOURCE_DIR}/cmake/utils/logging.cmake)
2-
include(${PROJECT_SOURCE_DIR}/cmake/utils/variables.cmake)
2+
include(${PROJECT_SOURCE_DIR}/cmake/utils/common.cmake)
33

44

5-
# Run python command and get result, output and error
5+
# @brief Run python command and get result, output and error
66
function(run_python PY_COMMAND PY_RESULT PY_OUTPUT PY_ERROR)
77
set_default_values(PYTHON_EXECUTABLE "python")
88
execute_process(
@@ -14,7 +14,7 @@ function(run_python PY_COMMAND PY_RESULT PY_OUTPUT PY_ERROR)
1414
ERROR_STRIP_TRAILING_WHITESPACE
1515
)
1616
if(NOT _PY_RESULT EQUAL 0)
17-
playground_log_fatal("run_python: PY_COMMAND failed:\n${_PY_ERROR}")
17+
log_fatal("run_python: PY_COMMAND failed:\nCOMMAND:\n${PY_COMMAND}\nERROR:\n${_PY_ERROR}")
1818
endif()
1919
set(${PY_RESULT} "${_PY_RESULT}" PARENT_SCOPE)
2020
set(${PY_OUTPUT} "${_PY_OUTPUT}" PARENT_SCOPE)

csrc/scripts/build.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ windows_prune_env_path() {
2020
local new_path=""
2121

2222
# Include only the necessary paths
23-
# You may want to add "conda" to the list if you are using Anaconda/Miniconda
24-
local -a include_paths=("/usr/bin" "cuda" "windows kits" "microsoft visual studio")
23+
local -a include_paths=("/usr/bin" "nvidia" "cuda" "windows kits" "microsoft visual studio" "conda")
2524
local -a filtered_paths
2625
for path in "${paths[@]}"; do
2726
local lowercase_path=$(echo "$path" | tr '[:upper:]' '[:lower:]')

csrc/test/CMakeLists.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

csrc/test/main.cpp

Lines changed: 0 additions & 34 deletions
This file was deleted.

example_package/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ def load_torch_ops(lib_dir: str):
1313
torch.ops.load_library(os.path.join(root, file))
1414

1515

16-
load_torch_ops(osp.join(PACKAGE_DIR, "_torch_ops_cxx"))
16+
load_torch_ops(osp.join(PACKAGE_DIR, "_torch_ops"))

0 commit comments

Comments
 (0)