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

Finding langNames default using pkg_resources issue #107 #129

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ayushjainrksh
Copy link
Contributor

Starting fresh pull request that solves issue 107

@coveralls
Copy link

coveralls commented Mar 17, 2019

Coverage Status

Coverage increased (+0.2%) to 45.273% when pulling 375e1ea on ayushjainrksh:issue107 into eb986aa on apertium:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 45.192% when pulling 40af2b3 on ayushjainrksh:issue107 into eb986aa on apertium:master.

@ayushjainrksh
Copy link
Contributor Author

It would build from source properly with default langNames but there is an issue with tornado but that's a separate issue. Please check out this PR.

@sushain97
Copy link
Member

This doesn't seem to be getting the correct path when I use pip3 install .. e.g:

$ apertium-apy --help | grep lang-names -A 3
  -l LANG_NAMES, --lang-names LANG_NAMES
                        path to localised language names sqlite database
                        (default = /usr/local/lib/python3.7/site-
                        packages/langNames.db)

$ stat /usr/local/lib/python3.7/site-packages/langNames.db
stat: /usr/local/lib/python3.7/site-packages/langNames.db: stat: No such file or directory

@ayushjainrksh
Copy link
Contributor Author

Yeah there's a problem. I looked in my system directories and didn't understand why is langNames.db in /usr/local/share/apertium-apy while apertium_apy installation is in /usr/local/lib/python3.7/site-packages/?

@sushain97
Copy link
Member

https://github.com/apertium/apertium-apy/blob/master/setup.py#L68. There's probably a different pkg_resources or pkgutil method to get a path to a data file.

@ayushjainrksh
Copy link
Contributor Author

Please check if it works for you.

@sushain97
Copy link
Member

This is way too hardcoded and will almost certainly fail depending on how the installation is done.

@ayushjainrksh
Copy link
Contributor Author

Should I find another way/package for finding path for datafiles in python?

@ayushjainrksh
Copy link
Contributor Author

The problem is we are looking for apertium_apy installation and datafile is not present in the same folder

@sushain97
Copy link
Member

Should I find another way/package for finding path for datafiles in python?

https://github.com/apertium/apertium-apy/blob/master/setup.py#L68. There's probably a different pkg_resources or pkgutil method to get a path to a data file.

@ayushjainrksh
Copy link
Contributor Author

Hey, I have come up with an idea. I am finding langNames.db in root now. Will that be fine?

@sushain97
Copy link
Member

No, this is a bad idea for a number of reasons including that we shouldn't be searching around the user's filesystem (let's be privacy-sensitive).

@sushain97
Copy link
Member

Did neither pkg_resources not pkgutil have anything useful? I'm relatively certain they will.

@ayushjainrksh
Copy link
Contributor Author

I have been trying to find out if any of the function in both the packages can help. Both rely on installed modules, which in our case is apertium_apy

@ayushjainrksh
Copy link
Contributor Author

Either we do path manipulation as in my previous PR ( the hardcoded one) becuase when we search apertium_modules it takes us to installed package. Well I will keep on searching.

@sushain97 sushain97 force-pushed the master branch 2 times, most recently from b36ac97 to 51fb9c5 Compare January 3, 2022 10:56
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.

3 participants