8000 Fix broken tag prefix on Windows and add CI by mathijsvdv · Pull Request #283 · python-versioneer/python-versioneer · GitHub
[go: up one dir, main page]

Skip to content

Fix broken tag prefix on Windows and add CI #283

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

Merged
merged 20 commits into from
Feb 19, 2022

Conversation

mathijsvdv
Copy link
Contributor

This pull request fixes #273 by simply removing the --match argument when tag_prefix = ''. No platform-dependent escaping of the asterisk needed.

As a first verification I tracked what git describe --tags --match <Match string> produces for each platform (Windows/Linux) and shell (cmd/powershell/bash), given different arguments for --match. In the table below we have a repository with two tags: aaa-999 and demo-1.0.

Match string Ubuntu Result Windows Bash Result Windows Cmd Result Windows Powershell Result
<Leave out --match> aaa-999 aaa-999 aaa-999 aaa-999
* fatal fatal aaa-999 aaa-999
* aaa-999 aaa-999 fatal fatal
demo-* demo-1.0 demo-1.0 demo-1.0 demo-1.0
\demo-* demo-1.0 demo-1.0 demo-1.0 demo-1.0
demo-* demo-1.0 demo-1.0 fatal fatal

The above suggests that we can indeed cover all cases by:

  • Leaving out --match when tag_prefix = ''
  • Using --match {tag_prefix}* otherwise

Next, I added the test_no_tag_prefix unittest to cover the case where tag_prefix is empty.

This covers the fix, but most of my efforts have actually been to get the Windows tests working to be sure that the implementation is correct. I started from #263 and added the following changes:

  • Use os.path.join wherever possible rather than hardcoding forward-slash paths 570fcc8
  • For some test projects, the rundemo file is a Python file that is made runnable in Linux through a shebang line. This doesn't work in Windows, so I opted to make a python rundemo call in these cases instead.
  • pip install -U pip doesn't seem to work in Windows because of access issues. You need to use python -m pip install -U pip instead, so I changed this in the run_in_venv function.
  • An environment made by virtualenv<20 is not recognized by Windows in python>=3.7 because it misses a pyvenv.cfg file. Therefore I switched to virtualenv>=20 and made the necessary changes to the testing code.

A couple of attention points, open to suggestions here:

  • As highlighted in test_dist and test_dist_subproject failing #282, distutils are deprecated and the test_sdist and test_sdist_subproject were already failing in master, so I took the liberty of removing these two unittests.
  • The CI for Windows adds a lot of runtime: each job (6 python versions are tested each for Windows and Linux) took about 20 min on Windows, versus 4-5 min on Linux. Part of the reason is that I run the test_git script from bash, CMD and powershell when on Windows to cover the bases in the table above. Perhaps it's worth reducing the number of Python versions checked for Windows or to remove one of those extra scripts (CMD and Powershell seem to behave identically here).

effigies and others added 17 commits August 25, 2021 13:43
For `pip` the problem in Windows was that `pip install` didn't have the correct permissions to the pip uninstall file. Using `python -m pip install` alleviates this access issue.

For `rundemo`: for some of the demo projects, this is simply a python file. In Linux you could make it runnable on its own through a shebang line (`#!/usr/bin/env python`) but this doesn't work on windows CMD or Powershell. In these cases we run `python rundemo` explicitly instead, controllable through the `use_python` argument.
From Python=3.7 onwards, Windows has trouble recognizing virtual environments made by virtualenv<20 because they don't contain a pyvenv.cfg file. It may be related to the issue mentioned here: https://bugs.python.org/issue35872

The pyvenv.cfg files _are_ generated by virtualenv>=20, which resolves the problem.
@effigies
Copy link
Contributor

Thank you! I will try to review this ASAP, but please feel free to bug me in a day or two if I haven't gotten to it.

Copy link
Contributor
@effigies effigies left a comment

Choose a reason for hiding this comment

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

Looks great! Minor comments.

Copy link
Contributor
@effigies effigies left a comment

Choose a reason for hiding this comment

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

Addressing your question about the explosion in jobs/runtime, this proposes only testing Windows on one Python version, but three shells.

I'm not sure how well tox will work with these other shells, so this might not be the greatest idea. But it feels a bit cleaner than tacking on extra tests for Windows.

@effigies
Copy link
Contributor

@mathijsvdv All my suggestions were implemented and debugged in https://github.com/python-versioneer/python-versioneer/tree/maint/windows. If you're good with that, please merge it into your branch.

@mathijsvdv
Copy link
Contributor Author

@effigies Sounds good to me! I had a quick look at your adjustments and they generally make sense to me. I'll see how the tests are working now and let you know my feedback in the next few days.

@mathijsvdv
Copy link
Contributor Author

Addressing your question about the explosion in jobs/runtime, this proposes only testing Windows on one Python version, but three shells.

I'm not sure how well tox will work with these other shells, so this might not be the greatest idea. But it feels a bit cleaner than tacking on extra tests for Windows.

I agree. One reason I didn't run the whole tox suite was that I was running into some errors when running the whole thing on other shells (and test_git.py contained the tests for the tag prefix). But with your version it seems to be working fine.

Testing fewer Python versions seems a fine compromise to me. One comment I'd make: there was a notable change starting from Python 3.7 that caused the virtual environments to no longer work on Windows until I updated virtualenv to v20 and above. It may be worth testing both Python 3.6 (before) and Python 3.10 (after) for that reason.

@effigies
Copy link
Contributor

Python 3.6 is end of life. I'd suggest we drop that altogether, but we could do 3.7 to test the range.

@mathijsvdv
Copy link
Contributor Author

Python 3.6 is end of life. I'd suggest we drop that altogether, but we could do 3.7 to test the range.

Fair enough. Since the issue with virtualenvs started with Python 3.7 I think we're pretty covered with Python 3.10 + all the linux tests then, but it can't hurt to cover our bases. I'll leave it to you.

For the rest I have no comments. From my side, we're ready to merge :)

@effigies
Copy link
Contributor

Let's do it, and we can tweak later if needed. Thanks a ton for pushing this forward!

@hwjohn
Copy link
hwjohn commented Feb 21, 2022

Great work! Thanks for the fix guys. Some quick tests seem to confirm that this fixes the issue for me on Windows 10 and Python 3.7.

@mathijsvdv
Copy link
Contributor Author

No problem, happy to help!

@jmartens
Copy link

Any chance this will released soon? Current release is broken for some cases when running windows.

@effigies
Copy link
Contributor

Yes. I would like to get in #280 before releasing, if anybody has the urge to do a review...

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.

Tag prefix broken on Windows with versioneer 0.21
4 participants
0