1

Is it possible to indicate that a specific file will become setup.py during the building process (e.g., python setup.py sdist) when using distutils (or distribute, or else) ?

I would like to be able to do python setup-specificbuild.py sdist and have something (either in setup-specificbuild.py or as a command line argument) that would rename setup-specificbuild.py to setup.py in the package tarball build in dist/.

2 Answers 2

1

There is an answer on SO about a similar problem (create different distribution types). Custom command line parsing seems to be a decent workaround, and then eventual distribution-specific logic can be pushed to separate modules, only imported if found, and only included when needed.

0

setup.py is ultimately just an entry point to a Python program, so if you want to implement branching build behaviors, just have your standard setup.py parse command line arguments and dispatch the actual build process to whatever modules you want. That's much preferable to trying to dynamically re-name files with some pre-build script step.

14
  • The unwanted side effect with this is approach that the final setup.py will contain all branching rules, which are all irrelevant when shipping one source build.
    – lgautier
    Commented May 24, 2013 at 13:26
  • 1
    @Igautier: No, that's backwards. A source build should contain all branching rules. Commented May 24, 2013 at 13:29
  • And even if for some reason you want to be that controlling and pedantic about it, you can implement the switching logic in another module, have setup.py delegate to that module, then have that module delegate to each platform specific build module. You can then have the platform builders build distributions excluding all files other than themselves, and have setup.py wildcard import the setup submodules, and when no platform is specified, just run the first one it finds. In your platform specific builds, you'll only have the single platform setup module, so you'll be good to go.
    – Silas Ray
    Commented May 24, 2013 at 13:36
  • @LennartRegebro: Not quite. A source build is only different from a binary build in the sense that it will be compiled when installed, at the difference of a source tree that will contain everything needed to make any build.
    – lgautier
    Commented May 24, 2013 at 14:17
  • 1
    setup.py is the package generation system. Having a package generation system to generate a package generation system seems a bit silly. :-) Commented May 24, 2013 at 14:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.