Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用批处理脚本打包python项目_Python_Git_Python 2.7_Batch File_Setuptools - Fatal编程技术网

使用批处理脚本打包python项目

使用批处理脚本打包python项目,python,git,python-2.7,batch-file,setuptools,Python,Git,Python 2.7,Batch File,Setuptools,您好,我目前有一个使用子流程的python项目。Popen运行一些批处理文件 是否可以将批处理文件打包为源文件。因此,当我们的其他一些python项目使用setup.py在install_requires中包含当前的python项目时,其他项目可以安装和更新这些批处理文件,并从源代码使用它们(即,也可以使用subprocess.Popen运行这些脚本) 有人知道我该怎么做吗 提前谢谢 如果您有运行python包所需的bash脚本,您可以简单地将它们存储在包文件夹中,并且在使用setuptools

您好,我目前有一个使用子流程的python项目。Popen运行一些批处理文件

是否可以将批处理文件打包为源文件。因此,当我们的其他一些python项目使用setup.py在install_requires中包含当前的python项目时,其他项目可以安装和更新这些批处理文件,并从源代码使用它们(即,也可以使用subprocess.Popen运行这些脚本)

有人知道我该怎么做吗


提前谢谢

如果您有运行python包所需的bash脚本,您可以简单地将它们存储在包文件夹中,并且在使用setuptools安装包时应该包含它们。下面是一个可能的文件夹结构示例:

/myproject
    /myproject
        __init__.py
        main.py
        batch.sh
    setup.py
在main.py中,您可以通过以下方式访问批处理文件:

import os.path
import subprocess

current_dir = os.path.dirname(os.path.abspath(__file__))
batch_script = os.path.join(current_dir, 'batch.sh')
subprocess.call(batch_script)
更新


根据其他注释,如果您需要一种方法使第三方软件包可以访问批处理脚本,则可以在setuptools中的“scripts”键中指定脚本。您可以在setuptools中看到这个可用选项。

到目前为止,您有什么?几个批处理文件,它们在各种python项目中重复使用。在部署python项目时,我们通常只从svn/git获取批处理文件。然而,我们正在试图找出是否有一种方法可以让我们处理批处理文件,就像处理python模块一样,我们可以在setup.py中指定,setuptool可以为我们获取它。