Skip to content
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

distutils and python -B #56328

Closed
pitrou opened this issue May 19, 2011 · 12 comments
Closed

distutils and python -B #56328

pitrou opened this issue May 19, 2011 · 12 comments
Assignees
Labels
stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented May 19, 2011

BPO 12119
Nosy @birkenfeld, @pitrou, @tarekziade, @merwok, @ssbarnea

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/merwok'
closed_at = <Date 2013-03-28.14:37:45.963>
created_at = <Date 2011-05-19.16:20:53.012>
labels = ['tests', 'type-bug', 'library']
title = 'distutils and python -B'
updated_at = <Date 2013-03-28.20:14:39.012>
user = 'https://github.com/pitrou'

bugs.python.org fields:

activity = <Date 2013-03-28.20:14:39.012>
actor = 'eric.araujo'
assignee = 'eric.araujo'
closed = True
closed_date = <Date 2013-03-28.14:37:45.963>
closer = 'eric.araujo'
components = ['Distutils', 'Tests']
creation = <Date 2011-05-19.16:20:53.012>
creator = 'pitrou'
dependencies = []
files = []
hgrepos = []
issue_num = 12119
keywords = []
message_count = 12.0
messages = ['136301', '136321', '136344', '146943', '147488', '148500', '148502', '154202', '185420', '185451', '185468', '185469']
nosy_count = 7.0
nosy_names = ['georg.brandl', 'pitrou', 'tarek', 'eric.araujo', 'Arfrever', 'ssbarnea', 'alexis']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue12119'
versions = ['Python 3.3']

@pitrou
Copy link
Member Author

pitrou commented May 19, 2011

I get the following failure under a fresh checkout:

======================================================================
FAIL: test_package_data (distutils.tests.test_build_py.BuildPyTestCase)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/home/antoine/t/cpython/Lib/distutils/tests/test_build_py.py", line 61, in test_package_data
    self.assertTrue("__init__.pyc" in files)
AssertionError: False is not true

@pitrou pitrou added stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels May 19, 2011
@pitrou
Copy link
Member Author

pitrou commented May 19, 2011

This is due to PYTHONDONTWRITEBYTECODE being set. Not sure this is worth fixing.

@vstinner
Copy link
Member

Duplicate of bpo-12117.

@merwok
Copy link
Member

merwok commented Nov 3, 2011

I have changed packaging in dad02a080bbc to work even under -O or -B.

packaging gives control over the creation of pyc and/or pyo files to the user with its own explicit options (--compile/--no-compile and --optimize 0/1/2), and the behavior should not change if the calling Python happens to run with -B or -O for whatever reason.

Other libraries make different choices: For example, compileall gives no option to generate pyo instead of pyc, you have to call it with python -O. I argue that distutils and packaging are different. Calling “python -B setup.py build” means that you don’t want pyc files to be created for the modules that are imported for this invocation, but it should not mean that distutils needs to behave as if --no-compile was given.

Fixing this is a small change, and in my opinion a bug fix. Of course, I would not remove the DistutilsByteCompileError to preserve compatibility, but I would remove the warnings/exceptions when running under -B. Can I do it?

@merwok merwok reopened this Nov 3, 2011
@merwok merwok assigned merwok and unassigned tarekziade Nov 3, 2011
@merwok
Copy link
Member

merwok commented Nov 12, 2011

A 1999 comment in build_py from Greg Ward agrees with me:

# XXX hey! we can't control whether we optimize or not; that's up
# to the invocation of the current Python interpreter (at least
# according to the py_compile docs).  That sucks.

If Tarek doesn’t object, I will make the change I proposed in my earlier message in distutils.

@merwok merwok changed the title test_distutils failure distutils and python -B Nov 12, 2011
@Arfrever
Copy link
Mannequin

Arfrever mannequin commented Nov 28, 2011

Please don't backport this change to distutils without backporting --no-compile options to "build" command in distutils (issue bpo-13400). Otherwise users would lose possibility of disabling byte-compilation during running this command.

distutils tests could use locally modified environment with PYTHONDONTWRITEBYTECODE variable removed.

@merwok
Copy link
Member

merwok commented Nov 28, 2011

Please don't backport this change to distutils without backporting --no-compile options to
"build" command in distutils (issue bpo-13400).
The feature freeze on distutils rules this out.

Otherwise users would lose possibility of disabling byte-compilation during running this command.
python setup.py build build_py --no-compile --optimize=0

@merwok
Copy link
Member

merwok commented Feb 25, 2012

I thought about this and am not sure about my position.

I am 100% convinced that what packaging does is the right thing. Modules like py_compile, compileall (in 3.2+) and packaging are able to compile with or without optimization depending on options that are given to them, independently from the optimization level of the calling Python.

distutils however depends on the calling Python’s -B and -O options, and I just don’t think there is much value in fixing this bug and causing obscure bugs for people who’ve been using -B to control distutils for the past months.

Antoine, you’re a pragmatist and a fixer of bugs. Arfrever, you’re using this misfeature. I’d like to know your opinion.

@birkenfeld
Copy link
Member

Can this be closed?

@merwok
Copy link
Member

merwok commented Mar 28, 2013

In the absence of support for doing the right thing (which would break compatibility), I won’t change distutils here.

@merwok merwok closed this as completed Mar 28, 2013
@ssbarnea
Copy link
Mannequin

ssbarnea mannequin commented Mar 28, 2013

Can we have a fix for this? ... one that would not require me to drop using PYTHONDONTWRITEBYTECODE.

I do have PYTHONDONTWRITEBYTECODE=1 on my user profile and installing packages became a nightmare.

@merwok
Copy link
Member

merwok commented Mar 28, 2013

See bpo-12117.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants