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

Hg / pip compatibility #729

Merged
merged 3 commits into from
Jun 25, 2022
Merged

Hg / pip compatibility #729

merged 3 commits into from
Jun 25, 2022

Conversation

paugier
Copy link
Contributor

@paugier paugier commented Jun 24, 2022

I open this PR to discuss about these changes that would avoid the problem describe in pypa/pip#10635.

This is a now a draft implementation of solution 2 described in pypa/pip#10635 (comment).

I see that there are already a function to clean up the environment of Git specific environment variables. A possibility would be to merge my new function avoid_pip_isolation and no_git_env to one unique function cleaning the environment to call the programs.

I wonder if it would be necessary to have a mechanism to deactivate this cleaning?

@@ -2,5 +2,6 @@
requires = [
"setuptools>=45",
"packaging>=20.0",
"typing_extensions",
Copy link
Contributor Author

@paugier paugier Jun 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add this to avoid a bug in the installation of setuptools_scm (Python 3.9).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this python 3.9 only or python 3.9+?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried only with 3.9 and I had an import error without this line. However, I don't understand well how we are supposed to use typing_extensions, since "The typing_extensions module serves two related purposes". I don't know if it is also useful for python > 3.9. It seems that it depends on what exactly is used in the code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paugier ah, its my fault - i missed to make the _t import in hg/hg_git support optional, if you like you can replicate what i did for git,

@paugier
Copy link
Contributor Author

paugier commented Jun 24, 2022

The first commit is actually only about improving debug logging.

@paugier paugier force-pushed the hg-pip-compat branch 2 times, most recently from 1269bcc to bfcd8e1 Compare June 24, 2022 19:11
Copy link
Contributor

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like what I see there

A good opt out for the env cleanup is unclear to me as well

I think it's a good idea to keep pip and git cleanup in separate functions

src/setuptools_scm/utils.py Show resolved Hide resolved
trace("cmd", repr(cmd))
trace(" in", cwd)
if isinstance(cmd, list):
cmd_4_trace = " ".join(cmd)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to use shlex quoting to avoid commands one can't safely run copy pasted

if os.name == "posix" and not isinstance(cmd, (list, tuple)):
cmd = shlex.split(cmd)

res = _run(cmd, cwd)
if res.stdout:
trace("out", repr(res.stdout))
trace("out:\n", res.stdout)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally those add a indent level

Copy link
Contributor

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me thanks

anything you want to add, or should i aim for a swift release?

@RonnyPfannschmidt RonnyPfannschmidt merged commit 1c00405 into pypa:main Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants