Skip to content

bpo-35718: Cannot initialize the "force" Command-option in initialize_options() #11526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from

Conversation

ophers
Copy link

@ophers ophers commented Jan 11, 2019

See Issue 35718.
In this build_py subclass I initialize force to 1, but when reaching byte_compile() we find out it was reset to None.

from setuptools.command.build_py import build_py as _build_py

class build_py(_build_py):
    def initialize_options(self):
        _build_py.initialize_options(self)
        self.force = 1
        self.compile = 1

    def byte_compile(self, files):
        # self.compile == 1
        # self.force == None
        _build_py.byte_compile(self, files)
        # do stuff...

https://bugs.python.org/issue35718

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Our records indicate we have not received your CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

@ophers
Copy link
Author

ophers commented Jan 12, 2019

This oddity is due to finalize_options() in class install_scripts calling set_undefined_options() on (among others) force option.
The original implementation of this class was wrong: The original coder intended on "inheriting" the force value from install command. But that requires initializing it to None, while instead it is wrongly initialized to 0.
Locking around the codebase these classes are similarly flawed:

  1. install_headers
  2. build_clib
  3. install_data
  4. install_lib
    Interestingly those classes also setup other options to "inherit" but correctly initialize them to None. They only got it wrong for force. Hum?

@merwok
Copy link
Member

merwok commented Jun 12, 2019

Maybe the dev wanted to avoid a ternary state (none / 0 to mean false / 1 to mean true) for boolean options, and did not realize that not setting to none would not be compatible with set_undefined_options

@iritkatriel
Copy link
Member

Closing the PR following the closure of its b.p.o issue (https://bugs.python.org/issue35718)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants