-
Notifications
You must be signed in to change notification settings - Fork 293
harcoded tmp folder prevent windows compatibilty of past module #296
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
Conversation
src/past/translation/__init__.py
Outdated
@@ -219,20 +220,20 @@ def detect_python2(source, pathname): | |||
if source != str(tree)[:-1]: # remove added newline | |||
# The above fixers made changes, so we conclude it's Python 2 code | |||
logger.debug('Detected Python 2 code: {0}'.format(pathname)) | |||
with open('/tmp/original_code.py', 'w') as f: | |||
with open(os.path.join(temppath,'original_code.py'), 'w') as f: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend using tempfile.mkdtemp
instead of this and removing line 211 (temppath
)
Also fixes bug related to simultaneous use of past
on the same system
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mr-c Thanks for the suggestion. I have made appropriate changes.
And Simultaneous use of past
module is an interesting use case. Never thought about it. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
It's great! |
@serge2016 Thanks. Can we get this PR merged ASAP so we can remove our workaround? |
@serge2016 I agree that we should remove the temp file once our work is done. I can make a separate PR for it. In the meanwhile once this PR get merge we can remove our workaround as mentioned by @mr-c |
@kapilkd13, @mr-c How can I help you? |
@serge2016 Actually we were hoping that you have commit access to this repo. My bad :) |
@kapilkd13 Any suggestions what do I have to do to speed up merging of this PR? |
@edschofield, @QuLogic, @krischer, dear colleagues! Could you, please, check this PR and merge it? |
I'm just a user of this library - I have no rights to the repository and also not enough knowledge of the library's internals to judge this. |
@krischer you are a contributor) |
@edschofield, could you help us, please, to get this PR merged? |
Any change to merge? |
Is there something blocking the merging of this PR? If not, can it be merged into master as soon as possible? This fixes an additional problem I am encountering. When past.translation is used from python3.x by two different users on the same machine, the second user will be unable to do so due to the permissions of the files created in the top level directory of Writing those files to a subdirectory within |
Guys please any change to merge? |
PR looks good. Maybe it's time to merge it? @mr-c |
@ADKosm Fine by me, but I don't have permissions here |
@mr-c Maybe you know, who does? |
@serge2016 I have no relationship with this project. Looks like @edschofield merged the last round of accepted PRs |
@mr-c It looks like no one is managing this repo now. Is there a way to gain commit access here. |
@kapilkd13 Someone (or better, a group) could fork this, rename it and maintain it themselves. There is no way to gain commit access to a repository without assistance from the repository owner. |
@mr-c A new maintainer group with fork of this repo sounds good. |
@@ -395,7 +396,7 @@ def load_module(self, fullname): | |||
|
|||
if detect_python2(source, self.pathname): | |||
source = self.transform(source) | |||
with open('/tmp/futurized_code.py', 'w') as f: | |||
with open(os.path.join(tempfile.mkdtemp(),'futurized_code.py'), 'w') as f: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesnt actually work. The existing code assumes that the futurized_code.py is in the same path as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 -- it might make sense to call tempfile.mkdtemp() once during test setup, refer to it throughout, and delete on cleanup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #335
@bakkerthehacker is right, this changeset will still (silently) not clean up the files (the previous code didn't either), though it will fix the file permission issues and the windows compatibility by using tempfile.mkdtemp for each execution instead of If those 3 files being written are unused by the package code, it is even better just to not write them in the first place. Doing a search for the filenames doesn't show any reference to them after writing. PR #335 removes them, and can resolve this PR. The last merge was completed 11 months ago. I think if there is still no reply within some time frame going forwards, we will need to think about where a fork of this code will need to live, and have a support request submitted for the package in PyPI in order to give it a new set of maintainers. |
Hello! Any chances to get progress here? |
@jmadler I saw you made a recent commit, can you merge this PR. |
@@ -395,7 +396,7 @@ def load_module(self, fullname): | |||
|
|||
if detect_python2(source, self.pathname): | |||
source = self.transform(source) | |||
with open('/tmp/futurized_code.py', 'w') as f: | |||
with open(os.path.join(tempfile.mkdtemp(),'futurized_code.py'), 'w') as f: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 -- it might make sense to call tempfile.mkdtemp() once during test setup, refer to it throughout, and delete on cleanup.
@kapilkd13 one minor change but otherwise looks good. Would you be open to setting up a PR to support Windows more broadly? Getting travis to run on Windows and all tests to succeed would be a good first step. You can build on the matrix config from #366 once that's landed. |
SGTM :) |
For issue #295
Here we are using
temp
env variable to figure out right directory to write files likeoriginal_code.py
in past'stranslate
.I am working on a project that rely on past module and currently before calling the past module's function I am creating Temp directory as a workaround. Once this PR is merged I don't have to use that workaround.
It would be good to make this module independent of any OS. Thanks