How to include and install local dependencies in setup.py in Python?

一世执手 提交于 2019-12-01 04:10:02

There are several options that you can choose from:

  1. Upload your package to some server, and provide the URL with dependency_links.
  2. You could put your python package inside of your my_app package and link it with packages parameter, instead of using the wheel file.
  3. A more hacky way would be to use the setuptools api, and install the package by yourself.

it is possible but not sure what setuptools version you should use. steps:

in setup.py

setup(
  ...,
  install_requires=['my-package'],
  dependency_links=[
    # location to your egg file
    os.path.join(os.getcwd(), 'deps', 'my_package-1.0.0-py3.5.egg')
  ]
)

important thing is that your location should not pass URL pattern test and egg file name should have structure <package_name_with_no_hyphens>-<version>-<py_version>.egg

Extending wiesiu_p's answer, you can install the dependency by linking to its source directory, which has its own setup.py:

setup(
  ...,
  install_requires=['my-package'],
  dependency_links=[
    # location to your my-package project directory
    ''.join(['file:\\', os.path.join(os.getcwd(), 'path', 'to', 'my-package_project_folder#egg=my-package-1.0')])
  ]
)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!