KikeM / xfoil-python

Stripped down version of XFOIL as compiled python module.
GNU General Public License v3.0
11 stars 0 forks source link

BLD: problems with the installation #7

Closed KikeM closed 4 years ago

KikeM commented 4 years ago

The user @parmonon reported a problem after installing the library and then running it.

>>> from xfoil import Xfoil
>>> xf = Xfoil()
Traceback (most recent call last):

  File "<ipython-input-2-334904b966f4>", line 1, in <module>
    xfoil.XFoil()

  File "/usr/local/lib/python3.5/dist-packages/xfoil-0.0.16-py3.5.egg/xfoil/xfoil.py", line 66, in __init__
    copy2(lib_path, self._lib_path)

  File "/usr/lib/python3.5/shutil.py", line 251, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)

  File "/usr/lib/python3.5/shutil.py", line 114, in copyfile
    with open(src, 'rb') as fsrc:

FileNotFoundError: [Errno 2] No such file or directory: '/Users/Kike/Library/Mobile Documents/com~apple~CloudDocs/Documents/Inbox/TU_Delft/MsC/Q1/Aircraft_Aerodynamics/Code/xfoil-python/build/lib.macosx-10.7-x86_64-3.6/xfoil/libxfoil.dylib'
KikeM commented 4 years ago

The solution for the moment is not clean at all ... I haven't had the time to work on the installation.

To have some context

When I began using this library I tried to install it and had trouble. I realised what was breaking my installation was the fact that the libxfoil.dylib file was being created, but for some reason not in the folder the installation procedure expected. Therefore, the installation ended with an error.

Since the file was created, which means the Fortran code has been compiled, I did a dirty workaround.

  1. Created a new setup.py where I did not invoke the compilation step.
  2. Modified the lines in the code which define where to look for the compiled library to point directly towards my file. That is what is breaking your code, the fact that I hardcoded the address to my local file.

Basically, I ran the installation to compile (to get the file) and then the installation without compilation (to be able to work with the library). That did the trick.

Solution to the problem

  1. Change the name of the current setup.py file to something like no_compilation_setup.py.
  2. Change the name of the current old_setup.py file to setup.py.
  3. Run pip install --no-cache-dir --force-reinstall . (this should generate the compiled Fortran library).
  4. Change the name of the current setup.py file to old_setup.py.
  5. Change the name of the current no_compilation_setup.py file to setup.py.
  6. Run pip install --no-cache-dir --force-reinstall . (this should install the library in your site-packages folder inside your environment).

Tell me what happened from here onwards so that we continue debugging :)

For me to know

Do you plan to extend the functionality of the library or do you want the simply use the current code.

parmonom commented 4 years ago

Hi,

Thanks for the help. I am now blocked at step 3.

$ sudo pip3 install --no-cache-dir --force-reinstall .

Processing /home/john/Bureau/xfoil-python-master
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /home/john/.local/lib/python3.5/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-6cd9omhj/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- scikit-build cmake
       cwd: None
  Complete output (18 lines):
  WARNING: The directory '/home/john/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
  Collecting scikit-build
    Downloading scikit_build-0.11.1-py2.py3-none-any.whl (72 kB)
  Collecting cmake
    Downloading cmake-3.18.0.tar.gz (28 kB)
      ERROR: Command errored out with exit status 1:
       command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7upyyj9e/cmake/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7upyyj9e/cmake/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-7upyyj9e/cmake/pip-egg-info
           cwd: /tmp/pip-install-7upyyj9e/cmake/
      Complete output (5 lines):
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/tmp/pip-install-7upyyj9e/cmake/setup.py", line 7, in <module>
          from skbuild import setup
      ImportError: No module named 'skbuild'
      ----------------------------------------
  ERROR: 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: /usr/bin/python3 /home/john/.local/lib/python3.5/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-6cd9omhj/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- scikit-build cmake Check the logs for full command output.

I don't really know what is going on. looks like problem with cmake or skbuild.

For now I just plan to use the current code.

KikeM commented 4 years ago

looks like problem with cmake or skbuild.

https://github.com/scikit-build/cmake-python-distributions/issues/86

In this issue they seem to suggest the following solution:

  1. pip install scikit-build
  2. pip install cmake

Building bugs and problems are always painful ...

parmonom commented 4 years ago

I use Ubuntu (32bits) not using conda.

I installed scikit-build correctly.

I had problem to install cmake. Update pip to 20.1 solved it.

Then I had problem on step 3 : pip install --no-cache-dir --force-reinstall . Cmake was looking for /usr/local/bin/gfortran but gfortran was installed here /usr/bin/gfortran so I made a symlink to solve it

Step 4, 5, 6 went without issue.

I was able to import xfoil correctly on python. I hard-coded the variable: lib_path = '/home/john/Bureau/xfoil-python-master/build/lib.linux-i686-3.5/xfoil/libxfoil.so' lib_ext ='so'

I had to comment from deprecated import deprecated and corresponding functions, because I don't have that module

Now everything works !! Thanks for your help.

KikeM commented 4 years ago

So glad to read this!

Some takeaways for @KikeM:

Let me know how things go using the library, if you have any doubts or problems do not hesitate and create issues.

Cheers