Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
dean0x7d committed Sep 22, 2023
1 parent c9f3df0 commit 124329b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/test_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
embedded-py: [3.9.8, 3.11.3]
os: [windows-latest]
embedded-py: [3.11.3]
env:
create_pck: conan create . lumicks/testing -o embedded_python:version=${{ matrix.embedded-py }} --build=missing
steps:
Expand All @@ -31,9 +31,5 @@ jobs:
run: conan create ./core lumicks/testing -o embedded_python-core:version=${{ matrix.embedded-py }} --build=missing
- name: Test baseline
run: ${{ env.create_pck }}
- name: Test with numpy env
run: ${{ env.create_pck }} -o test_embedded_python:env=numpy
- name: Test with nbconvert env
run: ${{ env.create_pck }} -o test_embedded_python:env=nbconvert
- name: Test with pylake env
run: ${{ env.create_pck }} -o test_embedded_python:env=pylake
26 changes: 21 additions & 5 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def package_py_exe(self):
else:
return pathlib.Path(self.package_folder, "embedded_python/bin/python3")

def _run_bootstrap_py(self, command, **kwargs):
self.run(f"{self.bootstrap_py_exe} -E -s {command}", **kwargs)

def make_package_list(self):
"""Create a list of package names based on `self.options.packages`
Expand Down Expand Up @@ -140,13 +143,26 @@ def _build_bootstrap(self):
file.rename(dlls / file.name)
# We need pip to install packages
files.download(self, "https://bootstrap.pypa.io/get-pip.py", filename="get-pip.py")
self.run(f"{self.bootstrap_py_exe} -E get-pip.py")
self._run_bootstrap_py("get-pip.py")

# While we do need to mostly restore regular module path rules for the bootstrap, we still
# don't want to get conflicts with packages installed in the user's home directory. We can
# disable those via env variable. Again, this is only for bootstrapping. The final package
# will be fully isolated via the `._pth` file.
self.run(f'{self.bootstrap_py_exe} -c "import sys; [print(p) for p in sys.path]; print()"')
os.environ["PYTHONNOUSERSITE"] = "1"
self.run(f'{self.bootstrap_py_exe} -c "import sys; [print(p) for p in sys.path]; print()"')
os.environ["PYTHONSAFEPATH"] = "1"
self.run(f'{self.bootstrap_py_exe} -c "import sys; [print(p) for p in sys.path]; print()"')
self.run(
f"{self.bootstrap_py_exe} -c \"import os; print(os.environ.get('PYTHONSAFEPATH'))\""
)
self.run(
f'{self.bootstrap_py_exe} -s -E -c "import sys; [print(p) for p in sys.path]; print()"'
)
self.run(
f'{self.bootstrap_py_exe} -I -c "import sys; [print(p) for p in sys.path]; print()"'
)

specs = [
f"pip=={self.options.pip_version}",
Expand All @@ -155,12 +171,12 @@ def _build_bootstrap(self):
f"pip-licenses=={self.options.pip_licenses_version}",
]
options = "--no-warn-script-location --upgrade"
self.run(f"{self.bootstrap_py_exe} -E -m pip install {options} {' '.join(specs)}")
self._run_bootstrap_py(f"-m pip install {options} {' '.join(specs)}")

def _gather_licenses(self, license_folder):
"""Gather licenses for all packages using our bootstrap environment"""
self.run(
f"{self.bootstrap_py_exe} -E -m piplicenses --python={self.package_py_exe}"
self._run_bootstrap_py(
f"-m piplicenses --python={self.package_py_exe}"
" --with-system --from=mixed --format=plain-vertical"
" --with-license-file --no-license-path --output-file=package_licenses.txt",
cwd=license_folder,
Expand Down Expand Up @@ -195,7 +211,7 @@ def package(self):
)
prefix = pathlib.Path(self.package_folder, "embedded_python")
options = f'--no-deps --ignore-installed --no-warn-script-location --prefix "{prefix}"'
self.run(f"{self.bootstrap_py_exe} -E -m pip install {options} -r {requirements}")
self._run_bootstrap_py(f"-m pip install {options} -r {requirements}")
self._gather_licenses(license_folder)
self._gather_packages(license_folder)

Expand Down

0 comments on commit 124329b

Please sign in to comment.