Skip to content

finalize_distribution_options entrypoint doesn't let me change install_requires #3982

Answered by 3N4N
3N4N asked this question in Q&A
Discussion options

You must be logged in to vote

Upon further research I found that I can bind a function to an object:

def finalize_dist(dist):
    # We can set install_requires of dist here, but it's replaced with
    # dependencies from pyproject.toml by setuptools.  Unless we bind this
    # attribute 'set_install_requires' to a function.  And the function needs
    # to be bound to dist object, otherwise it can't update the dist object.
    setattr(dist.metadata,'set_install_requires', MethodType(install_requires_setter, dist))

So, _dependencies() from setuptools will now call install_requires_setter with the dependencies listed in pyproject.toml, and install_requires_setter can add some other packages to that list.

Edit: For comp…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@3N4N
Comment options

@3N4N
Comment options

Answer selected by 3N4N
@abravalheri
Comment options

@3N4N
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants