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

log which python version to use/was used #827

Closed
graingert opened this issue May 28, 2019 · 7 comments · Fixed by #828
Closed

log which python version to use/was used #827

graingert opened this issue May 28, 2019 · 7 comments · Fixed by #828
Labels
feature Request for a new feature needs discussion Need some more discussion

Comments

@graingert
Copy link
Member

eg add this to the header:

 # This file is autogenerated by pip-compile on:
 # Python 2.7.15+ (default, Oct  2 2018, 22:12:08) 
 # [GCC 8.2.0] on linux2
 # To update, run:
 #
 #    pip-compile --generate-hashes --output-file=requirements.txt requirements.in
@atugushev atugushev added the feature Request for a new feature label Jun 6, 2019
@atugushev atugushev added the needs discussion Need some more discussion label Sep 19, 2019
@riordan
Copy link

riordan commented Nov 14, 2019

Would be great to also log the pip version used. Some packages have minimum pip versions (as I'm finding out now), so if you run your pip-compile in an environment with a different pip version from the one you're installing into (e.g. fresh and new and 19.x on your local laptop, but stuck at 9.x on ubuntu in the docker container), it's possible to get installation incompatibility errors.

This'll help users identify that could be an environment difference causing issues.

@graingert
Copy link
Member Author

graingert commented Nov 14, 2019

@riordan the pip version is already logged if packages eronously depend on pip

Also you can use pip install --no-deps --require-hashes -r requirements.txt to avoid pip dependency resolution getting in the way

@atugushev
Copy link
Member

@riordan

Some packages have minimum pip versions (as I'm finding out now), so if you run your pip-compile in an environment with a different pip version from the one you're installing into (e.g. fresh and new and 19.x on your local laptop, but stuck at 9.x on ubuntu in the docker container), it's possible to get installation incompatibility errors.

Hello @riordan! You could use --allow-unsafe option, which allows you to pin pip in requirements.txt (by default it's commented-out as an unsafe package).

@atugushev
Copy link
Member

@graingert

Also you can use pip install --no-deps --require-hashes -r requirements.txt to avoid pip dependency resolution getting in the way

Yeah, that should also work. Shouldn't we have --no-deps and --require-hashes in pip-sync as well?

@graingert
Copy link
Member Author

graingert commented Nov 15, 2019 via email

@atugushev
Copy link
Member

atugushev commented Nov 15, 2019

--require-hashes is only useful when passed as a cli directly to the pip invocation

pip-sync invokes pip install /tmp/file/with/requirements.txt under the hood.

@AndydeCleyre
Copy link
Contributor

FWIW, zsh wrapper to accomplish this:

pip-compile-withpyver () {
    CUSTOM_COMPILE_COMMAND=$(
        print -l \
            "pip-compile ${(j: :)@}" \
            '#' \
            "# Last compiled with: ${(j: :)${(f)$(python -V)}}"
    ) pip-compile $@
}
$ pip-compile-withpyver --generate-hashes requirements.in
#
# This file is autogenerated by pip-compile
# To update, run:
#
#    pip-compile --generate-hashes requirements.in
#
# Last compiled with: Python 3.6.9 (1608da62bfc71e8ac775121dd0b21bb72e61c6ea, Dec 25 2019, 02:47:23) [PyPy 7.3.0 with GCC 9.2.0]
#
...

ssbarnea pushed a commit to graingert/pip-tools that referenced this issue Jun 9, 2021
ssbarnea pushed a commit that referenced this issue Jun 9, 2021
ssbarnea added a commit that referenced this issue Jun 9, 2021
* log which python version to use/was used Fixes #827

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update writer.py

* Update writer.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix tests

Co-authored-by: Sorin Sbarnea <sorin.sbarnea@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Request for a new feature needs discussion Need some more discussion
Projects
None yet
4 participants