Refactor bootstrap generation (#2101)
* Refactor bootstrap generation This makes the bootstrap script get the package version directly from pypi instead of from our lists of packages. This makes sure that the packages are actually available for the end user to install. Fixes #2053 * Fix lint * Fix lint * Remove aiohttp * Add missing dependency for aiohttp-client * Use hatch version
This commit is contained in:
parent
2a174b2543
commit
1ee7261ea7
|
|
@ -24,10 +24,6 @@ libraries = [
|
||||||
"library": "aiohttp ~= 3.0",
|
"library": "aiohttp ~= 3.0",
|
||||||
"instrumentation": "opentelemetry-instrumentation-aiohttp-client==0.46b0.dev",
|
"instrumentation": "opentelemetry-instrumentation-aiohttp-client==0.46b0.dev",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"library": "aiohttp ~= 3.0",
|
|
||||||
"instrumentation": "opentelemetry-instrumentation-aiohttp-server==0.46b0.dev",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"library": "aiopg >= 0.13.0, < 2.0.0",
|
"library": "aiopg >= 0.13.0, < 2.0.0",
|
||||||
"instrumentation": "opentelemetry-instrumentation-aiopg==0.46b0.dev",
|
"instrumentation": "opentelemetry-instrumentation-aiopg==0.46b0.dev",
|
||||||
|
|
@ -191,7 +187,6 @@ default_instrumentations = [
|
||||||
"opentelemetry-instrumentation-dbapi==0.46b0.dev",
|
"opentelemetry-instrumentation-dbapi==0.46b0.dev",
|
||||||
"opentelemetry-instrumentation-logging==0.46b0.dev",
|
"opentelemetry-instrumentation-logging==0.46b0.dev",
|
||||||
"opentelemetry-instrumentation-sqlite3==0.46b0.dev",
|
"opentelemetry-instrumentation-sqlite3==0.46b0.dev",
|
||||||
"opentelemetry-instrumentation-threading==0.46b0.dev",
|
|
||||||
"opentelemetry-instrumentation-urllib==0.46b0.dev",
|
"opentelemetry-instrumentation-urllib==0.46b0.dev",
|
||||||
"opentelemetry-instrumentation-wsgi==0.46b0.dev",
|
"opentelemetry-instrumentation-wsgi==0.46b0.dev",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -12,43 +12,55 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os
|
from tomli import load
|
||||||
import subprocess
|
from os import path, listdir
|
||||||
from subprocess import CalledProcessError
|
from subprocess import check_output, CalledProcessError
|
||||||
|
from requests import get
|
||||||
|
|
||||||
import tomli
|
scripts_path = path.dirname(path.abspath(__file__))
|
||||||
|
root_path = path.dirname(scripts_path)
|
||||||
scripts_path = os.path.dirname(os.path.abspath(__file__))
|
instrumentations_path = path.join(root_path, "instrumentation")
|
||||||
root_path = os.path.dirname(scripts_path)
|
|
||||||
instrumentations_path = os.path.join(root_path, "instrumentation")
|
|
||||||
|
|
||||||
|
|
||||||
def get_instrumentation_packages():
|
def get_instrumentation_packages():
|
||||||
for pkg in sorted(os.listdir(instrumentations_path)):
|
for pkg in sorted(listdir(instrumentations_path)):
|
||||||
pkg_path = os.path.join(instrumentations_path, pkg)
|
pkg_path = path.join(instrumentations_path, pkg)
|
||||||
if not os.path.isdir(pkg_path):
|
if not path.isdir(pkg_path):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
error = f"Could not get version for package {pkg}"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
version = subprocess.check_output(
|
hatch_version = check_output(
|
||||||
"hatch version",
|
"hatch version",
|
||||||
shell=True,
|
shell=True,
|
||||||
cwd=pkg_path,
|
cwd=pkg_path,
|
||||||
universal_newlines=True,
|
universal_newlines=True
|
||||||
)
|
)
|
||||||
|
|
||||||
except CalledProcessError as exc:
|
except CalledProcessError as exc:
|
||||||
print(f"Could not get hatch version from path {pkg_path}")
|
print(f"Could not get hatch version from path {pkg_path}")
|
||||||
print(exc.output)
|
print(exc.output)
|
||||||
raise exc
|
|
||||||
|
|
||||||
pyproject_toml_path = os.path.join(pkg_path, "pyproject.toml")
|
try:
|
||||||
|
response = get(f"https://pypi.org/pypi/{pkg}/json", timeout=10)
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
print(error)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if response.status_code != 200:
|
||||||
|
print(error)
|
||||||
|
continue
|
||||||
|
|
||||||
|
pyproject_toml_path = path.join(pkg_path, "pyproject.toml")
|
||||||
|
|
||||||
with open(pyproject_toml_path, "rb") as file:
|
with open(pyproject_toml_path, "rb") as file:
|
||||||
pyproject_toml = tomli.load(file)
|
pyproject_toml = load(file)
|
||||||
|
|
||||||
instrumentation = {
|
instrumentation = {
|
||||||
"name": pyproject_toml["project"]["name"],
|
"name": pyproject_toml["project"]["name"],
|
||||||
"version": version.strip(),
|
"version": hatch_version.strip(),
|
||||||
"instruments": pyproject_toml["project"]["optional-dependencies"][
|
"instruments": pyproject_toml["project"]["optional-dependencies"][
|
||||||
"instruments"
|
"instruments"
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue