Dian Fu created FLINK-27373:
-------------------------------

             Summary: Disable installing PyFlink using `python setup.py install`
                 Key: FLINK-27373
                 URL: https://issues.apache.org/jira/browse/FLINK-27373
             Project: Flink
          Issue Type: Improvement
          Components: API / Python
            Reporter: Dian Fu
            Assignee: Dian Fu


When users install PyFlink using `pip install .` or `pip install apache-flink`, 
it will be installed into site-packages with directories as following:
{code}
apache_flink-1.14.4.dist-info
apache_flink_libraries-1.14.4.dist-info
pyflink
{code}

However, if installed using `python setup.py install`, the result directories 
will be as following:
{code}
apache_flink-1.14.4-py3.8-macosx-10.9-x86_64.egg
apache_flink_libraries-1.14.4-py3.8.egg
{code} 

The consequence of the latter case is that the installed package is 
problematic. The reason is that it contains jar packages in 
apache_flink_libraries and currently these jar packages need to be installed 
together with apache_flink to make them work(under directory pyflink/lib and 
pyflink/opt).

Users will get the following error when installing PyFlink via "python setup.py 
install":
{code}
Error: Could not find or load main class 
org.apache.flink.client.python.PythonGatewayServer
Caused by: java.lang.ClassNotFoundException: 
org.apache.flink.client.python.PythonGatewayServer
E/Users/dianfu/miniconda3/lib/python3.8/unittest/case.py:704: ResourceWarning: 
unclosed file <_io.BufferedWriter name=5>
  outcome.errors.clear()
ResourceWarning: Enable tracemalloc to get the object allocation traceback

======================================================================
ERROR: test_scalar_function (test_table_api.TableTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/dianfu/code/src/github/pyflink-faq/testing/test_utils.py", line 
122, in setUp
    self.t_env = 
TableEnvironment.create(EnvironmentSettings.in_streaming_mode())
  File 
"/Users/dianfu/code/src/github/pyflink-faq/testing/.venv/lib/python3.8/site-packages/apache_flink-1.14.4-py3.8-macosx-10.9-x86_64.egg/pyflink/table/environment_settings.py",
 line 267, in in_streaming_mode
    get_gateway().jvm.EnvironmentSettings.inStreamingMode())
  File 
"/Users/dianfu/code/src/github/pyflink-faq/testing/.venv/lib/python3.8/site-packages/apache_flink-1.14.4-py3.8-macosx-10.9-x86_64.egg/pyflink/java_gateway.py",
 line 62, in get_gateway
    _gateway = launch_gateway()
  File 
"/Users/dianfu/code/src/github/pyflink-faq/testing/.venv/lib/python3.8/site-packages/apache_flink-1.14.4-py3.8-macosx-10.9-x86_64.egg/pyflink/java_gateway.py",
 line 112, in launch_gateway
    raise Exception("Java gateway process exited before sending its port 
number")
Exception: Java gateway process exited before sending its port number
{code}

`python setup.py install` is already deprecated in Python community and it's 
suggesting to use `pip install`. We have two choices:
- Support installing PyFlink using `python setup.py install`
- Disable installing PyFlink using `python setup.py install` and throw a 
meaningful exception if users install it with `python setup.py install` to make 
it more explicit




--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to