Repository: neutrinoceros/wxc (language: python)

Issue:
installation method is clunky and brittle
prepending to PYTHONPATH is bad practice, period.
I don't think it's worth trying to be _smart_ about how to approach installation of this tool, it _should_ be installed via pip in each environment it's needed.
This would be much easier if the project was renamed so that I could publish it on Pypi without colliding with the existing (unrelated) project `whych`.

and of coures this means moving the repo itself, so I expect nice surprises.


Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index 43a0e31..d7acfec 100644
--- a/README.md
+++ b/README.md
@@ -28,29 +28,16 @@ $ pyw pandas.DataFrame
 
 ## Installation
 
-### Usage
-
-``pyw``'s command line application shines most if you use isolated Python
-environments. In order to make it available from anywhere on your system and
-against the current environment run
+Get the latest stable version
 ```shell
-$ python install_app.py
+$ pip install pyw
 ```
-:warning: Currently only Linux and MacOS are supported. On Windows, it is still
-possible to install `pyw` on an specific environment by installing it as a
-Python package (see next section).
-
-### Python api
 
-From the top level of the repo, run
+Or, if you want the bleeding edge devleopment version
 ```shell
-$ pip install -e .
+$ pip install git+https://github.com/neutrinoceros/pyw@development
 ```
 
-This will make `pyw`'s internal functionalities available from a Python
-session in the current environment.
-
-
 ## Usage
 
 Examples
diff --git a/install_app.py b/install_app.py
deleted file mode 100644
index 070955e..0000000
--- a/install_app.py
+++ /dev/null
@@ -1,4 +0,0 @@
-if __name__ == "__main__":
-    from pyw._installer import main
-
-    main()
diff --git a/pyw/_installer.py b/pyw/_installer.py
deleted file mode 100644
index 9664e99..0000000
--- a/pyw/_installer.py
+++ /dev/null
@@ -1,77 +0,0 @@
-import os
-import stat
-import sys
-from pathlib import Path
-
-RCFILE_LOOKUP_TABLE = [".zshrc", ".bashrc", ".bash_profile"]
-THIS_FILE = Path(__file__).resolve()
-REPO_DIR = THIS_FILE.parents[1]
-DEFAULT_INSTALL_DIR = REPO_DIR / ".app"
-
-
-def _lookup_rcfile(interactive: bool):
-
-    found = [
-        file for file in RCFILE_LOOKUP_TABLE if (Path.home() / file).is_file()
-    ]
-    if not found:
-        raise FileNotFoundError(
-            "Could not determine your shell configuration file"
-        )
-
-    if interactive and len(found) > 1:
-        filename = ""
-        while filename not in found:
-            filename = input(
-                "Please select your shell configuration file "
-                f"({', '.join(found)}))    "
-            )
-    else:
-        filename = found[0]
-
-    rcfile = Path.home() / filename
-    return rcfile
-
-
-def main(install_dir=None, rcfile=None):
-
-    if install_dir is None:
-        install_dir = DEFAULT_INSTALL_DIR
-    install_dir = Path(install_dir)
-
-    try:
-        install_dir.mkdir()
-    except FileExistsError:
-        print(
-            f"{install_dir} already exists. "
-            "Please remove this directory before installing again. "
-            "You might also need to cleanup your shell rc file."
-        )
-        sys.exit(1)
-
-    # create an executable symlink
-    app_file = install_dir / "pyw"
-    app_file.symlink_to(REPO_DIR.joinpath("pyw", "__main__.py"))
-    st = os.stat(app_file)
-    os.chmod(app_file, st.st_mode | stat.S_IEXEC)
-
-    # prepend $PATH and $PYTHONPATH to rcfile
-    if rcfile is None:
-        rcfile = _lookup_rcfile(interactive=False)
-
-    with open(rcfile, mode="at") as fileh:
-        fileh.write(
-            "\n".join(
-                [
-                    f"# Created by {THIS_FILE}",
-                    f"export PATH={install_dir}:$PATH",
-                    f"export PYTHONPATH={REPO_DIR}:$PYTHONPATH\n",
-                ]
-            )
-        )
-
-    print(
-        "Installation complete. "
-        "To start using pyw, please open a new terminal, or run\n"
-        f"source {rcfile}"
-    )


Test patch:
diff --git a/tests/test_install.py b/tests/test_install.py
deleted file mode 100644
index e1f39a2..0000000
--- a/tests/test_install.py
+++ /dev/null
@@ -1,67 +0,0 @@
-import os
-import sys
-import tempfile
-from pathlib import Path
-from tempfile import NamedTemporaryFile
-from unittest import mock
-
-import pytest
-
-from pyw import _installer
-from pyw._installer import _lookup_rcfile, main
-
-
-@pytest.mark.skipif(sys.platform.startswith("win"), reason="no windows support")
-def test_lookup_rcfile():
-    rcfile = _lookup_rcfile(interactive=False)
-    assert rcfile.is_file()
-
-    # mock a non-existing file by creating a tempfile and removing it
-    with tempfile.NamedTemporaryFile(dir=str(Path.home())) as tmprcfile:
-        filename = tmprcfile.name
-    with mock.patch.object(_installer, "RCFILE_LOOKUP_TABLE", [filename]):
-        with pytest.raises(FileNotFoundError):
-            _lookup_rcfile(interactive=False)
-
-
-def test_lookup_rcfile_interactive():
-    tmprc1 = NamedTemporaryFile(dir=Path.home())
-    tmprc2 = NamedTemporaryFile(dir=Path.home())
-    fake_lookup_table = [tmprc1.name, tmprc2.name]
-    with mock.patch.object(
-        _installer, "RCFILE_LOOKUP_TABLE", fake_lookup_table
-    ):
-        for fname in fake_lookup_table:
-            with mock.patch("builtins.input", return_value=fname):
-                result = _lookup_rcfile(interactive=True)
-            assert Path(result) == Path(fname)
-    tmprc1.close()
-    tmprc2.close()
-
-
-@pytest.mark.skipif(sys.platform.startswith("win"), reason="no windows support")
-def test_default_install():
-    with tempfile.TemporaryDirectory() as tmpdir:
-        fake_default_dir = os.path.join(tmpdir, ".app")
-        with mock.patch.object(
-            _installer, "DEFAULT_INSTALL_DIR", fake_default_dir
-        ):
-            with tempfile.NamedTemporaryFile(dir=str(Path.home())) as tmprcfile:
-                with mock.patch.object(
-                    _installer, "RCFILE_LOOKUP_TABLE", [tmprcfile.name]
-                ):
-                    assert not Path(fake_default_dir).exists()
-                    main()
-
-
-@pytest.mark.skipif(sys.platform.startswith("win"), reason="no windows support")
-def test_repeated_install():
-    with tempfile.TemporaryDirectory() as tmpdir:
-        install_dir = os.path.join(tmpdir, ".app")
-        with tempfile.NamedTemporaryFile(dir=str(Path.home())) as tmprcfile:
-            with mock.patch.object(
-                _installer, "RCFILE_LOOKUP_TABLE", [tmprcfile.name]
-            ):
-                main(install_dir=install_dir)
-                with pytest.raises(SystemExit):
-                    main(install_dir=install_dir)