Skip to content

Commit

Permalink
Bump to conda 23.11.0 (with menuinst v2) (#36)
Browse files Browse the repository at this point in the history
Co-authored-by: Jannis Leidel <jannis@leidel.info>
Co-authored-by: jaimergp <jaimergp@users.noreply.github.com>
  • Loading branch information
jaimergp and jezdez authored Dec 19, 2023
1 parent 08d67f0 commit d06b2c7
Show file tree
Hide file tree
Showing 8 changed files with 256 additions and 56 deletions.
15 changes: 4 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,25 @@ jobs:
include:
- os: ubuntu-latest
subdir: linux-64
python-version: "3.9"
- os: macos-latest
subdir: osx-64
python-version: "3.9"
- os: windows-latest
subdir: win-64
python-version: "3.9"
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
auto-activate-base: true
activate-environment: ""
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
run-post: false
- name: Install conda-libmamba-solver

- name: Install dependencies
shell: bash -el {0}
run: |
mamba install "conda>=22.11.1" conda-libmamba-solver conda-build anaconda-client
conda update --all --solver=libmamba
run: conda install -y "conda-build!=3.28.0,!=3.28.1" anaconda-client

- name: Build recipe
shell: bash -el {0}
env:
CONDA_SOLVER: libmamba
CONDA_BLD_PATH: ${{ runner.temp }}/bld
run: conda build recipe

Expand Down
20 changes: 20 additions & 0 deletions news/36-update-menuinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Enhancements

* Bump to `python` 3.10.13, `conda` 23.11.0, `conda-libmamba-solver` 23.11.1 and `libmambapy` 1.5.3. (#36)
* Bundle `menuinst` v2.0.1 and import `menuinst` directly without relying on `constructor`'s `_nsis.py` module. (#36)

### Bug fixes

* <news item>

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
14 changes: 8 additions & 6 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% set conda_version = "23.10.0" %}
{% set conda_libmamba_solver_version = "23.11.0" %}
{% set conda_version = "23.11.0" %}
{% set conda_libmamba_solver_version = "23.11.1" %}
{% set libmambapy_version = "1.5.3" %}
{% set constructor_version = "3.5.0" %}
{% set python_version = "3.9.15" %}
{% set python_version = "3.10.13" %}
{% set pyver = "".join(python_version.split(".")[:2]) %}

package:
Expand All @@ -11,16 +11,17 @@ package:

source:
- path: ../

- url: https://github.com/conda/conda/archive/{{ conda_version }}.tar.gz
sha256: 273d49db8ea723426b87866381daf2df27c7bca2c3474196460d637b62de2a1c
sha256: 9276686c8a6ee536dc451cc6557685724fe275a44949ac4f741066fd23cdc7b4
folder: conda_src
patches:
- ../src/conda_patches/0001-Rename-and-replace-entrypoint-stub-exe.patch
- ../src/conda_patches/0002-Manipulate-PATH-directly-instead-of-_call_ing-conda.patch
- ../src/conda_patches/0003-Return-unknown-module-in-deprecations.patch

- url: https://github.com/conda/constructor/archive/{{ constructor_version }}.tar.gz # [win]
sha256: 787ffd85e9414bdf70fe531f01eab3987a040e3f6a6ac3a01409f4d332f7de9e # [win]
sha256: 928ddd32942093a89563ef2eb3abb116be17795cf277545ea9f6e9a0a4ba7a17 # [win]
folder: constructor_src # [win]

build:
Expand All @@ -35,7 +36,7 @@ requirements:
- python ={{ python_version }}
- conda ={{ conda_version }}
- conda-package-handling >=1.6
- menuinst >=1.4.18,<2.0a0 # [win]
- menuinst >=2.0.1
- conda-libmamba-solver ={{ conda_libmamba_solver_version }}
- libmambapy ={{ libmambapy_version }}
run_constrained:
Expand All @@ -44,6 +45,7 @@ requirements:
test:
requires:
- pytest
- menuinst >=2
source_files:
- tests
commands:
Expand Down
25 changes: 20 additions & 5 deletions src/conda.exe.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ else:

block_cipher = None
sitepackages = os.environ.get(
"SP_DIR", # site-packages in conda-build's host environment
"SP_DIR", # site-packages in conda-build's host environment
# if not defined, get running Python's site-packages
# Windows puts sys.prefix in this list first
next(
Expand All @@ -23,27 +23,42 @@ sitepackages = os.environ.get(
)
)


extra_exe_kwargs = {}
# Non imported files need to be added manually via datas or binaries:
# Datas are not analyzed, just copied over. Binaries go through some
# linkage analysis to also bring necessary libs. This includes plain
# text files like JSON, modules never imported, or standalone binaries
# Shared objects and DLLs should have been caught by pyinstaller import hooks,
# but if not, add them.
# Format: a list of tuples like (file-path, target-DIRECTORY)
binaries = []
datas = [
(os.path.join(sitepackages, 'archspec', 'json', 'COPYRIGHT'), 'archspec/json'),
(os.path.join(sitepackages, 'archspec', 'json', 'NOTICE'), 'archspec/json'),
(os.path.join(sitepackages, 'archspec', 'json', 'LICENSE-APACHE'), 'archspec/json'),
(os.path.join(sitepackages, 'archspec', 'json', 'LICENSE-MIT'), 'archspec/json'),
(os.path.join(sitepackages, 'archspec', 'json', 'cpu', 'microarchitectures.json'), 'archspec/json/cpu'),
(os.path.join(sitepackages, 'archspec', 'json', 'cpu', 'microarchitectures_schema.json'), 'archspec/json/cpu'),
(os.path.join(sitepackages, 'menuinst', 'data', 'menuinst.default.json'), 'menuinst/data'),
(os.path.join(sitepackages, 'menuinst', 'data', 'menuinst.schema.json'), 'menuinst/data'),
]
if sys.platform == "win32":
datas += [
(os.path.join(os.getcwd(), 'constructor_src', 'constructor', 'nsis', '_nsis.py'), 'Lib'),
(os.path.join(os.getcwd(), 'entry_point_base.exe'), '.')]

(os.path.join(os.getcwd(), 'entry_point_base.exe'), '.'),
]
elif sys.platform == "darwin":
datas += [
(os.path.join(sitepackages, 'menuinst', 'data', 'osx_launcher_arm64'), 'menuinst/data'),
(os.path.join(sitepackages, 'menuinst', 'data', 'osx_launcher_x86_64'), 'menuinst/data'),
(os.path.join(sitepackages, 'menuinst', 'data', 'appkit_launcher_arm64'), 'menuinst/data'),
(os.path.join(sitepackages, 'menuinst', 'data', 'appkit_launcher_x86_64'), 'menuinst/data'),
]
extra_exe_kwargs["entitlements_file"] = os.path.join(HERE, "entitlements.plist")

a = Analysis(['entry_point.py', 'imports.py'],
pathex=['.'],
binaries=[],
binaries=binaries,
datas=datas,
hiddenimports=['pkg_resources.py2_warn'],
hookspath=[],
Expand Down
33 changes: 8 additions & 25 deletions src/entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os
import sys
from multiprocessing import freeze_support
from pathlib import Path


def _create_dummy_executor(*args, **kwargs):
Expand Down Expand Up @@ -169,23 +170,12 @@ def _constructor_extract_tarball():


def _constructor_menuinst(prefix, pkg_names=None, root_prefix=None, remove=False):
import importlib.util

root_prefix = root_prefix or prefix

utility_script = os.path.join(root_prefix, "Lib", "_nsis.py")
spec = importlib.util.spec_from_file_location("constructor_utils", utility_script)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
if remove:
module.rm_menus(prefix=prefix, root_prefix=prefix)
elif pkg_names is not None:
module.mk_menus(
remove=False,
prefix=prefix,
pkg_names=pkg_names,
root_prefix=prefix,
)
from menuinst import install

for json_path in Path(prefix, "Menu").glob("*.json"):
if pkg_names and json_path.stem not in pkg_names:
continue
install(str(json_path), remove=remove, prefix=prefix, root_prefix=root_prefix)


def _constructor_subcommand():
Expand All @@ -196,9 +186,6 @@ def _constructor_subcommand():
- extract conda packages
- extract the tarball payload contained in the shell installers
- invoke menuinst to create and remove menu items on Windows
It is supported by a module included in `constructor`, `_nsis.py`, which is placed
in `$INSTDIR\Lib\_nsis.py` on Windows installations.
"""
args, _ = _constructor_parse_cli()
os.chdir(args.prefix)
Expand All @@ -212,10 +199,6 @@ def _constructor_subcommand():
# when called with --make-menus and no package names, the value is an empty list
# hence the explicit check for None
elif (args.make_menus is not None) or args.rm_menus:
if sys.platform != "win32":
raise NotImplementedError(
"Menu creation and removal is only supported on Windows"
)
_constructor_menuinst(
prefix=args.prefix,
pkg_names=args.make_menus,
Expand Down Expand Up @@ -292,7 +275,7 @@ def _conda_main():
from conda.cli import main

_fix_sys_path()
main()
return main()


def main():
Expand Down
31 changes: 30 additions & 1 deletion src/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
"conda_libmamba_solver",
"libmambapy",
]
site_packages = os.getenv("SP_DIR", site.getsitepackages()[0])
site_packages = os.environ.get(
"SP_DIR", # site-packages in conda-build's host environment
# if not defined, get running Python's site-packages
# Windows puts sys.prefix in this list first
next(
path for path in site.getsitepackages()
if path.endswith("site-packages")
)
)
files = [
f
for package in packages
Expand Down Expand Up @@ -263,7 +271,28 @@
import libmambapy.__init__
import libmambapy._version
import libmambapy.bindings
import menuinst.__init__

# import menuinst._schema
import menuinst.api
import menuinst.platforms.__init__
import menuinst.platforms.base
import menuinst.platforms.linux
import menuinst.platforms.osx
import menuinst.utils

if os.name == "nt":
import menuinst._legacy.__init__
import menuinst._legacy.cwp
import menuinst._legacy.main
import menuinst._legacy.utils
import menuinst._legacy.win32
import menuinst.platforms.win
import menuinst.platforms.win_utils.__init__
import menuinst.platforms.win_utils.knownfolders
import menuinst.platforms.win_utils.registry
import menuinst.platforms.win_utils.win_elevate
import menuinst.platforms.win_utils.winshortcut
try:
import conda_env.__main__
except Exception:
Expand Down
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pytest
menuinst>=2
Loading

0 comments on commit d06b2c7

Please sign in to comment.