我使用pipenv为a small project。代码看起来可能有用,我想通过pypi分发。我无法在pipenv网页或其github回购中找到有关如何完成此操作的指导。什么是DRY打包pipenv项目的方式?
我可以把依赖从我Pipfile.lock
成setup.py
的install_requires
section,但我不能找到一个工具来自动做到这一点,和干手做不会。
有没有人有更好的建议?
我使用pipenv为a small project。代码看起来可能有用,我想通过pypi分发。我无法在pipenv网页或其github回购中找到有关如何完成此操作的指导。什么是DRY打包pipenv项目的方式?
我可以把依赖从我Pipfile.lock
成setup.py
的install_requires
section,但我不能找到一个工具来自动做到这一点,和干手做不会。
有没有人有更好的建议?
这似乎这样的伎俩对我来说:可以动态生成
import os
from setuptools import setup, find_packages
import json
def get_requirements_from_pipfile_lock(pipfile_lock=None):
if pipfile_lock is None:
pipfile_lock = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Pipfile.lock')
lock_data = json.load(open(pipfile_lock))
return [package_name for package_name in lock_data.get('default', {}).keys()]
packages = find_packages('.', exclude=['*.test', '*.test.*'])
pipfile_lock_requirements = get_requirements_from_pipfile_lock()
setup(
name='my_package',
version='0.0.1',
packages=packages,
license='MIT',
long_description=open('README.md').read(),
install_requires=pipfile_lock_requirements,
python_requires=">=3.5",
)
只是一个小小的评论,[根据Creative Commons Org本身](https://creativecommons.org/faq/#can -i-apply-a-creative-commons-license-to-software),你不应该在软件上使用任何CC许可证。 – dangom
大声笑,我完全同意。我想我一定是从某处复制过的。 – winni2k
看起来像从Hitchhiker的指南中得到它包装:https://the-hitchhikers-guide-to-packaging.readthedocs.io/en/latest/quickstart.html – winni2k
'install_requrements'和文件是JSON。你只需要编写一个函数来从中产生正确的列表。 –
干杯。我会继续努力,并在此处发布我的解决方案¯\ _(ツ)_ /¯ – winni2k