Commit 307a67b2 authored by Clownce Deng's avatar Clownce Deng

fix: modify dir, change name

parent a3c73dac
...@@ -77,6 +77,8 @@ Thumbs.db ...@@ -77,6 +77,8 @@ Thumbs.db
**/dist/ **/dist/
**/build/ **/build/
**/*.egg-info/
**/build*/
!src/lib/*.qm !src/lib/*.qm
# SINCPM # SINCPM
......
...@@ -3,25 +3,24 @@ import platform ...@@ -3,25 +3,24 @@ import platform
import subprocess import subprocess
import shutil import shutil
from pathlib import Path from pathlib import Path
from setuptools import setup, Extension, find_namespace_packages from setuptools import setup, Extension, find_packages
from setuptools.command.build_ext import build_ext from setuptools.command.build_ext import build_ext
from PySide6.support.generate_pyi import generate_all_pyi
# ---- PROJECT SETTING ---------- # # ---- PROJECT SETTING ---------- #
NAMESPACE = "timp" PROJECT = "timp_pcbcam"
PROJECT = "pcbcam" LIBNAME = "libpcbcam"
VERSION = "1.0.0" VERSION = "1.0.0"
DESCRIPTION = "pcbcam lib" DESCRIPTION = "timp_pcbcam lib"
# ---- END OF PROJECT SETTING ----# # ---- END OF PROJECT SETTING ----#
class CMakeExtension(Extension): class CMakeExtension(Extension):
""" CMake编译扩展类 """ """ CMake编译扩展类 """
def __init__(self, name: str, namespace: str = "", sourcedir: str = ""): def __init__(self, name: str, libname: str = "", sourcedir: str = ""):
Extension.__init__(self, name, sources=[]) Extension.__init__(self, name, sources=[])
self.namespace = namespace self.libname = libname
self.sourcedir = os.path.abspath(sourcedir) self.sourcedir = os.path.abspath(sourcedir)
...@@ -31,14 +30,10 @@ class CMakeBuild(build_ext): ...@@ -31,14 +30,10 @@ class CMakeBuild(build_ext):
def build_extension(self, ext): def build_extension(self, ext):
# setuptools 打包文件时创建的临时路径 # setuptools 打包文件时创建的临时路径
py_build_dir = Path(os.path.abspath(self.build_lib)) py_build_dir = Path(os.path.abspath(self.build_lib))
if ext.namespace:
py_build_dir = py_build_dir.joinpath(ext.namespace)
py_build_dir = py_build_dir.joinpath(ext.name) py_build_dir = py_build_dir.joinpath(ext.name)
if not py_build_dir.exists():
os.makedirs(py_build_dir)
# c++源码所在路径,在不同系统下使用不同的编译目录 # c++源码所在路径,在不同系统下使用不同的编译目录
build_temp = Path(ext.sourcedir).parent.joinpath('build') build_temp = Path(ext.sourcedir).joinpath('build-' + platform.system())
if not build_temp.exists(): if not build_temp.exists():
os.makedirs(build_temp) os.makedirs(build_temp)
...@@ -61,7 +56,7 @@ class CMakeBuild(build_ext): ...@@ -61,7 +56,7 @@ class CMakeBuild(build_ext):
libray_files = [] libray_files = []
if platform.system() == "Windows": if platform.system() == "Windows":
libray_files.append("{}.pyd".format(ext.name)) libray_files.append("{}.pyd".format(ext.name))
libray_files.append("lib{}.dll".format(ext.name)) libray_files.append("{}.dll".format(ext.libname))
elif platform.system() == "Darwin": elif platform.system() == "Darwin":
libray_files.append("{}.so".format(ext.name)) libray_files.append("{}.so".format(ext.name))
libray_files.append("lib{}.dylib".format(ext.name)) libray_files.append("lib{}.dylib".format(ext.name))
...@@ -70,7 +65,7 @@ class CMakeBuild(build_ext): ...@@ -70,7 +65,7 @@ class CMakeBuild(build_ext):
libray_files.append("lib{}.so".format(ext.name)) libray_files.append("lib{}.so".format(ext.name))
print('copying dynamic library file') print('copying dynamic library file')
# pak_dir = Path(ext.sourcedir).parent.joinpath(ext.namespace, ext.name) # pak_dir = Path(ext.sourcedir).parent.joinpath(ext.name)
for lib in libray_files: for lib in libray_files:
src_file = build_temp.joinpath(lib) src_file = build_temp.joinpath(lib)
print(f'copying {src_file} -> {py_build_dir}') print(f'copying {src_file} -> {py_build_dir}')
...@@ -113,16 +108,16 @@ class CMakeBuild(build_ext): ...@@ -113,16 +108,16 @@ class CMakeBuild(build_ext):
setup( setup(
name="{}.{}".format(NAMESPACE, PROJECT), name=PROJECT,
version=VERSION, version=VERSION,
author="toplinker", author="toplinker",
author_email="service@topibd.com", author_email="service@topibd.com",
description=DESCRIPTION, description=DESCRIPTION,
long_description=DESCRIPTION, long_description=DESCRIPTION,
ext_modules=[CMakeExtension(name=PROJECT, namespace=NAMESPACE, sourcedir="lib")], ext_modules=[CMakeExtension(name=PROJECT, libname=LIBNAME, sourcedir="src/cxx")],
cmdclass={"build_ext": CMakeBuild}, cmdclass={"build_ext": CMakeBuild},
package_dir={'': 'build'}, package_dir={'': 'src'},
packages=find_namespace_packages(where='build', include=["{}.{}".format(NAMESPACE, PROJECT)]), packages=find_packages(where='src', include=[PROJECT]),
python_requires='>=3.8', python_requires='>=3.8',
install_requires=[ install_requires=[
'PySide6', 'PySide6',
......
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<typesystem package="pcbcam"> <typesystem package="timp_pcbcam">
<load-typesystem name="typesystem_core.xml" generate="no"/> <load-typesystem name="typesystem_core.xml" generate="no"/>
<load-typesystem name="typesystem_gui.xml" generate="no"/> <load-typesystem name="typesystem_gui.xml" generate="no"/>
<load-typesystem name="typesystem_widgets.xml" generate="no"/> <load-typesystem name="typesystem_widgets.xml" generate="no"/>
......
#----------------项目设置---------------------------------------------------- #----------------项目设置----------------------------------------------------
PROJECT_NAME = titan_pcbcam PROJECT_NAME = timp_pcbcam
ROOT_DIR = $$PWD/../ ROOT_DIR = $$PWD/../
HEADER_DIR = titan/pcbcam HEADER_DIR =
DLL_LIBS = DLL_LIBS =
STATIC_LIBS = STATIC_LIBS =
VERSION = 2.0.3 VERSION = 2.0.3
......
...@@ -10,6 +10,7 @@ PYSIDE = 'pyside6' ...@@ -10,6 +10,7 @@ PYSIDE = 'pyside6'
PYSIDE_MODULE = 'PySide6' PYSIDE_MODULE = 'PySide6'
SHIBOKEN = 'shiboken6' SHIBOKEN = 'shiboken6'
class Package(Enum): class Package(Enum):
SHIBOKEN_MODULE = 1 SHIBOKEN_MODULE = 1
SHIBOKEN_GENERATOR = 2 SHIBOKEN_GENERATOR = 2
......
from .timp_pcbcam import *
\ No newline at end of file
from timp.pcbcam import PcbCamUtil as UT import PySide6.QtCore
import PySide6.QtWidgets
from timp_pcbcam import PcbCamUtil as UT
if __name__ == "__main__": if __name__ == "__main__":
a = UT.formatNumber(12.135456789, 2) a = UT.formatNumber(12.135456789, 2)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment