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

(🐞) install --compile installs with optimization level 1, which is confusing and undocumented #7639

Closed
KotlinIsland opened this issue Mar 13, 2023 · 4 comments · Fixed by #7666
Labels
area/installer Related to the dependency installer kind/bug Something isn't working as expected

Comments

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Mar 13, 2023

  • Poetry version: 1.4.0
  • Python version: 3.11.2
  • OS version and name: Windows/LiGNUx
  • pyproject.toml:
[tool.poetry]
name = "poetry-test"
version = "0.1.0"
description = ""
authors = [""]

[tool.poetry.dependencies]
python = "^3.11"
pendulum = "*"
  • [🚀] I am on the latest stable Poetry version, installed using a recommended method.
  • [🚀] I have searched the issues of this repo and believe that this is not a duplicate.
  • [🚀] I have consulted the FAQ and blog for any relevant entries or release notes.
  • [🚀] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

👉 poetry install --compile
Installing dependencies from lock file

Package operations: 1 install, 0 updates, 0 removals

  • Installing pendulum (2.1.2)
👉 Get-ChildItem $VIRTUAL_ENV\Lib\site-packages\pendulum\__pycache__ | Select-Object Name

Name                             
----
__init__.cpython-312.opt-1.pyc
__version__.cpython-312.opt-1.pyc
constants.cpython-312.opt-1.pyc
date.cpython-312.opt-1.pyc
datetime.cpython-312.opt-1.pyc
duration.cpython-312.opt-1.pyc
exceptions.cpython-312.opt-1.pyc
helpers.cpython-312.opt-1.pyc
parser.cpython-312.opt-1.pyc
period.cpython-312.opt-1.pyc
time.cpython-312.opt-1.pyc

Additionally

I have no idea why these are labeled with cpython-312, my venv is python3.11

`👉 poetry env info`
👉 poetry env info

Virtualenv
Python:         3.11.2
Implementation: CPython
Path:           C:\Users\amongus\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-RGMhFuFN-py3.11
Executable:     C:\Users\amongus\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-RGMhFuFN-py3.11\Scripts\python.exe
Valid:          True

System
Platform:   win32
OS:         nt
Python:     3.11.2
Path:       C:\Users\amongus\AppData\Local\Programs\Python\Python311
Executable: C:\Users\amongus\AppData\Local\Programs\Python\Python311\python.exe  

Could this be a bug(🐞)?

Okay, so basically

  • (🐞) This is different to poetry 1.3.x, which installed compiled at normal level, not opt-1.
  • (👩‍💻) There is no way to pick a different level, apart from disabling the new installer entirely.
  • (📚) This behavior is not documented.

My use case

I need my deps to be compiled, but I don't want opt-1 because I like to keep the asserts. Additionally, I would need to setup my entire project to use python -O x, as otherwise it will just compile on the spot anyway.

Workaround

Use python -m compileall.

@KotlinIsland KotlinIsland added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Mar 13, 2023
@dimbleby
Copy link
Contributor

dimbleby commented Mar 13, 2023

I have no idea why these are labeled with cpython-312, my venv is python3.11

presumably bytecode is generated for the python interpreter associated with poetry, and not for the interpreter in the target virtual environment

@radoering
Copy link
Member

Optimization level 1 was not intended. Thus, probably two bugs here: compiling for the wrong python version and wrong optimization level...

@radoering radoering added area/installer Related to the dependency installer and removed status/triage This issue needs to be triaged labels Mar 13, 2023
@radoering
Copy link
Member

I created #7666 to fix the optimization level and thus this issue (as per the title). The wrong interpreter is a bit more complicated and tracked in pypa/installer#172.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/installer Related to the dependency installer kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants