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

Windows compability improvements #56

Merged
merged 3 commits into from
Dec 5, 2020
Merged

Windows compability improvements #56

merged 3 commits into from
Dec 5, 2020

Conversation

exc4l
Copy link
Contributor

@exc4l exc4l commented Dec 5, 2020

As mentioned in the commits, when building packages on windows it's important that the encoding of the readme is specified.
https://discuss.python.org/t/pep-597-enable-utf-8-mode-by-default-on-windows/3122

For example, long_description = open("README.md").read() in
setup.py is a common mistake. Many Windows users can not install
the package if there is at least one emoji or any other non-ASCII
character in the README.md file.

Furthermore, when using Ankipandas on windows, collection takes quite some time to find the database due to it starting in the home dictionary.
os.getenv("APPDATA", "~") returns the AppData/Roaming folder with windows typical \\ seperators which is why i feed it into pathlib to get a consistent path. C\\Users\\User_name\\AppData\\Roaming/Anki2/ might work on it's own but I'm uncertain if it could lead to problems. On Linux this should simply result in ~/Anki2

Windows doesn't default to utf8 encoding which results in potential
errors when using windows to build the package.
See:
https://discuss.python.org/t/pep-597-use-utf-8-for-default-text-file-encoding/1819
https://www.python.org/dev/peps/pep-0597/
As mentioned in #1, anki saves it's databases in APPDATA/Roaming/Anki2
os.getenv provides the path in windows fashion with \\ as seperator
which is why i feed the result into Path to convert it into a proper
windowspath.
@klieret
Copy link
Owner

klieret commented Dec 5, 2020

Awesome! I didn't know that about the default encoding, seems like this is a problem for almost all of my projects!
Also very nice with the Windows path!

@klieret klieret merged commit 6bf361a into klieret:master Dec 5, 2020
@klieret
Copy link
Owner

klieret commented Dec 5, 2020

@allcontributors please add @exc4l for code

@allcontributors
Copy link
Contributor

@klieret

I've put up a pull request to add @exc4l! 🎉

@exc4l exc4l deleted the WindowsCompability branch December 5, 2020 15:30
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.

2 participants