软件包版本更改时获取Tox重新安装console_scripts

时间:2019-12-11 00:50:25

标签: python setuptools tox

我正在使用tox测试一个模块,该模块具有在基于setuptools的{​​{1}}脚本中定义的脚本入口点。

setup.py

entry_points={ 'console_scripts': [ 'myscript = mypackage:main', ], } 的配置如下:

tox

如预期的那样,文件[testenv] commands = pytest --cov=mypackage --cov-report=html --cov-append tests/ deps = pytest pytest-cov usedevelop = True 指向我的开发目录,该目录显然具有新的版本号。安装在.tox/py38/lib/python3.8/site-packages/mypackage.egg-link上的脚本包括以下对旧版本号的引用,并且.tox/py38/bin/myscript.py并未对其进行更新,因此当我在更新版本后重新运行tox时,最终得到tox错误。

VersionConflict

==================================== ERRORS ==================================== _____________________ ERROR collecting tests/test_args.py ______________________ tests/test_args.py:6: in <module> import mypackage .tox/py38/bin/mypackage.py:4: in <module> __import__('pkg_resources').require('mypackage==1.0.0b1') .tox/py38/lib/python3.8/site-packages/pkg_resources/__init__.py:900: in require needed = self.resolve(parse_requirements(requirements)) .tox/py38/lib/python3.8/site-packages/pkg_resources/__init__.py:791: in resolve raise VersionConflict(dist, req).with_context(dependent_req) E pkg_resources.VersionConflict: (mypackage 1.0.0b2 (/Users/matt/devel/mypackage), Requirement.parse('mypackage==1.0.0b1')) 正在其tox目录中安装以下两个脚本,这些脚本似乎没有更新,并且正在触发上述错误:

bin

是否有一种方法可以说服% cat mypackage.py #!/Users/matt/devel/mypackage/.tox/py38/bin/python # EASY-INSTALL-DEV-SCRIPT: 'mypackage==1.0.0b1','mypackage.py' __requires__ = 'mypackage==1.0.0b1' __import__('pkg_resources').require('mypackage==1.0.0b1') __file__ = '/Users/matt/devel/mypackage/mypackage.py' with open(__file__) as f: exec(compile(f.read(), __file__, 'exec')) % cat myscript #!/Users/matt/devel/mypackage/.tox/py38/bin/python # EASY-INSTALL-ENTRY-SCRIPT: 'mypackage','console_scripts','myscript' __requires__ = 'mypackage' import re import sys from pkg_resources import load_entry_point if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit( load_entry_point('mypackage', 'console_scripts', 'myscript')() ) 在其环境中对控制台脚本进行适当的升级,而不必每次更改版本号时都手动清除所有tox子目录?

0 个答案:

没有答案