There is a so-called local ENU (east north up) coordinate system that complies with the one you call XYZ. ENU can be converted to earth-centered XeYeZe. From that XeYeZe, you can convert to (lat,long,H).
In Python you can use pymap3d
to do all your required computation. Here is a runnable code that you can try.
import pymap3d
ell_wgs84 = pymap3d.Ellipsoid('wgs84')
# Your ENU system needs origin definition (lat0, lon0, h0) +
# and also needs a reference ellipsoid: let's use `ell_wgs84` defined above
lat0, lon0, h0 = -90, 45, 0 # origin of ENU, (h is height above ellipsoid)
# Test ENU coordinates: (e1, n1, u1) by `enu2geodetic()`
e1, n1, u1 = 0.0, 0.0, 0.0 # just the origin of this ENU system
lat1, lon1, h1 = pymap3d.enu2geodetic(e1, n1, u1, \
lat0, lon0, h0, \
ell=ell_wgs84, deg=True) # use wgs86 ellisoid
# this should agree with: (lat0, lon0, h0)
print(lat1, lon1, h1) # -90.0 44.99999999999999 1.313839409243646e-12 OK!
# Inversion check by `geodetic2enu()`
# input values to convert: lat1, lon1, h1
e1k, n1k, u1k = pymap3d.geodetic2enu(lat1, lon1, h1, lat0, lon0, h0, ell=ell_wgs84, deg=True)
print(e1k, n1k, u1k) # 0,0,0 OK
# Now arbitrary ENU to lat/long and reverse
lat112, lon112, h112 = pymap3d.enu2geodetic(1120, 100, 10, \
lat0, lon0, h0, \
ell=ell_wgs84, deg=True)
print(lat112, lon112, h112)
# Check
e112k, n112k, u112k = pymap3d.geodetic2enu(lat112, lon112, h112, lat0, lon0, h0, ell=ell_wgs84, deg=True)
print(e112k, n112k, u112k) # 1120, 100, 10 OK