我正在开发一个项目,最近不得不更新setup.py以添加extras_require字段。
项目的setup.py的上一版本是1.1.3不完整的。我把它提升到1.1.4不完整。
当我尝试在virtualenv中使用pip install -e
更新包时,我会遇到奇怪的行为。就像pip以某种方式缓存我的setup.py文件的旧副本,但仅限于编辑模式。
这是我的setup.py文件的相关位:
setup(
name='phpIPAM-Scraper',
version='1.1.4-incomplete',
...
install_requires=[
'configparser ; python_version < "3.2"',
'requests',
'beautifulsoup4',
'tabulate',
'click',
'click-shell'],
extras_require={
'test': [
'pytest',
'pytest-docker',
'pytest-docker-pexpect',
]
},
...
)
旧的setup.py是相同的,除了它没有extras_require
内容。
当我从我的项目目录运行pip install -e .[test]
时,我得到了这个奇怪的输出:
$ pip install -e .[test]
Obtaining file:[project-dir]
phpipam-scraper 1.1.3-incomplete does not provide the extra 'test'
Requirement already satisfied: requests ...
Requirement already satisfied: beautifulsoup4 ...
Requirement already satisfied: tabulate ...
Requirement already satisfied: click ...
Requirement already satisfied: click-shell ...
Requirement already satisfied: certifi>=2017.4.17 ...
Requirement already satisfied: chardet<3.1.0,>=3.0.2 ...
Requirement already satisfied: urllib3<1.22,>=1.21.1 ...
Requirement already satisfied: idna<2.6,>=2.5 ...
Installing collected packages: phpIPAM-Scraper
Found existing installation: phpipam-scraper 1.1.3-incomplete
Not uninstalling phpipam-scraper at [project-dir], outside environment [virtualenv]
Running setup.py develop for phpIPAM-Scraper
Successfully installed phpIPAM-Scraper
但是,当我在没有-e标志的情况下运行相同的命令时,它安装得很好:
$ pip install .[test]
Processing [project-dir]
Requirement already satisfied: requests ...
Requirement already satisfied: beautifulsoup4 ...
Requirement already satisfied: tabulate ...
Requirement already satisfied: click ...
Requirement already satisfied: click-shell ...
Requirement already satisfied: pytest ...
Requirement already satisfied: pytest-docker ...
Requirement already satisfied: pytest-docker-pexpect ...
Requirement already satisfied: chardet<3.1.0,>=3.0.2 ...
Requirement already satisfied: idna<2.6,>=2.5 ...
Requirement already satisfied: certifi>=2017.4.17 ...
Requirement already satisfied: urllib3<1.22,>=1.21.1 ...
Requirement already satisfied: setuptools ...
Requirement already satisfied: py>=1.4.33 ...
Requirement already satisfied: attrs<17,>=16 ...
Requirement already satisfied: pexpect ...
Requirement already satisfied: six ...
Requirement already satisfied: ptyprocess>=0.5 ...
Building wheels for collected packages: phpIPAM-Scraper
Running setup.py bdist_wheel for phpIPAM-Scraper ... done
Stored in directory: [local .cache]
Successfully built phpIPAM-Scraper
Installing collected packages: phpIPAM-Scraper
Found existing installation: phpipam-scraper 1.1.3-incomplete
Not uninstalling phpipam-scraper at [project-dir], outside environment [virtualenv-dir]
Successfully installed phpIPAM-Scraper-1.1.4-incomplete
这没有任何意义。这就像pip的编辑模式在某个地方使用缓存文件,但我无法弄清楚在哪里或如何,并且我的googlefu未能找到任何有用的信息。
你们之前有没有遇到过这么好的人?
编辑:我删除并重新创建了virtualenv,结果相同。我还将版本设置为1.1.4,行为没有变化