Skip to content

How do I run a custom distutils Command without a setup.py? #4223

Answered by thrau
thrau asked this question in Q&A
Discussion options

You must be logged in to vote

Based on the hints you provided, I came up with something (conceptually) like this to replace the python setup.py plugins egg_info command:

import os
from setuptools.dist import Distribution

workdir = os.getcwd()

# prepare Distribution from workdir
config_files = ["pyproject.toml", "setup.cfg"]
config_files = [file for file in config_files if os.path.exists(file)]

if not config_files:
    raise ValueError(f"no distribution config files found in {workdir}")

dist = Distribution()
dist.parse_config_files(config_files)
if os.path.exists("setup.py"):
    # use setup.py script if available
    dist.script_name = os.path.join(workdir, "setup.py")
else:
    # else use a bogus file (seems to w…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@abravalheri
Comment options

@thrau
Comment options

thrau Feb 16, 2024
Author Sponsor

@abravalheri
Comment options

@thrau
Comment options

thrau Feb 17, 2024
Author Sponsor

Answer selected by thrau
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