Skip to content

Commit

Permalink
Install works on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasBorboleta committed Feb 9, 2021
1 parent 82cbd45 commit 51df58f
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 13 deletions.
13 changes: 11 additions & 2 deletions docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@

*jersi_certu* has been developed using Python 3.8.5. So it is better to have installed such version or some higher version.

### Instructions for Windows and Linux platforms
### Instructions for Linux and Windows platforms

1. Make an installation directory by either cloning this *git* repository or downloading it as a zip archive and unzipping it.

2. Move into the installation directory, where the `README.md` file seats.
3. Execute `jersi_start.py`: the first time a Python virtual environment is created and the required dependencies are downloaded and installed; then GUI is started. The next times, just the GUI is started.

3. Execute `python jersi_start.py` on Linux and double-click on`jersi_start.py` on Windows:

- On Windows, if needed, the first time, use `Open with ...` in order to associate `.py` file with your installed `python` interpreter.

- The first time a Python virtual environment is created and the required dependencies are downloaded and installed; then the GUI is started.
- The next times, the GUI is just started.

4. For un-installing *jersi_certu* just remove the installation directory.

5. The above instructions might also work on other platforms, but only Windows and Linux have been tested.

### Used dependencies
Expand Down
2 changes: 0 additions & 2 deletions jersi_start.bat

This file was deleted.

50 changes: 41 additions & 9 deletions jersi_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import os
import subprocess
import sys


_product_home = os.path.abspath(os.path.dirname(__file__))
os.chdir(_product_home)
Expand All @@ -37,33 +37,65 @@
print("Creating virtual environment ...")
subprocess.run(args=[sys.executable, "-m", "venv", ".env"], shell=False, check=True)
print("Creating virtual environment done")
install_dependencies = True
_install_dependencies = True

else:
install_dependencies = False
_install_dependencies = False
print("Checking virtual environment done")


print()
print("Determining the python executable ...")
if os.name == 'nt':
_python_executable = os.path.join(_venv_home, "Scripts", "python.exe")
_venv_python_executable = os.path.join(_venv_home, "Scripts", "python.exe")

elif os.name == 'posix':
_python_executable = os.path.join(_venv_home, "bin", "python")
_venv_python_executable = os.path.join(_venv_home, "bin", "python")

else:
_python_executable = glob.glob(os.path.join(_venv_home, "*/python*"))[0]
_venv_python_executable = glob.glob(os.path.join(_venv_home, "*/python*"))[0]

print("_venv_python_executable = ", _venv_python_executable)
print("Determining the python executable done")



if install_dependencies:
if _install_dependencies:
print()
print("Installing dependencies ...")
subprocess.run(args=[_python_executable, "-m", "pip", "install", "-r", "requirements.txt"], shell=False, check=True)

if os.name == 'nt':
# windows fix to "import _ssl" failure after "import ssl" in "pip"
_sys_python_path = os.path.dirname(sys.executable)

if 'PATH' in os.environ:
os.environ['PATH'] = (_sys_python_path + os.pathsep +
os.path.join(_sys_python_path, 'Scripts') + os.pathsep +
os.path.join(_sys_python_path, 'Library', 'bin') + os.pathsep +
os.environ['PATH'] )
else:
os.environ['PATH'] = (_sys_python_path + os.pathsep +
os.path.join(_sys_python_path, 'Scripts') + os.pathsep +
os.path.join(_sys_python_path, 'Library', 'bin') )


_venv_python_path = os.path.dirname(_venv_python_executable)

if 'PATH' in os.environ:
os.environ['PATH'] = _venv_python_path + os.pathsep + os.environ['PATH']
else:
os.environ['PATH'] = _venv_python_path

subprocess.run(args=[_venv_python_executable, "-c", "import ssl"], shell=False, check=True)

subprocess.run(args=[_venv_python_executable, "-m", "pip", "install", "--upgrade", "pip"], shell=False, check=True)
subprocess.run(args=[_venv_python_executable, "-m", "pip", "install", "-r", "requirements.txt"], shell=False, check=True)
print("Installing dependencies done")


print()
print("jersi_gui ...")
subprocess.run(args=[_python_executable, _jersi_gui_executable], shell=False, check=True)
subprocess.run(args=[_venv_python_executable, _jersi_gui_executable], shell=False, check=True)
print()
print("jersi_gui done")

Expand Down

0 comments on commit 51df58f

Please sign in to comment.