python-3.x 我无法创建内部包含自定义包的pex文件

5ssjco0h  于 2023-02-01  发布在  Python
关注(0)|答案(1)|浏览(128)

我按照this教程将我自己的包添加到.pex中,但此教程基于python 2,我尝试为python3.10.6重新创建,但不起作用。我的包的结构如下hello/init.py,hello/hello.py,hello/setup.py

初始化.py(空)

hello.py:

def hello(): 
       print("hello!")

setup.py:

from distutils.core import setup
setup( name='hello', version='0.0.1', py_modules=['hello'] )

但当我尝试构建pex文件时,显示以下错误:

$ pex hello -e hello:hello -o hello.pex
pid 282 -> /home/leraes93/.pex/venvs/607954d150b1247ce7c1a15f91d4c7d23be98298/5985ed09b49a653d6596b0e14d134c5456cf1a9f/bin/python -sE /home/leraes93/.pex/venvs/607954d150b1247ce7c1a15f91d4c7d23be98298/5985ed09b49a653d6596b0e14d134c5456cf1a9f/pex --disable-pip-version-check --no-python-version-warning --exists-action a --no-input --use-deprecated legacy-resolver --isolated -q --cache-dir /home/leraes93/.pex/pip_cache download --dest /home/leraes93/.pex/downloads/resolver_download.dbt8psp4/mnt.c.Users.PC.Documents.env_medical_app.bin.python3 hello --index-url https://pypi.org/simple 
--retries 5 --timeout 15 exited with 1 and STDERR:
Re-execing from /home/leraes93/.pex/venvs/607954d150b1247ce7c1a15f91d4c7d23be98298/5985ed09b49a653d6596b0e14d134c5456cf1a9f/bin/python
ERROR: Could not find a version that satisfies the requirement hello (from versions: none)
ERROR: No matching distribution found for hello
5ktev3wc

5ktev3wc1#

  • ------如何运行. pex文件:----------首先安装以下库(如果bdist_wheel无法安装,请跳过该步骤)
  • 管子安装轮
  • 管道安装
  • 管道安装bdist_wheel
  • python网址:www.example.com bdist轮setup.py bdist_wheel
  • 导出PYTHON_ENTRYPOINT =包.我的包
  • pex-禁用缓存。-e ${PYTHON_ENTRYPOINT}-o应用程序. pex(输入

对于运行,只需运行以下命令:'./应用程序. pex'
文件夹列表:从安装程序导入操作系统工具导入安装程序,查找软件包APP版本= os. environ. get("APP版本",'0.0.0')APP名称= os. environ. get("APP名称",'api名称")setup.py ----- `import os from setuptools import setup, find_packages APP_VERSION = os.environ.get("APP_VERSION", '0.0.0') APP_NAME = os.environ.get("APP_NAME", "api-name")

def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()

setup(
    name=APP_NAME,
    version=APP_VERSION,
    packages=find_packages(),
    package_data={"": ["setup.cfg"]},
    include_package_data=True
)`

setup.cfg-----[pycodestyle]最大行长度= 200忽略= W605、E402、E713、E712

--- package
    --- my_package.py
        ---def my_function():
                print('hello')
           my_function()
    --- __init__.py
--- setup.py
--- setup.cfg

相关问题