Skip to content

Recommended way to add custom build steps #3762

Answered by abravalheri
jarkenau asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @jarkenau,

I can successfully run the following:

rm -rf /tmp/myproj
mkdir /tmp/myproj
cd /tmp/myproj
cat <<EOF > setup.py
from contextlib import suppress
from pathlib import Path
from setuptools import Command, setup
from setuptools.command.build import build

class CustomCommand(Command):
    def initialize_options(self) -> None:
        self.bdist_dir = None

    def finalize_options(self) -> None:
        with suppress(Exception):
            self.bdist_dir = Path(self.get_finalized_command("bdist_wheel").bdist_dir)

    def run(self) -> None:
        if self.bdist_dir:
            self.bdist_dir.mkdir(parents=True, exist_ok=True)
            (self.bdist_dir / "file.txt").write_text…

Replies: 2 comments 14 replies

Comment options

You must be logged in to vote
10 replies
@webknjaz
Comment options

@jarkenau
Comment options

@webknjaz
Comment options

@jarkenau
Comment options

@webknjaz
Comment options

Comment options

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

@jarkenau
Comment options

@abravalheri
Comment options

@jarkenau
Comment options

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