Skip to content

Commit

Permalink
update 0407
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangyu17 authored and jiangyu17 committed Apr 17, 2024
1 parent 55b4037 commit 4ebbd66
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
6 changes: 2 additions & 4 deletions pprobe/bootstrap/_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def find_module(self, fullname, path=None):
class MetaPathLoader:

def load_module(self, fullname):
# print('load_module {}'.format(fullname))
Logger.info('load_module {}'.format(fullname))
# ``sys.modules`` 中保存的是已经导入过的 module
if fullname in sys.modules:
return sys.modules[fullname]
Expand All @@ -27,12 +27,10 @@ def load_module(self, fullname):
# 防止下面执行 import_module 的时候再次触发此 finder
# 从而出现递归调用的问题
finder = sys.meta_path.pop(0)
# 导入 module
module = importlib.import_module(fullname)

module_hook(fullname, module)

sys.meta_path.insert(0, finder)

return module

sys.meta_path.insert(0, MetaPathFinder())
Expand Down
2 changes: 1 addition & 1 deletion pprobe/bootstrap/sitecustomize.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import _hook
from pprobe.bootstrap import _hook
2 changes: 1 addition & 1 deletion script/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project_dir=$(git rev-parse --show-toplevel)
cd "${project_dir}"

# 清理项目目录
git clean -dxf
# git clean -dxf

# 构建 wheel 包
python setup.py bdist_wheel
Expand Down
13 changes: 13 additions & 0 deletions script/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -euo pipefail

# 获取项目根目录
project_dir=$(git rev-parse --show-toplevel)

# 切换到项目根目录
cd "${project_dir}"

cd pprobe/tests

python xtest_torchvision_model.py -a resnet50 --epochs 1 -b 12 -p 1 --seed 42 --dummy

26 changes: 17 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from setuptools import setup, find_packages
from setuptools.command.build_py import build_py
import os
import shutil

Expand All @@ -18,25 +19,32 @@ def read_requirements(file_path):
print("pprobe install_requires:", f.read().splitlines())
return f.read().splitlines()

class build_py_with_pth_file(build_py):
"""Include the .pth file for this project, in the generated wheel."""
def run(self):
super().run()
destination_in_wheel = "pprobe.pth"
location_in_source_tree = "pprobe.pth"
outfile = os.path.join(self.build_lib, destination_in_wheel)
self.copy_file(location_in_source_tree, outfile, preserve_mode=0)

setup(
name="pprobe",
version="1.0.0",
packages=find_packages(exclude=["pprobe/tests"]),
include_package_data=True,
install_requires=read_requirements("./requirements.txt"),
# package_data={
# '': ['*.pth'], # 添加所有.pth文件到安装中
# },

author="clemente0620",
author_email="[email protected]",
description="A hook tool for python",
long_description="A hook tool for python",
url="https://www.pprobe.com/pprobe",
author="clemente0620",
author_email="[email protected]",
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
packages=find_packages(exclude=["pprobe/tests"]),
include_package_data=True,
package_data={"": ["*.pth"]}, # 将所有.pth文件包含在安装中
install_requires=read_requirements("./requirements.txt"),
zip_safe=False,
cmdclass={"build_py": build_py_with_pth_file},
)

0 comments on commit 4ebbd66

Please sign in to comment.