尽管遵循所有说明

发布于 2025-02-11 21:33:53 字数 2077 浏览 2 评论 0 原文

我遵循了所有指令概述在这里在安装过程中执行函数一个PIP包,但我仍然无法使用``pip install< my_package>''函数执行该功能。

我在 dist 文件夹中没有 .whl 文件。我的设置文件具有与上述站点中提到的文件相同的格式,与以下内容:

import urllib.request
import requests
## made some deletions here for simplicity sake
from setuptools.command.develop import develop
from setuptools.command.install import install

this_directory = Path(__file__).parent
long_description = ( this_directory/ "README.md").read_text()

def temp():
    print('running post installation')
    
    s = 'https://storage.googleapis.com/download/storage/etc'
    urllib.request.urlopen(s)
    if not os.path.exists(fold):
        os.mkdir(fold)
    file = f'{fold}hey.txt'  # this is got from elsewhere in the code
    r = requests.get(s, stream=True, verify=False)
    if r.status_code == 200:
        r.raw.decode_content = 1
        with open(file, 'wb') as f:
            f.write(r.content)
    else:
        p('failed to download data files')


class PostDevelopCommand(develop):
    """Post-installation for development mode."""
    def run(self):
        temp()
        develop.run(self)


class PostInstallCommand(install):
    """Post-installation for installation mode."""
    def run(self):
        temp()
        install.run(self)

setup(
    ### simplified this a bit
    install_requires=['Levenshtein',
                      'striprtf==0.0.12',
                      ],
    cmdclass={
            'develop': PostDevelopCommand,
            'install': PostInstallCommand,
        },

    classifiers=[
        'Development Status :: 1 - Planning',
        'Intended Audience :: Education',
        'License :: OSI Approved :: GNU General Public License (GPL)',
        'Operating System :: MacOS',
        'Programming Language :: Python :: 3.8',
    ],
)

下载包时,我什至没有读取: print('running post intert installation')导致相信函数 temp 未执行的代码>。我在做什么错?

I have followed all the instructions outlined here for executing a function during the installation of a pip package but I still cannot get the function to execute up using `pip install <my_package>.

I have no .whl file in the dist folder. My setup file has the same format as the file mentioned in the aforementioned site as follows:

import urllib.request
import requests
## made some deletions here for simplicity sake
from setuptools.command.develop import develop
from setuptools.command.install import install

this_directory = Path(__file__).parent
long_description = ( this_directory/ "README.md").read_text()

def temp():
    print('running post installation')
    
    s = 'https://storage.googleapis.com/download/storage/etc'
    urllib.request.urlopen(s)
    if not os.path.exists(fold):
        os.mkdir(fold)
    file = f'{fold}hey.txt'  # this is got from elsewhere in the code
    r = requests.get(s, stream=True, verify=False)
    if r.status_code == 200:
        r.raw.decode_content = 1
        with open(file, 'wb') as f:
            f.write(r.content)
    else:
        p('failed to download data files')


class PostDevelopCommand(develop):
    """Post-installation for development mode."""
    def run(self):
        temp()
        develop.run(self)


class PostInstallCommand(install):
    """Post-installation for installation mode."""
    def run(self):
        temp()
        install.run(self)

setup(
    ### simplified this a bit
    install_requires=['Levenshtein',
                      'striprtf==0.0.12',
                      ],
    cmdclass={
            'develop': PostDevelopCommand,
            'install': PostInstallCommand,
        },

    classifiers=[
        'Development Status :: 1 - Planning',
        'Intended Audience :: Education',
        'License :: OSI Approved :: GNU General Public License (GPL)',
        'Operating System :: MacOS',
        'Programming Language :: Python :: 3.8',
    ],
)

On downloading the package I am not even getting the reading: print('running post installation') which leads to believe that the function temp is not being executed. What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘味果▽酱 2025-02-18 21:33:53

您无法更改PIP日志

我遵循所有指令概述在这里在此期间执行功能安装PIP软件包,但我仍然无法使用 pip install&lt; my_package&gt;

运行 pip install&lt; my_package&gt; ,您将仅看到 pip 日志,并且在 pip install 中无法更改它或调用某些功能。请想象,如果我们可以在 pip安装期间运行任何脚本,我们可以窃取任何不需要权限的信息。

完成设置的参数函数

我在 dist> dist 文件夹中没有 .whl 文件。

setup.py 仅缺少设置函数的一些参数。按照我的。另外,我不确定您正在正确运行构建,因此请使用答案中提供的构建命令。

不要将下载包装与后安装式下载 Egg

在下载软件包时,我什至没有获得读数: print('运行帖子安装'),它会相信函数 temp 尚未执行。我在做什么错?

它在 .egg 上打印在 python3设置。对我来说,这是愚蠢。

running sdist
running egg_info
creating my_package.egg-info
writing my_package.egg-info/PKG-INFO
writing dependency_links to my_package.egg-info/dependency_links.txt
writing requirements to my_package.egg-info/requires.txt
writing top-level names to my_package.egg-info/top_level.txt
writing manifest file 'my_package.egg-info/SOURCES.txt'
reading manifest file 'my_package.egg-info/SOURCES.txt'
writing manifest file 'my_package.egg-info/SOURCES.txt'
warning: sdist: standard file not found: should have one of README, README.rst, README.txt, README.md

running check
warning: Check: missing required meta-data: url

creating my_package-0.0.1
creating my_package-0.0.1/my_package
creating my_package-0.0.1/my_package.egg-info
copying files to my_package-0.0.1...
copying setup.py -> my_package-0.0.1
copying my_package/__init__.py -> my_package-0.0.1/my_package
copying my_package/demo.py -> my_package-0.0.1/my_package
copying my_package.egg-info/PKG-INFO -> my_package-0.0.1/my_package.egg-info
copying my_package.egg-info/SOURCES.txt -> my_package-0.0.1/my_package.egg-info
copying my_package.egg-info/dependency_links.txt -> my_package-0.0.1/my_package.egg-info
copying my_package.egg-info/requires.txt -> my_package-0.0.1/my_package.egg-info
copying my_package.egg-info/top_level.txt -> my_package-0.0.1/my_package.egg-info
Writing my_package-0.0.1/setup.cfg
creating dist
Creating tar archive
removing 'my_package-0.0.1' (and everything under it)
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/my_package
copying my_package/demo.py -> build/lib/my_package
copying my_package/__init__.py -> build/lib/my_package
installing to build/bdist.linux-x86_64/wheel
running install
running post installation
/home/artyom/.local/lib/python3.9/site-packages/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'storage.googleapis.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(
failed to download data files
running install_lib
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/wheel
creating build/bdist.linux-x86_64/wheel/my_package
copying build/lib/my_package/demo.py -> build/bdist.linux-x86_64/wheel/my_package
copying build/lib/my_package/__init__.py -> build/bdist.linux-x86_64/wheel/my_package
running install_egg_info
Copying my_package.egg-info to build/bdist.linux-x86_64/wheel/my_package-0.0.1-py3.9.egg-info
running install_scripts
creating build/bdist.linux-x86_64/wheel/my_package-0.0.1.dist-info/WHEEL
creating 'dist/my_package-0.0.1-py3-none-any.whl' and adding 'build/bdist.linux-x86_64/wheel' to it
adding 'my_package/__init__.py'
adding 'my_package/demo.py'
adding 'my_package-0.0.1.dist-info/METADATA'
adding 'my_package-0.0.1.dist-info/WHEEL'
adding 'my_package-0.0.1.dist-info/top_level.txt'
adding 'my_package-0.0.1.dist-info/RECORD'
removing build/bdist.linux-x86_64/wheel

You cannot change the pip logs

I have followed all the instructions outlined here for executing a function during the installation of a pip package, but I still cannot get the function to execute up using pip install <my_package>.

Running pip install <my_package>, you will see only pip logs, and you cannot change it or call some function during pip install. Just imagine, if we can run any script during pip install, we could steal any information that does not require permissions.

Complete the arguments of the setup function

I have no .whl file in the dist folder.

The setup.py is only missing some arguments for the setup function. Follow the instructions of my answer. Also, I am not sure you're running the build properly, so please use the build command that has been provided in the answer.

Do not confuse downloading the package with post-installing the egg

On downloading the package I am not even getting the reading: print('running post installation') which leads to believe that the function temp is not being executed. What am I doing wrong?

It is printed on post-installation of the .egg. So if you run python3 setup.py sdist bdist_wheel it will start to build the package and the text you print you will see in that logs. For me, it was the follofing.

running sdist
running egg_info
creating my_package.egg-info
writing my_package.egg-info/PKG-INFO
writing dependency_links to my_package.egg-info/dependency_links.txt
writing requirements to my_package.egg-info/requires.txt
writing top-level names to my_package.egg-info/top_level.txt
writing manifest file 'my_package.egg-info/SOURCES.txt'
reading manifest file 'my_package.egg-info/SOURCES.txt'
writing manifest file 'my_package.egg-info/SOURCES.txt'
warning: sdist: standard file not found: should have one of README, README.rst, README.txt, README.md

running check
warning: Check: missing required meta-data: url

creating my_package-0.0.1
creating my_package-0.0.1/my_package
creating my_package-0.0.1/my_package.egg-info
copying files to my_package-0.0.1...
copying setup.py -> my_package-0.0.1
copying my_package/__init__.py -> my_package-0.0.1/my_package
copying my_package/demo.py -> my_package-0.0.1/my_package
copying my_package.egg-info/PKG-INFO -> my_package-0.0.1/my_package.egg-info
copying my_package.egg-info/SOURCES.txt -> my_package-0.0.1/my_package.egg-info
copying my_package.egg-info/dependency_links.txt -> my_package-0.0.1/my_package.egg-info
copying my_package.egg-info/requires.txt -> my_package-0.0.1/my_package.egg-info
copying my_package.egg-info/top_level.txt -> my_package-0.0.1/my_package.egg-info
Writing my_package-0.0.1/setup.cfg
creating dist
Creating tar archive
removing 'my_package-0.0.1' (and everything under it)
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/my_package
copying my_package/demo.py -> build/lib/my_package
copying my_package/__init__.py -> build/lib/my_package
installing to build/bdist.linux-x86_64/wheel
running install
running post installation
/home/artyom/.local/lib/python3.9/site-packages/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'storage.googleapis.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(
failed to download data files
running install_lib
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/wheel
creating build/bdist.linux-x86_64/wheel/my_package
copying build/lib/my_package/demo.py -> build/bdist.linux-x86_64/wheel/my_package
copying build/lib/my_package/__init__.py -> build/bdist.linux-x86_64/wheel/my_package
running install_egg_info
Copying my_package.egg-info to build/bdist.linux-x86_64/wheel/my_package-0.0.1-py3.9.egg-info
running install_scripts
creating build/bdist.linux-x86_64/wheel/my_package-0.0.1.dist-info/WHEEL
creating 'dist/my_package-0.0.1-py3-none-any.whl' and adding 'build/bdist.linux-x86_64/wheel' to it
adding 'my_package/__init__.py'
adding 'my_package/demo.py'
adding 'my_package-0.0.1.dist-info/METADATA'
adding 'my_package-0.0.1.dist-info/WHEEL'
adding 'my_package-0.0.1.dist-info/top_level.txt'
adding 'my_package-0.0.1.dist-info/RECORD'
removing build/bdist.linux-x86_64/wheel
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文