Skip to content

Commit

Permalink
fix install directory;
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoqing committed Apr 17, 2024
1 parent c97154a commit 4d6636d
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/src/cpp",
"${workspaceFolder}/src/PyCXpress/include",
"/opt/conda/envs/py38/include/python3.8",
"/opt/conda/envs/py38/lib/python3.8/site-packages/pybind11/include"
],
Expand Down
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 启动",
"name": "(gdb) on Example",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/example/example.out",
"program": "${workspaceFolder}/src/PyCXpress/example/example.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/example",
"cwd": "${workspaceFolder}/src/PyCXpress/example/",
"environment": [{
"name": "PATH",
"value": "/opt/conda/envs/py38/bin"
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"./src/python"
],
"files.associations": {
"tuple": "cpp"
"tuple": "cpp",
"array": "cpp"
}
}
21 changes: 17 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
#* Variables
SHELL := /usr/bin/env bash
PYTHON := python
PYTHONPATH := `pwd`

CXX_SOURCES = $(shell find . -name '*.cpp' -o -name '*.cxx' -o -name '*.cc' -o -name '*.c++' -o -name '*.hpp' -o -name '*.h')
THIS_MAKEFILE := $(realpath $(lastword $(MAKEFILE_LIST)))
REPO_DIR := $(patsubst %/,%,$(dir $(THIS_MAKEFILE)))
REPO_PREFIX := ../$(notdir $(abspath $(REPO_DIR)))

PYTHON := python3
PYTHONPATH := $(REPO_DIR)/src

CXX_SOURCES = $(shell find $(REPO_DIR) -name '*.cpp' -o -name '*.cxx' -o -name '*.cc' -o -name '*.c++' -o -name '*.hpp' -o -name '*.h')

#* Makefile debugging
print-%: ; @$(warning $* is $($*) ($(value $*)) (from $(origin $*)))

define message
@echo -n "make[top]: "
@echo $(1)
endef

#* Poetry
.PHONY: poetry-download
Expand Down Expand Up @@ -104,7 +117,7 @@ pytestcache-remove:

.PHONY: build-dist
build-dist:
poetry run python -m build --outdir dist/
$(PYTHON) -m build --outdir dist/

.PHONY: build-remove
build-remove:
Expand Down
81 changes: 4 additions & 77 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "PyCXpress"
version = "0.0.2"
version = "0.0.3"
description = "PyCXpress is a high-performance hybrid framework that seamlessly integrates Python and C++ to harness the flexibility of Python and the speed of C++ for efficient and expressive computation, particularly in the realm of deep learning and numerical computing."
readme = "README.md"
authors = ["chaoqing <[email protected]>"]
Expand All @@ -15,17 +15,13 @@ homepage = "https://github.com/chaoqing/PyCXpress"
packages = [
{ include = "PyCXpress", from = "src" },
]
include = [
{ path = "src/cpp/", format = ["sdist", "wheel"] },
{ path = "example/", format = ["sdist", "wheel"] },
]


# Keywords description https://python-poetry.org/docs/pyproject/#keywords
keywords = [] #! Update me
keywords = ["CPP", "Embdedding"]

# Pypi classifiers: https://pypi.org/classifiers/
classifiers = [ #! Update me
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
Expand All @@ -38,7 +34,7 @@ classifiers = [ #! Update me

[tool.poetry.scripts]
# Entry points for the package https://python-poetry.org/docs/pyproject/#scripts
"PyCXpress" = "PyCXpress.__main__:main"
"pycxpress" = "PyCXpress.__main__:main"

[tool.poetry.dependencies]
python = "^3.8"
Expand Down Expand Up @@ -144,7 +140,7 @@ addopts = [
source = ["tests"]

[coverage.paths]
source = "PyCXpress"
source = "src"

[coverage.run]
branch = true
Expand Down
11 changes: 2 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
click==8.1.7 ; python_version >= "3.8" and python_version < "4.0"
colorama==0.4.6 ; python_version >= "3.8" and python_version < "4.0" and platform_system == "Windows"
markdown-it-py==3.0.0 ; python_version >= "3.8" and python_version < "4.0"
mdurl==0.1.2 ; python_version >= "3.8" and python_version < "4.0"
pygments==2.17.2 ; python_version >= "3.8" and python_version < "4.0"
rich==13.7.1 ; python_version >= "3.8" and python_version < "4.0"
shellingham==1.5.4 ; python_version >= "3.8" and python_version < "4.0"
typer[all]==0.12.3 ; python_version >= "3.8" and python_version < "4.0"
typing-extensions==4.11.0 ; python_version >= "3.8" and python_version < "4.0"
numpy==1.24.4 ; python_version >= "3.8" and python_version < "4.0"
pybind11==2.12.0 ; python_version >= "3.8" and python_version < "4.0"
2 changes: 1 addition & 1 deletion example/Makefile → src/PyCXpress/example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CC = c++
CFLAGS = -g -Wall -std=c++17 -fPIC
CFLAGS = -I../src/cpp
CFLAGS += $(shell python3-config --cflags --ldflags --embed)
CFLAGS += $(shell PYTHONPATH=../src/ python3 -m PyCXpress --includes) -I ../src/include
CFLAGS += $(shell PYTHONPATH=../../ python3 -m PyCXpress --includes)

# The build target executable
TARGET = example.out
Expand Down
4 changes: 2 additions & 2 deletions example/main.cpp → src/PyCXpress/example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <iterator>
#define PYBIND11_DETAILED_ERROR_MESSAGES

#include <PyCXpress.hpp>
#include <Utils.hpp>
#include <PyCXpress/core.hpp>
#include <PyCXpress/utils.hpp>

namespace pcx = PyCXpress;

Expand Down
File renamed without changes.
21 changes: 17 additions & 4 deletions src/cpp/PyCXpress.hpp → src/PyCXpress/include/PyCXpress/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@
#include <string>
#include <vector>

#include "Utils.hpp"
#include "utils.hpp"

#if !defined(PYCXPRESS_EXPORT)
# if defined(WIN32) || defined(_WIN32)
# define PYCXPRESS_EXPORT __declspec(dllexport)
# else
# define PYCXPRESS_EXPORT __attribute__((visibility("default")))
# endif
#endif

namespace PyCXpress {
namespace py = pybind11;
using namespace utils;

class Buffer {
class PYCXPRESS_EXPORT
Buffer {
typedef unsigned char Bytes;

template <typename T>
Expand Down Expand Up @@ -70,6 +79,9 @@ class Buffer {
} else if (data_type == "double") {
m_converter = __to_array<double>;
m_length /= sizeof(double);
} else if (data_type == "char") {
m_converter = __to_array<char>;
m_length /= sizeof(char);
} else {
throw NotImplementedError(data_type);
}
Expand Down Expand Up @@ -104,7 +116,8 @@ class Buffer {
py::array (*m_converter)(const std::vector<size_t> &, void *);
};

class PythonInterpreter {
class PYCXPRESS_EXPORT
PythonInterpreter {
public:
explicit PythonInterpreter(bool init_signal_handlers = true, int argc = 0,
const char *const *argv = nullptr,
Expand Down Expand Up @@ -178,7 +191,7 @@ class PythonInterpreter {
auto meta = d->cast<py::tuple>();
m_buffers.insert(std::make_pair(
meta[0].cast<std::string>(),
Buffer{meta[2].cast<int>(), meta[1].cast<std::string>()}));
Buffer{meta[2].cast<size_t>(), meta[1].cast<std::string>()}));
}

for (auto d = output_fields.begin(); d != output_fields.end(); d++) {
Expand Down
File renamed without changes.

0 comments on commit 4d6636d

Please sign in to comment.