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

Fix setting PYTHONPATH on Python 2 not working #1673

Merged
merged 6 commits into from Mar 3, 2020

Conversation

jd
Copy link
Contributor

@jd jd commented Feb 26, 2020

  • ensure we do not rewrite the PYTHONPATH
  • ensure we respect the -E flag.

@jd jd force-pushed the skip-pythonpath branch 2 times, most recently from 5781f4f to 997d515 Compare Feb 26, 2020
@jd jd force-pushed the skip-pythonpath branch 2 times, most recently from 08db125 to 56fc536 Compare Feb 27, 2020
@jd
Copy link
Contributor Author

jd commented Feb 27, 2020

Is there anything left that needs fixing?

Copy link
Contributor

@gaborbernat gaborbernat left a comment

Still needs tests and changelog entry 👍

@jd
Copy link
Contributor Author

jd commented Feb 28, 2020

Could you give me some hints about where to add some tests?
I took a look at #1641 but it's unclear to me how you added/changed the tests.

@gaborbernat
Copy link
Contributor

gaborbernat commented Feb 29, 2020

In that pr the test were adding brew Python to the ci matrix. Here you want a test inside test_create 👍set Python path, run create, check sys path of the debug property 👍

@jd
Copy link
Contributor Author

jd commented Mar 2, 2020

I'm blocked by #1683 to try locally to add tests :(

@jd jd force-pushed the skip-pythonpath branch 5 times, most recently from ab7c12a to 9268426 Compare Mar 2, 2020
@jd
Copy link
Contributor Author

jd commented Mar 2, 2020

Any idea how you set UTF-8 strings in a Windows env? 🤔

@pfmoore
Copy link
Member

pfmoore commented Mar 2, 2020

Environment variables are Unicode in Windows, so I'm not quite sure the question makes sense. Having said that, if this is Python 2, os.environ probably uses the ANSI APIs to read the environment, so the practical answer would likely be "you can't - you always get the default encoding".

@jd
Copy link
Contributor Author

jd commented Mar 2, 2020

My question is related to the CI failure. IIUC the dir contains Unicode chars and setting that as PYTHONPATH is a problem… :(

@pfmoore
Copy link
Member

pfmoore commented Mar 2, 2020

Ah, OK. So passing a general Unicode value through to the subprocess' environment. I don't think you can, in Python 2 (IIRC, you can only use characters that are valid in the system ANSI codepage) 🙁 (I may be wrong, it's a long while since I used Python 2).

Sorry I can't be more help.

tests/conftest.py Outdated Show resolved Hide resolved
@gaborbernat gaborbernat force-pushed the skip-pythonpath branch 2 times, most recently from 1f48d16 to 90bf357 Compare Mar 3, 2020
Copy link
Contributor

@gaborbernat gaborbernat left a comment

@jd needed to do quite a few changes here, but I think now things should be OK. Can you validate with your system?

tests/unit/create/test_creator.py Show resolved Hide resolved
tests/unit/create/test_creator.py Show resolved Hide resolved
tests/unit/create/test_creator.py Show resolved Hide resolved
@gaborbernat gaborbernat changed the title Fix PYTHONPATH rewrite on Python 2 Fix setting PYTHONPATH on Python 2 not working Mar 3, 2020
@gaborbernat
Copy link
Contributor

gaborbernat commented Mar 3, 2020

@jd it's just how pythonpath is parsed at the interpreter level.

jd added 2 commits Mar 3, 2020
str.startswith() is a little bit too naive to check if a directories are
related.
jd and others added 4 commits Mar 3, 2020
Signed-off-by: Bernat Gabor <bgabor8@bloomberg.net>
Signed-off-by: Bernat Gabor <bgabor8@bloomberg.net>
@gaborbernat gaborbernat merged commit c310a95 into pypa:master Mar 3, 2020
37 checks passed
@gaborbernat
Copy link
Contributor

gaborbernat commented Mar 4, 2020

Hello, a fix for this issue has been released via virtualenv 20.0.8; see https://pypi.org/project/virtualenv/20.0.8/ (https://virtualenv.pypa.io/en/latest/changelog.html#v20-0-8-2020-03-04). Please give a try and report back if your issue has not been addressed; if not, please comment here, and we'll reopen the ticket. We want to apologize for the inconvenience this has caused you and say thanks for having patience while we resolve the unexpected bugs with this new major release.
thanks

bogdando pushed a commit to bogdando/base-jobs that referenced this issue May 25, 2020
In addition to the bug for which [0] is a workaround, there is another
issue with virtualenv [1,2], so we need to temporarily pin its version,
too.

[0] Ia8bbcbc734bc7fe3d7e553e51d67a4ed0ae1404e
[1] pypa/virtualenv#1670
[2] pypa/virtualenv#1673

Change-Id: I0a4ce2d259675fa7f1d6069a318bc8e8a98b0850
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.

None yet

3 participants