Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite for cross-platform compatibility (following conda/ceps#8) #91

Merged
merged 214 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
214 commits
Select commit Hold shift + click to select a range
405643b
Start draft implementation for CEP
jaimergp Nov 3, 2021
b9efb44
rm debugging schema
jaimergp Nov 3, 2021
59dd980
add some est examples and simplify tree
jaimergp Nov 4, 2021
62dad9c
more work
jaimergp Nov 8, 2021
72c29ed
update static schema dump
jaimergp Nov 8, 2021
03b3945
add test for schema file
jaimergp Nov 8, 2021
839f89b
fix ci typo
jaimergp Nov 8, 2021
333372c
add pydantic
jaimergp Nov 8, 2021
0123b6b
fix legacy tests
jaimergp Nov 8, 2021
0eb1fd3
fix one more import
jaimergp Nov 8, 2021
587a676
use typing_extensions
jaimergp Nov 8, 2021
1071b9e
skip legacy on non-windows
jaimergp Nov 8, 2021
821d50f
underscore typo
jaimergp Nov 8, 2021
1ce9498
use conda-forge
jaimergp Nov 8, 2021
c4c79ec
supress slow warnings
jaimergp Nov 8, 2021
2f5aa2a
remove extra argument
jaimergp Nov 8, 2021
bd14d24
value must be list of int
jaimergp Nov 8, 2021
16ce913
better arguments
jaimergp Nov 8, 2021
27261e2
strip output
jaimergp Nov 8, 2021
ac3f328
restore comment
jaimergp Nov 8, 2021
15a49f0
fix start menu location on win
jaimergp Nov 8, 2021
a6b5d73
fix linux file path
jaimergp Nov 8, 2021
fddddf4
use bytes
jaimergp Nov 8, 2021
c9e5213
typo
jaimergp Nov 8, 2021
ba437fc
cmd -> command
jaimergp Nov 9, 2021
709bef5
metadata obj was simplified
jaimergp Nov 9, 2021
6d4a6e4
only merge keys if value is not None
jaimergp Nov 9, 2021
6b426a9
enable osx on example 1 too
jaimergp Nov 9, 2021
6155adf
add enabled_for_platform
jaimergp Nov 9, 2021
fbbd3e3
better merge_for_platform
jaimergp Nov 9, 2021
042a7cd
ensure all create/remove methods return list of paths
jaimergp Nov 9, 2021
1595715
fix imports and syntax
jaimergp Nov 9, 2021
47dcfa6
quote/escape windows arguments
jaimergp Nov 9, 2021
0ed345f
Menu.create returns iterables; extend instead of append
jaimergp Nov 9, 2021
b1f4c6e
strip a bit
jaimergp Nov 9, 2021
16f93b5
use right quote method
jaimergp Nov 9, 2021
a631e90
quote this too :)
jaimergp Nov 9, 2021
d3223cc
use Path internally
jaimergp Nov 9, 2021
dcaeec9
update setup
jaimergp Nov 10, 2021
531c313
one more setup update
jaimergp Nov 10, 2021
974d0ba
enable legacy only on windows
jaimergp Nov 21, 2021
da47086
add id & schema keys
jaimergp Nov 21, 2021
ae3e199
expose api module
jaimergp Nov 21, 2021
8c6eceb
fix linux filenames
jaimergp Nov 24, 2021
e9a9294
handle optional working directory and icon better in unix
jaimergp Nov 24, 2021
cedd7cf
blacken 99
jaimergp Nov 24, 2021
d9b65df
more explicit: PYTHON -> PYTHONAPP in osx
jaimergp Nov 25, 2021
fc9281e
temporarily add new cwp
jaimergp Nov 25, 2021
d0852cd
add activation mechanisms WIP
jaimergp Nov 30, 2021
4c19a74
add integration tests (WIP)
jaimergp Nov 30, 2021
743adec
fix paths
jaimergp Nov 30, 2021
5ec3a2d
fix prefix
jaimergp Nov 30, 2021
6170fbb
path this in
jaimergp Nov 30, 2021
51859b0
fix tests
jaimergp Nov 30, 2021
0721f00
more robust lib python site-packages
jaimergp Nov 30, 2021
95e4c57
no curly braces in placeholders dict
jaimergp Nov 30, 2021
ae382fb
create PREFIX/Menu if it doesn't exist
jaimergp Nov 30, 2021
915b060
more tests
jaimergp Nov 30, 2021
ff893cc
oops join paths properly
jaimergp Nov 30, 2021
ef0b979
always path
jaimergp Nov 30, 2021
38e9140
command should be single line on windows too
jaimergp Nov 30, 2021
179eeab
use conda_exe property on windows too
jaimergp Dec 1, 2021
59c1aba
fix menu attr here too
jaimergp Dec 1, 2021
f688ecf
more paths
jaimergp Dec 1, 2021
3700270
add more tests
jaimergp Dec 1, 2021
691651e
do not use shell on windows test (it's preactivated :D)
jaimergp Dec 1, 2021
122ba9d
try explicit call to cmd
jaimergp Dec 1, 2021
cdecfd8
fix windows
jaimergp Dec 1, 2021
674818d
make remove return paths too
jaimergp Dec 1, 2021
44a74a4
some more logging
jaimergp Dec 1, 2021
e3a4f7b
strip != replace
jaimergp Dec 1, 2021
8300109
pre-deactivate env on windows for cleaner output?
jaimergp Dec 1, 2021
c78a6f7
moar deactivate
jaimergp Dec 1, 2021
6cd01ce
support micromamba activation
jaimergp Dec 1, 2021
ff1bdb3
provide _paths() in all platforms
jaimergp Dec 8, 2021
6628a2d
consistent site_packages detection
jaimergp Dec 8, 2021
f382d70
fix artifact removal tests (osx at least)
jaimergp Dec 8, 2021
9e45448
check if xml is restored on Linux
jaimergp Dec 8, 2021
64182e9
add _paths() to menu in windows too
jaimergp Dec 8, 2021
0cf3c28
cleanup
jaimergp Dec 8, 2021
cf786da
escape with single quotes
jaimergp Dec 8, 2021
a3c094e
allow sys.executable to be a conda exe candidate
jaimergp Dec 9, 2021
214c108
expose CFBundleName
jaimergp Dec 9, 2021
dfda296
allow parent menu dir to exist on windows
jaimergp Dec 9, 2021
0ae7319
fix launcher scripts on windows
jaimergp Dec 9, 2021
0092ff0
fix tests a bit
jaimergp Dec 9, 2021
88a1ab2
and one more fix :)
jaimergp Dec 9, 2021
eee46d1
support some CoreFoundation keys on mac
jaimergp Dec 9, 2021
da54e4e
try with more explicit powershell path
jaimergp Dec 9, 2021
929a356
blacken
jaimergp Dec 9, 2021
ec0c880
add terminal option for both linux and windows (replaces Windows' no_…
jaimergp Dec 19, 2021
bbdec08
ensure xdg lists end in semicolon
jaimergp Dec 19, 2021
c0c0e09
fix name rendering in linux directories
jaimergp Dec 19, 2021
cc1c417
update json schema
jaimergp Dec 19, 2021
b3efb86
fix bash calls in linux shortcuts
jaimergp Dec 19, 2021
7f9f87d
raise test errors on env removal too
jaimergp Dec 19, 2021
a907d45
test artifact removal more throroughly
jaimergp Dec 19, 2021
eb0b0d1
fix linux menu removal
jaimergp Dec 19, 2021
dfd85cc
use double quotes on unix
jaimergp Dec 19, 2021
ab343a8
create system directories on windows tests
jaimergp Dec 19, 2021
592b88b
use pathlib
jaimergp Dec 19, 2021
05ff503
fix original xml linux tests?
jaimergp Dec 19, 2021
7d7d12c
missing_ok is not available in py36; use a util function for that
jaimergp Dec 19, 2021
594d642
setting CFBundleVersion also changes CFBundleShortVersionString, CFBu…
jaimergp Dec 19, 2021
1f869b2
make sure linux booleans are lowercase
jaimergp Feb 27, 2022
93e09c9
exclude tests
jaimergp Feb 27, 2022
b3ae77f
do not depend on pydantic at runtime
jaimergp Mar 11, 2022
75eb061
fix import
jaimergp Mar 12, 2022
81c0a96
more pydantic-less progress
jaimergp Mar 12, 2022
e8ee3af
use deep updates
jaimergp Mar 24, 2022
1e9bb50
add tests to ensure data files are up to date with code
jaimergp Mar 24, 2022
f7639ec
update tests a bit
jaimergp Mar 24, 2022
465e87c
soft import
jaimergp Mar 24, 2022
c380713
Merge remote-tracking branch 'upstream/main' into cep
jaimergp Sep 19, 2022
5e2cbfb
no channel notices
jaimergp Sep 19, 2022
33d0a20
quote py versions
jaimergp Sep 19, 2022
31736a1
switch to cpp driven shortcut creation on windows, with elevation
jaimergp Sep 20, 2022
e91a9cc
safeguard Literal imports
jaimergp Sep 20, 2022
890aa0d
import Pathlike from os
jaimergp Sep 20, 2022
a3c57ad
fix import
jaimergp Sep 20, 2022
84379fd
mark some tests as pydantic too
jaimergp Sep 20, 2022
19ef9af
one more
jaimergp Sep 20, 2022
65d4a39
verbose install
jaimergp Sep 20, 2022
e50882c
rm versioneer
jaimergp Sep 23, 2022
e86887e
use pyproject.toml with setuptools-scm
jaimergp Sep 23, 2022
679b538
mark the file
jaimergp Sep 23, 2022
4702874
remove mark
jaimergp Sep 23, 2022
94c6189
force keyword only for some args
jaimergp Sep 26, 2022
1b22ceb
bring conda from PR channel
jaimergp Sep 26, 2022
2881742
use dual api
jaimergp Sep 26, 2022
042a7d2
add conda as explicit dependency from dev channel
jaimergp Sep 27, 2022
465f8d2
bring that one from conda-forge
jaimergp Sep 27, 2022
b064324
and this one too
jaimergp Sep 27, 2022
b7f380e
use conda-forge for everything?
jaimergp Sep 27, 2022
4b726ef
be nicer to ci resources
jaimergp Sep 27, 2022
149a3f0
check for quick_launch location
jaimergp Sep 27, 2022
1659659
positional args only
jaimergp Sep 27, 2022
4ee128c
handle deprecation warnings
jaimergp Sep 27, 2022
6ccfd0f
exclude some more stuff
jaimergp Sep 27, 2022
85acdd5
do not use deprecated c function
jaimergp Sep 27, 2022
59e67a5
use setuptools defaults
jaimergp Sep 27, 2022
f465415
enforce conda-forge for py310 issues?
jaimergp Sep 27, 2022
9480695
try again?
jaimergp Sep 27, 2022
5ba10c2
try provision-with-micromamba
jaimergp Sep 27, 2022
b0c33b2
add dev channel
jaimergp Sep 27, 2022
fbe2364
this step is not needed anymore
jaimergp Sep 27, 2022
d1c9cd0
maybe defaults helps with py310 now?
jaimergp Sep 27, 2022
29da7e2
nah it doesn't, revert
jaimergp Sep 27, 2022
5a6dae2
move windows C++ stuff
jaimergp Oct 30, 2022
9aaf2df
add C launcher for macos
jaimergp Oct 30, 2022
a474847
add compiled launchers
jaimergp Oct 30, 2022
e934bae
use python -m
jaimergp Oct 30, 2022
27e24c8
also for conda
jaimergp Oct 30, 2022
10845a4
use new binary launcher in osx
jaimergp Oct 31, 2022
1d997d3
drop py37
jaimergp Oct 31, 2022
7c7c6d9
fix test
jaimergp Oct 31, 2022
c22050d
fix packaging
jaimergp Oct 31, 2022
8ab5650
add macos plist keys
jaimergp Oct 31, 2022
d7ddd28
implement terminal on osx
jaimergp Oct 31, 2022
792fce6
regenerate json schemas
jaimergp Oct 31, 2022
53c68ea
too soon for 311
jaimergp Oct 31, 2022
c0780da
do not use importlib resources yet
jaimergp Oct 31, 2022
7ac280d
use -I to prevent local menuinst from being loaded
jaimergp Oct 31, 2022
b1a9444
it's ok if we couldn't clean up
jaimergp Oct 31, 2022
3234061
more robust slugs
jaimergp Nov 3, 2022
59bd104
refactor elevation and add unix support
jaimergp Nov 3, 2022
b6a5bf9
self-sign resulting shortcuts in osx if entitlements are provided
jaimergp Nov 18, 2022
a9b4341
support both conda.exe and _conda.exe names
jaimergp Nov 18, 2022
bd23bde
debugging typo
jaimergp Nov 18, 2022
f3c8373
add precommands
jaimergp Nov 18, 2022
95cd56a
test precommands and entitlements
jaimergp Nov 21, 2022
160ff04
one more test
jaimergp Nov 21, 2022
a3bc232
test fixes
jaimergp Nov 21, 2022
4f9d4ed
skip some tests if not on macos
jaimergp Nov 21, 2022
8774228
use fixture again
jaimergp Nov 21, 2022
d6840b5
do not nest context managers
jaimergp Nov 21, 2022
ce4982d
output to env defined file
jaimergp Nov 21, 2022
8e67aa7
env vars are not passed?
jaimergp Nov 21, 2022
dcc6518
try another syntax
jaimergp Nov 21, 2022
5555e04
try with templating?
jaimergp Nov 21, 2022
c2550f3
open in text mode
jaimergp Nov 21, 2022
e5f211b
escape backslashes
jaimergp Nov 21, 2022
4d527ae
debug
jaimergp Nov 21, 2022
f144f1e
hopefully this fix is enough
jaimergp Nov 21, 2022
b096c8f
resolve before comparing
jaimergp Nov 21, 2022
7c06ca4
remove warnings for raw regex
jaimergp Nov 21, 2022
88a3a85
add launchers to manifest
jaimergp Nov 21, 2022
c5b2722
test prefix instead?
jaimergp Nov 21, 2022
bb9f887
do not assume `python` location, use sys.executable
jaimergp Nov 22, 2022
2c873f0
better handling of target and base prefixes
jaimergp Nov 23, 2022
387002f
disable elevation for now
jaimergp Nov 23, 2022
6ea23c4
undo
jaimergp Nov 23, 2022
787fc01
fetch all commits
jaimergp Dec 6, 2022
c1c7340
remove unused import
jaimergp Dec 6, 2022
e6cc68a
mock instead temporary env vars
jaimergp Dec 7, 2022
78238a6
handle escapes with python?
jaimergp Dec 7, 2022
4e569c6
support the python interface in conda-standalone
jaimergp Dec 7, 2022
f9e5238
handle kwargs = None differently
jaimergp Dec 7, 2022
e7772c8
some logic to find the best executable for the relaunch
jaimergp Dec 8, 2022
e820413
one less line
jaimergp Dec 8, 2022
3f52ba3
do not use /K on win tests (it blocks test!)
jaimergp Dec 22, 2022
b7436f1
regenerate test package
jaimergp Dec 22, 2022
849938c
fix LSEnvironment serialization and unwanted presence of entitlements…
jaimergp Dec 22, 2022
da16f43
add preinstall and link_in_bundle implementations (draft)
jaimergp Dec 30, 2022
dc295a9
add typings to non-legacy parts
jaimergp Dec 30, 2022
d0525f2
sync schemas
jaimergp Dec 31, 2022
062999c
update docs for schema and refine validation on osx
jaimergp Dec 31, 2022
863dfdf
add tests for symlinks
jaimergp Dec 31, 2022
b7fce96
always define MenuItem.location as property
jaimergp Dec 31, 2022
b8b26a5
avoid recursion
jaimergp Dec 31, 2022
3945fb0
avoid recursion but better
jaimergp Dec 31, 2022
e423f8f
one more fix for linux
jaimergp Dec 31, 2022
efe63c5
Path.is_relative_to() is only available on Python 3.9+
jaimergp Dec 31, 2022
324250b
fix kwargs on windows
jaimergp Dec 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 40 additions & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,70 @@
name: Tests

on: [push, pull_request]
on:
push:
branches:
- main
pull_request:

concurrency:
# Concurrency group that uses the workflow name and PR number if available
# or commit SHA as a fallback. If a new build is triggered under that
# concurrency group while a previous build is running it will be canceled.
# Repeated pushes to a PR will cancel all previous builds, while multiple
# merges to main will not cancel.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
run_test_suite:
name: ${{ matrix.os }}-py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 30
env:
test-dependencies: pytest pytest-cov conda
CONDA_NUMBER_CHANNEL_NOTICES: 0
strategy:
fail-fast: false
matrix:
os: [windows]
python-version: [3.7, 3.8, 3.9]
os: [windows, ubuntu, macos]
python-version: ["3.8", "3.9", "3.10",] # "3.11"]

steps:
- uses: actions/checkout@v2

- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
fetch-depth: 0

- name: Install dependencies
uses: mamba-org/provision-with-micromamba@main
with:
environment-file: false
environment-name: test
channels: conda-canary/label/conda-conda-pr-11882,conda-forge
extra-specs: |
python=${{ matrix.python-version }}
conda-canary/label/conda-conda-pr-11882::conda
pip
pytest
pytest-cov
pydantic
hypothesis
hypothesis-jsonschema

- shell: bash -l {0}
- shell: bash -el {0}
name: Conda info
run: |
conda info
conda list

- shell: bash -l {0}
name: Install dependencies
run: |
conda install ${{ env.dependencies }} ${{ env.test-dependencies }}
conda list

- shell: bash -l {0}
- shell: bash -el {0}
name: Install menuinst
run: |
pip install -e .
python -m pip install -vv .
conda list

- shell: bash -l {0}
- shell: bash -el {0}
name: Run test suite
run: |
pytest tests --cov-append --cov-report=xml --cov=menuinst
python -I -m pytest tests/ --cov-append --cov-report=xml --cov=menuinst

- uses: codecov/codecov-action@v1
with:
Expand Down
148 changes: 141 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,144 @@
# file types to ignore
*.pyc
*.pyd
*~
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# ignore the build directories
*.egg-info/
# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
.cache/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# MacOS
.DS_Store

# setuptools-scm
menuinst/_version.py
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
include versioneer.py
include menuinst/_version.py
include menuinst/data/*.json
include menuinst/data/osx_launcher_*
exclude *.h *.cpp
7 changes: 0 additions & 7 deletions TODO.txt

This file was deleted.

41 changes: 29 additions & 12 deletions cwp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,43 @@
import sys
import subprocess
from os.path import join, pathsep
import argparse

from menuinst.knownfolders import FOLDERID, get_folder_path, PathNotFoundException
from menuinst._legacy.knownfolders import FOLDERID, get_folder_path

# call as: python cwp.py PREFIX ARGs...
# call as: python cwp.py [--no-console] PREFIX ARGs...
parser = argparse.ArgumentParser()
parser.add_argument(
"--no-console", action="store_true", help="Create subprocess with CREATE_NO_WINDOW flag."
)
parser.add_argument("prefix", help="Prefix to be 'activated' before calling `args`.")
parser.add_argument("args", nargs="*", help="Command (and arguments) to be executed.")
parsed_args = parser.parse_args()

prefix = sys.argv[1]
args = sys.argv[2:]
no_console = parsed_args.no_console
prefix = parsed_args.prefix
args = parsed_args.args

new_paths = pathsep.join([prefix,
join(prefix, "Library", "mingw-w64", "bin"),
join(prefix, "Library", "usr", "bin"),
join(prefix, "Library", "bin"),
join(prefix, "Scripts")])
new_paths = pathsep.join(
[
prefix,
join(prefix, "Library", "mingw-w64", "bin"),
join(prefix, "Library", "usr", "bin"),
join(prefix, "Library", "bin"),
join(prefix, "Scripts"),
]
)
env = os.environ.copy()
env['PATH'] = new_paths + pathsep + env['PATH']
env['CONDA_PREFIX'] = prefix
env["PATH"] = new_paths + pathsep + env["PATH"]
env["CONDA_PREFIX"] = prefix

documents_folder, exception = get_folder_path(FOLDERID.Documents)
if exception:
documents_folder, exception = get_folder_path(FOLDERID.PublicDocuments)
if not exception:
os.chdir(documents_folder)
sys.exit(subprocess.call(args, env=env))

creationflags = {}
if no_console:
creationflags["creationflags"] = getattr(subprocess, "CREATE_NO_WINDOW", 0x08000000)
sys.exit(subprocess.call(args, env=env, **creationflags))
Binary file removed menuinst/PythonApplet.icns
Binary file not shown.
Loading