-
Notifications
You must be signed in to change notification settings - Fork 5
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
Take a dictionary instead of a file #7
Comments
Can you please give a concrete example of what you want to achieve? |
I'm actually directly calling pyinstaller_versionfile.create_file_version.MetaData as an API so that I can set things programmatically when pyinstaller runs. But it just occurred to me that what I probably need to do is send an IO steam that contains my content rather than have a file on the side. |
I will take a look at this - so for you it would be enough if the MetaData class would accept a file-like object instead of a filepath? |
With a bit more playing, with the 1.0.2 version, this hack demonstrates what I'm looking to do. |
So really: rather than taking a raw file or a stream, taking a structure would be much more flexible. |
@aw-was-here I pushed a update to the develop branch. For issue #6 I wanted to separate the input of the metadata and creation of the output file anyway, and this should now also make what you want to do straightforward, as you can just create your own Here would be a minimal example: from pyinstaller_versionfile.metadata import MetaData
from pyinstaller_versionfile.writer import Writer
metadata = MetaData(version="1.2.3.4", legal_copyright="My Imaginary Company") # all parameters are optional, just specify what you need
writer = Writer(metadata)
writer.render()
writer.save("versionfile.txt") Would this solve your problem? |
@DudeNr33 Just tried out the develop branch: yes! definitely! This change makes it much easier to incorporate into the build. Two things probably worth mentioning:
metadata = MetaData(version='1.2.3', ...) ends up being
which is obviously wrong.
writer = Writer(metadata)
writer.render()
writer.save("versionfile.txt") Should save() just call render()? Should render() return the rendered text as well? Or perhaps you have other plans already and it will make more sense later. 👍
That's fine for me. I've already got code that requires 3.8 in use. Thanks! |
Thank you for your feedback! Ad 1)
I considered calling both methods directly in the Ad 2) I think both issues could be addressed by providing a functional API in the # __init__.py
def create_versionfile(version, company_name, ..., outfile):
metadata = MetaData(version, company_name, ...)
metadata.validate()
metadata.sanitize()
writer = Writer(metadata)
writer.render()
writer.save(outfile)
def create_versionfile_from_file(infile, outfile, version=None):
metadata = MetaData.from_file(infile)
metadata.validate()
if version:
metadata.set_version(version)
metadata.sanitize()
writer = Writer(metadata)
writer.render()
writer.save(outfile) This would at least save you from calling all methods yourself in the correct order. |
That all looks fantastic. Combined with pyinstaller taking the version file as a parameter these changes make it all very easy to do now. Thanks! |
V2.0.0 is now available on PyPI. Check the updated readme for the final function signature. 👍 |
Thanks! |
It would be fantastic if there was a way to replace copyright. Given the limitations of the version field, it is useful to stuff that field with more information at build-time. Thanks!
The text was updated successfully, but these errors were encountered: