diff --git a/.github/workflows/test_package.yml b/.github/workflows/test_package.yml index a498976..fdbc71d 100644 --- a/.github/workflows/test_package.yml +++ b/.github/workflows/test_package.yml @@ -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: @@ -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 diff --git a/conanfile.py b/conanfile.py index 955f471..6b04f38 100644 --- a/conanfile.py +++ b/conanfile.py @@ -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` @@ -140,13 +143,29 @@ 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") + + with open(bootstrap / "pyenv.cfg", "w") as f: + f.write("include-system-site-packages = false\n") # 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}", @@ -155,12 +174,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 --isolated 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, @@ -195,7 +214,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 --isolated {options} -r {requirements}") self._gather_licenses(license_folder) self._gather_packages(license_folder)