-
Notifications
You must be signed in to change notification settings - Fork 0
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
Autover fails to read .version on Windows when param is stored on a "posix-like filesytem" #63
Comments
I'd be happy to look for _version.py instead, particularly since it helps address the other situation of inappropriately calling git for released versions -- if we change the filename at this time, developers who happen to have .version sitting around on their hard drive from an old call to setup.py won't be messed up! (Assuming we change setup.py not to generate _version (or .version) unless actually building a release package) |
I think the problem is that
On line 178 will make sure the separator is at consistent at which point I believe that Python will be able to handle opening the file just fine. Is there any reason you don't think this is true @ceball ? |
I don't think that will work in the scenario I described (which I did not describe very well, sorry). If param is at But you still might be able to figure out a way to get the path separators right! However, I only gave the particular example in this issue because it was a recent concrete one in my mind. There are probably various others I could think up, since as far as I know, a python module does not have to be a file "according to the language rules" (not sure though! and often they are referred to as files). E.g. (not sure it lists all the istuations when it doesn't have to be set?) Anyway, maybe a less weird example than the one I posted in this issue would be when a module is imported from a zip file? That's functionality in the stdlib (right?) and I think you might have trouble using Basically my conclusion in the past was: what can you trust in the place you're running except the import system, given that nothing would work without that (right?!). But there are things in/around setuptools/other(newer) stdlib modules to help with "reading 'data' from packages". An oldish setuptools example would be using something like |
If Using the import system to simply grab some data from a file seems rather ridiculous although it does seem to resolve some of these annoying edge cases as you point out. I suppose instead of a JSON file, it can simply be a Python dictionary literal that you import but again, this all seems rather silly. |
importlib.resources does look suitable, but it's about 10 years too late! Basically, what we're up against is that the default of simply setting an attribute |
Code like
vfile = os.path.join(os.path.dirname(self.fpath), '.version')
can fail because you can end up with something like/path/to/param\\.version
on windows. (I know, I know, windows...)Code like the above appears in a few places, but reading the
.version
file is the one that bothers me:https://github.com/pyviz-dev/autover/blob/956ffe8fef9dbf4dda67e2529be986e3df1cbda8/autover/version.py#L311-L324
I used quotes in the title because it doesn't have to be a filesystem - it could be something else...something like some kind of a database, say. As long as the "path separator" you need to use to open the
.version
file is different from what python thinks the path separator is for the platform it's running on (which could indeed be correct for accessing files on some other part of the system), it will not work out.There are various things you could do to try to overcome this problem, but I think my proposed solution for this in the past was that
.version
should instead be_version.py
, and autover should just rely on python's import system, which is guaranteed to be set up ok anywhere you're able to import stuff like param in the first place. But presumably there are downsides to that.The text was updated successfully, but these errors were encountered: