Skip to content

Commit

Permalink
Merge pull request #10 from ZihengSun/main
Browse files Browse the repository at this point in the history
sync
  • Loading branch information
ZihengSun authored Jun 5, 2023
2 parents e2ed319 + 5262c94 commit ed383d8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 31 deletions.
3 changes: 3 additions & 0 deletions pygeoweaver/java_bin.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

where java
5 changes: 5 additions & 0 deletions pygeoweaver/java_bin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source ~/.bashrc

which java
53 changes: 24 additions & 29 deletions pygeoweaver/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,6 @@
import sys


def get_java_bin_path():
# Check if the 'java' command is available in the system path
if sys.platform.startswith('win'): # Windows
java_exe = 'java.exe'
else:
java_exe = 'java'

java_bin_path = None

for path in os.environ.get('PATH', '').split(os.pathsep):
bin_path = os.path.join(path, java_exe)
if os.path.isfile(bin_path) and os.access(bin_path, os.X_OK):
java_bin_path = os.path.dirname(bin_path)
break

return java_bin_path


def get_home_dir():
return os.path.expanduser('~')
Expand All @@ -36,22 +19,34 @@ def get_root_dir():
head, tail = os.path.split(__file__)
return head


def get_java_bin_from_which():
# Check if 'which' command is available
try:
subprocess.check_output(['source', '~/.bashrc', '&&', 'which', 'java'])
except (subprocess.CalledProcessError, FileNotFoundError):
return None

# Run 'which java' command to get the Java binary path
try:
output = subprocess.check_output(['source', '~/.bashrc', '&&', 'which', 'java'], encoding='utf-8')
java_bin_path = output.strip()
except subprocess.CalledProcessError:
return None

system = platform.system()

if system == 'Darwin' or system == 'Linux':

try:

output = subprocess.check_output([f'{get_root_dir()}/java_bin.sh'], encoding='utf-8')

java_bin_path = output.strip()

except subprocess.CalledProcessError:

return None

elif system == 'Windows':

print('Unsupported platform for windows yet.')

else:
print('Unsupported platform.')

return java_bin_path



def get_java_bin_path():
# Check if the 'java' command is available in the system path
if sys.platform.startswith('win'): # Windows
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pygeoweaver"
version = "0.6.11"
version = "0.6.12"
authors = [
{ name="Geoweaver team", email="geoweaver.app@gmail.com" },
]
Expand All @@ -22,7 +22,7 @@ classifiers = [

[tool.poetry]
name = "pygeoweaver"
version = "0.6.11"
version = "0.6.12"
description = "This is a wrapper package of the Geoweaver app."
authors = ["Geoweaver team <geoweaver.app@gmail.com>"]
readme = "README.md"
Expand Down

0 comments on commit ed383d8

Please sign in to comment.