UB-Mannheim / RaiseWikibase

Knowledge graph construction: Fast inserts into a Wikibase instance
https://ub-mannheim.github.io/RaiseWikibase/
MIT License
45 stars 7 forks source link

Issues with install on Windows (encoding) #17

Closed MHuberFaust closed 2 years ago

MHuberFaust commented 2 years ago

Hi,

I'm trying an install on a Windows machine as a test run and found into several problems so far: (Usually I tried to avoid Windows, so I might not be as familiar with common workarounds)

The Windows console had encoding issues:

(base) C:\Users\knutt\raiseWikibase>pip3 install .
Processing c:\users\knutt\raisewikibase
   DEPRECATION: A future pip version will change local packages to be 
built in-place without first copying to a temporary directory. We 
recommend you use --use-feature=in-tree-build to test your packages 
with this new behavior before it becomes the default.
    pip 21.3 will remove support for this functionality. You can find 
discussion regarding this at https://github.com/pypa/pip/issues/7555.
     ERROR: Command errored out with exit status 1:
      command: 'C:\Users\knutt\anaconda3\python.exe' -c 'import io, 
os, sys, setuptools, tokenize; sys.argv[0] = 
'"'"'C:\\Users\\knutt\\AppData\\Local\\Temp\\pip-req-build-n9qkonl8\\setup.py'"'"'; __file__='"'"'C:\\Users\\knutt\\AppData\\Local\\Temp\\pip-req-build-n9qkonl8\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 
'C:\Users\knutt\AppData\Local\Temp\pip-pip-egg-info-j_f52b4c'
          cwd: C:\Users\knutt\AppData\Local\Temp\pip-req-build-n9qkonl8\
     Complete output (7 lines):
     Traceback (most recent call last):
       File "<string>", line 1, in <module>
       File 
"C:\Users\knutt\AppData\Local\Temp\pip-req-build-n9qkonl8\setup.py", 
line 6, in <module>
         long_description = fh.read()
       File "C:\Users\knutt\anaconda3\lib\encodings\cp1252.py", line 
23, in decode
         return codecs.charmap_decode(input,self.errors,decoding_table)[0]
     UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in 
position 7175: character maps to <undefined>
     ----------------------------------------
WARNING: Discarding file:///C:/Users/knutt/raiseWikibase. Command 
errored out with exit status 1: python setup.py egg_info Check the 
logs for full command output.

Specifying the encoding in setup.py fixed it.

with open("README.md", "r", encoding='utf-8') as fh:
    long_description = fh.read()
MHuberFaust commented 2 years ago

After fixing the problem above

running

pip3 install .

resulted into this:

(base) C:\Users\knutt\raiseWikibase>pip3 install .
Processing c:\users\knutt\raisewikibase
   Preparing metadata (setup.py) ... error
   ERROR: Command errored out with exit status 1:
    command: 'C:\Users\knutt\anaconda3\python.exe' -c 'import io, os, 
sys, setuptools, tokenize; sys.argv[0] = 
'"'"'C:\\Users\\knutt\\raiseWikibase\\setup.py'"'"'; 
__file__='"'"'C:\\Users\\knutt\\raiseWikibase\\setup.py'"'"';f = 
getattr(tokenize, '"'"'open'"'"', open)(__file__) if 
os.path.exists(__file__) else io.StringIO('"'"'from setuptools import 
setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', 
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' 
egg_info --egg-base 
'C:\Users\knutt\AppData\Local\Temp\pip-pip-egg-info-acikcyib'
        cwd: C:\Users\knutt\raiseWikibase\
   Complete output (39 lines):
   Traceback (most recent call last):
     File "<string>", line 1, in <module>
     File "C:\Users\knutt\raiseWikibase\setup.py", line 8, in <module>
       setup(
     File 
"C:\Users\knutt\anaconda3\lib\site-packages\setuptools\__init__.py", 
line 153, in setup
       return distutils.core.setup(**attrs)
     File "C:\Users\knutt\anaconda3\lib\distutils\core.py", line 108, in setup
       _setup_distribution = dist = klass(attrs)
     File 
"C:\Users\knutt\anaconda3\lib\site-packages\setuptools\dist.py", line 
453, in __init__
       _Distribution.__init__(
     File "C:\Users\knutt\anaconda3\lib\distutils\dist.py", line 292, 
in __init__
       self.finalize_options()
     File 
"C:\Users\knutt\anaconda3\lib\site-packages\setuptools\dist.py", line 
831, in finalize_options
       ep(self)
     File 
"C:\Users\knutt\anaconda3\lib\site-packages\setuptools\dist.py", line 
852, in _finalize_setup_keywords
       ep.load()(self, ep.name, value)
     File 
"c:\users\knutt\raisewikibase\.eggs\setuptools_scm-6.3.2-py3.9.egg\setuptools_scm\integration.py", line 65, in 
version_keyword
       dist.metadata.version = _get_version(config)
     File 
"c:\users\knutt\raisewikibase\.eggs\setuptools_scm-6.3.2-py3.9.egg\setuptools_scm\__init__.py", line 177, in 
_get_version
       parsed_version = _do_parse(config)
     File 
"c:\users\knutt\raisewikibase\.eggs\setuptools_scm-6.3.2-py3.9.egg\setuptools_scm\__init__.py", line 128, in 
_do_parse
       version = _version_from_entrypoints(config) or 
_version_from_entrypoints(
     File 
"c:\users\knutt\raisewikibase\.eggs\setuptools_scm-6.3.2-py3.9.egg\setuptools_scm\__init__.py", line 69, in 
_version_from_entrypoints
       version = _call_entrypoint_fn(root, config, ep.load())
     File 
"c:\users\knutt\raisewikibase\.eggs\setuptools_scm-6.3.2-py3.9.egg\setuptools_scm\__init__.py", line 48, in 
_call_entrypoint_fn
       return fn(root, config=config)
     File 
"c:\users\knutt\raisewikibase\.eggs\setuptools_scm-6.3.2-py3.9.egg\setuptools_scm\git.py", line 135, in 
parse
       return _git_parse_inner(
     File 
"c:\users\knutt\raisewikibase\.eggs\setuptools_scm-6.3.2-py3.9.egg\setuptools_scm\git.py", line 170, in 
_git_parse_inner
       return meta(
     File 
"c:\users\knutt\raisewikibase\.eggs\setuptools_scm-6.3.2-py3.9.egg\setuptools_scm\version.py", line 186, in 
meta
       parsed_version = _parse_tag(tag, preformatted, config)
     File 
"c:\users\knutt\raisewikibase\.eggs\setuptools_scm-6.3.2-py3.9.egg\setuptools_scm\version.py", line 167, in 
_parse_tag
       tag = tag_to_version(tag, config)
     File 
"c:\users\knutt\raisewikibase\.eggs\setuptools_scm-6.3.2-py3.9.egg\setuptools_scm\version.py", line 75, in 
tag_to_version
       version = config.version_cls(version)
     File 
"C:\Users\knutt\anaconda3\lib\site-packages\packaging\version.py", 
line 266, in __init__
       raise InvalidVersion(f"Invalid version: '{version}'")
   packaging.version.InvalidVersion: Invalid version: 'v1.35.0-wmde.0'
   ----------------------------------------
WARNING: Discarding file:///C:/Users/knutt/raiseWikibase. Command 
errored out with exit status 1: python setup.py egg_info Check the 
logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py 
egg_info Check the logs for full command output.

I did not try it on another machine. So it might be related to this system being Windows or the lates updates.

Best,

Michael

shigapov commented 2 years ago

Well, it says packaging.version.InvalidVersion: Invalid version: 'v1.35.0-wmde.0'. Could you try to change the version value in setup.py to any other value, e.g., 1.0.0? May be for some reason it just does not like the string "1.35.0-wmde.0"...

MHuberFaust commented 2 years ago

It probably has to do with version='1.35.0-wmde.0' not being a valid version according to PEP440

Changing the version in setup.py did not change the outcome. (already tried it)

shigapov commented 2 years ago

Is it the same error message after you changed the version?

MHuberFaust commented 2 years ago

Does it look somewhere else? Also, the error code says 'v1.35.0-wmde.0' , which suggests the former.

MHuberFaust commented 2 years ago

Is it the same error message after you changed the version?

the error message stays the same

shigapov commented 2 years ago

Try in editable mode pip install -e .

MHuberFaust commented 2 years ago

same error

shigapov commented 2 years ago

Try uninstalling

MHuberFaust commented 2 years ago

"Skipping RaiseWikibase as it is not installed."

Edit: I assumed you wanted me to uninstall and reinstall with pip

shigapov commented 2 years ago

Right, it is not yet installed obviously :)

Try pip with --use-deprecated=legacy-resolver

MHuberFaust commented 2 years ago

still the same

shigapov commented 2 years ago

May be downgrading pip to the version when PEP440 was not used? Is there a version?

MHuberFaust commented 2 years ago

A workaround might be downgrading to pip 21.0 as hinted here where --use-deprecated=legacy-resolver still works.

It still seems to be worth it to change the tag to an PEP440 valid version.

shigapov commented 2 years ago

Agree!

shigapov commented 2 years ago

I've changed version in setup.py to "1.35.4" according to the used Wikibase Docker image.

MHuberFaust commented 2 years ago

6c618bc34529cba88a2e724449626c297815a19b

in setup.py did not fix it.

I think it looks at different metadata. (maybe https://github.com/UB-Mannheim/RaiseWikibase/releases/tag/v1.35.0-wmde.0)

A workaround might be downgrading to pip 21.0 as hinted here where --use-deprecated=legacy-resolver still works.

It still seems to be worth it to change the tag to an PEP440 valid version.

did not work either and results in the same error message.

shigapov commented 2 years ago

I've just created a new release v1.35.4 based on the latest Wikibase Docker.

MHuberFaust commented 2 years ago

That did it!

For me to run it, it still needs specifying the encoding in the with-open statement.

with open("README.md", "r", encoding='utf-8') as fh:
    long_description = fh.read()
shigapov commented 2 years ago

Would you like to make a pull request for that?