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

0.0.23 #12

Merged
merged 35 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
33b6e8c
logos
pomponchik Nov 13, 2023
32c0e98
new logo
pomponchik Nov 13, 2023
bccfe9c
assets
pomponchik Nov 13, 2023
4a6da15
ruff as a dependency
pomponchik Nov 13, 2023
6188c55
trash file
pomponchik Nov 13, 2023
b78c786
pre-commit
pomponchik Nov 16, 2023
39eee5a
pre-commit
pomponchik Nov 16, 2023
b88ff65
pre-commit
pomponchik Nov 16, 2023
9de8112
pre-commit
pomponchik Nov 16, 2023
1cf1085
ruff + a pre-commit hook
pomponchik Nov 17, 2023
c298653
ruff in the CI
pomponchik Nov 17, 2023
9b7da60
pre-commit library version
pomponchik Nov 17, 2023
3c4d68c
ruff badge in the readme
pomponchik Nov 17, 2023
7bd066e
readme
pomponchik Nov 17, 2023
9d411c0
pyproject.toml file has added
pomponchik Nov 17, 2023
3021192
setup.py has deleted
pomponchik Nov 17, 2023
9b626f9
import fix
pomponchik Nov 17, 2023
d45599e
prints
pomponchik Nov 17, 2023
fd2ac09
maybe fix?
pomponchik Nov 20, 2023
c3fb449
fixed tests
pomponchik Nov 20, 2023
e67aa68
fixed tests
pomponchik Nov 20, 2023
4f533eb
prints
pomponchik Nov 20, 2023
998a21c
a new test (skipped still)
pomponchik Nov 20, 2023
2226453
cutting trace size
pomponchik Nov 26, 2023
923009c
cutting trace size
pomponchik Nov 26, 2023
9204e3f
cutting trace size
pomponchik Nov 26, 2023
ac9db1f
cutting trace size
pomponchik Nov 26, 2023
ae851cc
cutting trace size
pomponchik Nov 26, 2023
35587fb
cutting trace size
pomponchik Nov 26, 2023
ba0c651
python 3.12 in the CI
pomponchik Nov 26, 2023
162976c
no prints
pomponchik Nov 28, 2023
32f522a
no prints
pomponchik Nov 28, 2023
f7ac335
docstring
pomponchik Nov 28, 2023
df479bc
a new version tag
pomponchik Nov 28, 2023
d95be80
classifiers
pomponchik Nov 28, 2023
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
28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint

on:
push

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7']

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
shell: bash
run: pip install -r requirements_dev.txt

- name: Run ruff
shell: bash
run: ruff instld
4 changes: 2 additions & 2 deletions .github/workflows/tests_and_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
Expand All @@ -25,7 +25,7 @@ jobs:

- name: Install the library
shell: bash
run: python setup.py install
run: pip install .

- name: Print all libs
shell: bash
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ test.py
tests/cli/data/chpok
tests/cli/data/pok
.idea
.ruff_cache
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.290
hooks:
# Run the linter.
- id: ruff
args: [ instld ]
1 change: 1 addition & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore = ['E501', 'E712']
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![logo](https://raw.githubusercontent.com/pomponchik/instld/main/docs/assets/logo5.png)
![logo](https://raw.githubusercontent.com/pomponchik/instld/main/docs/assets/logo_5.png)

# INSTLD: the simplest package management

Expand All @@ -8,9 +8,11 @@
[![Test-Package](https://github.com/pomponchik/instld/actions/workflows/tests_and_coverage.yml/badge.svg)](https://github.com/pomponchik/instld/actions/workflows/tests_and_coverage.yml)
[![Python versions](https://img.shields.io/pypi/pyversions/instld.svg)](https://pypi.python.org/pypi/instld)
[![PyPI version](https://badge.fury.io/py/instld.svg)](https://badge.fury.io/py/instld)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

Thanks to this package, it is very easy to manage the lifecycle of packages.

- ⚡ Run your code without installing libraries.
- ⚡ You can use 2 different versions of the same library in the same program.
- ⚡ You can use incompatible libraries in the same project, as well as libraries with incompatible/conflicting dependencies.
- ⚡ It's easy to share written scripts. The script file becomes self-sufficient - the user does not need to install the necessary libraries.
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
Binary file added docs/assets/logo_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/presentation.pptx
Binary file not shown.
Binary file added docs/assets/terminal.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 9 additions & 5 deletions instld/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import code
import builtins
import importlib
import importlib.util
import inspect
from contextlib import contextmanager
from tempfile import TemporaryDirectory
from threading import RLock

import instld
Expand Down Expand Up @@ -74,7 +74,7 @@
with set_import():
try:
result = __import__(name, *args, **kwargs)
except (ModuleNotFoundError, ImportError) as e:
except (ModuleNotFoundError, ImportError):
current_context.install(package_name, catch_output=catch_output, **options)
result = current_context.import_here(base_name)
sys.modules[base_name] = result
Expand All @@ -92,7 +92,7 @@

if python_file is None:
try:
import readline
import readline # noqa: F401

Check warning on line 95 in instld/cli/main.py

View check run for this annotation

Codecov / codecov/patch

instld/cli/main.py#L95

Added line #L95 was not covered by tests
except ImportError:
pass

Expand Down Expand Up @@ -120,9 +120,13 @@
spec = importlib.util.spec_from_file_location('kek', os.path.abspath(python_file))
module = importlib.util.module_from_spec(spec)
sys.modules['__main__'] = module
set_cutting_excepthook(4)
if sys.platform.lower() in ('win32',):
cutting_trace_size = 4

Check warning on line 124 in instld/cli/main.py

View check run for this annotation

Codecov / codecov/patch

instld/cli/main.py#L124

Added line #L124 was not covered by tests
else:
cutting_trace_size = 4
set_cutting_excepthook(cutting_trace_size)
spec.loader.exec_module(module)


if __name__ == "__main__":
start()
main()

Check warning on line 132 in instld/cli/main.py

View check run for this annotation

Codecov / codecov/patch

instld/cli/main.py#L132

Added line #L132 was not covered by tests
1 change: 0 additions & 1 deletion instld/cli/parsing_arguments/get_python_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import sys


Expand Down
6 changes: 2 additions & 4 deletions instld/cli/traceback_cutting/cutting.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import io
import os
import sys
import traceback
from contextlib import redirect_stderr

from instld.cli.traceback_cutting.traceback_utils import cut_base_of_traceback
from instld.cli.traceback_cutting.traceback_utils import cut_base_of_traceback, cut_importlib_bug


def create_cutting_excepthook(old_hook, base_size):
def new_hook(exc_type, value, traceback_object):
traceback_object = cut_base_of_traceback(traceback_object, base_size)
traceback_object = cut_importlib_bug(traceback_object)
traceback.print_exception(exc_type, value, traceback_object)
return new_hook

Expand Down
15 changes: 15 additions & 0 deletions instld/cli/traceback_cutting/traceback_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,18 @@
return traceback_object
index += 1
traceback_object = traceback_object.tb_next


def cut_importlib_bug(traceback_object):
"""
This function fix the truble, that occurs only for windows.

See: https://github.com/pomponchik/instld/actions/runs/6997770395
"""
try:
while traceback_object is not None:
if not (traceback_object.tb_frame.f_code.co_filename == '<frozen importlib._bootstrap>' or traceback_object.tb_frame.f_code.co_filename == '<frozen importlib._bootstrap_external>'):
return traceback_object
traceback_object = traceback_object.tb_next
except AttributeError:
return traceback_object

Check warning on line 30 in instld/cli/traceback_cutting/traceback_utils.py

View check run for this annotation

Codecov / codecov/patch

instld/cli/traceback_cutting/traceback_utils.py#L28-L30

Added lines #L28 - L30 were not covered by tests
2 changes: 1 addition & 1 deletion instld/module/command_executer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from threading import Thread, Lock
from subprocess import Popen, PIPE, CalledProcessError
from subprocess import Popen, PIPE

from instld.module.empty_logger import EmptyLogger
from instld.errors import RestartingCommandError, RunningCommandError
Expand Down
4 changes: 1 addition & 3 deletions instld/module/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def new_path(self, module_name):
old_path = sys.path
sys.path = [self.where] + copy.copy(self.original_path)
if module_name in sys.modules:
old_module = sys.modules.pop(module_name)
else:
old_module = None
sys.modules.pop(module_name)
yield
sys.path = old_path

Expand Down
3 changes: 0 additions & 3 deletions instld/module/context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import tempfile
from functools import partial

from io import StringIO
from contextlib import contextmanager

from instld.errors import InstallingPackageError, RunningCommandError
Expand Down Expand Up @@ -52,8 +51,6 @@ def create_temp_directory():
new_error = InstallingPackageError(f'{str(e)} It occurred when installing one of the following packages: {", ".join(packages_names)}.')
new_error.stdout = e.stdout
new_error.stderr = e.stderr
#print('STDOUT', e.stdout)
#print('STDERR', e.stderr)
raise new_error from e

yield Context(where, logger, catch_output, options, partial(pip_context, logger=logger, runner=runner, catch_output=catch_output, where=directory))
2 changes: 2 additions & 0 deletions pre-commit_activate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Run it after the first clone of the repo.
pre-commit install
38 changes: 38 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[build-system]
requires = ['setuptools==68.0.0']
build-backend = 'setuptools.build_meta'

[project]
name = 'instld'
version = '0.0.23'
authors = [
{ name='Evgeniy Blinov', email='zheni-b@yandex.ru' },
]
description = 'The simplest package management'
readme = 'README.md'
requires-python = '>=3.7'
classifiers = [
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'License :: OSI Approved :: MIT License',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Interpreters',
'Topic :: Utilities',
'Topic :: System :: Archiving :: Packaging',
'Intended Audience :: System Administrators',
'Intended Audience :: Developers',
]

[project.scripts]
instld = 'instld.cli.main:main'

[project.urls]
'Source' = 'https://github.com/pomponchik/instld'
'Tracker' = 'https://github.com/pomponchik/instld/issues'
3 changes: 3 additions & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
pytest==7.4.1
coverage==7.2.7
twine==4.0.2
build==0.9.0
wheel==0.40.0
pytest-timeout==2.1.0
contextif==0.0.3
ruff==0.0.290
pre-commit
42 changes: 0 additions & 42 deletions setup.py

This file was deleted.

3 changes: 1 addition & 2 deletions tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import shutil

import pytest
from contextif import state


@pytest.mark.timeout(180)
Expand All @@ -14,7 +13,7 @@ def test_cli_where(main_runner):
rf'import is_odd # instld: where {os.path.join("tests", "cli", "data", "pok")}',
rf'import is_even # instld: where {os.path.join("tests", "cli", "data", "chpok")}',
'assert is_odd.valid(23)',
'assert is_even.isEven(1)',
'assert is_even.is_even(2)',
]

script = os.path.join('tests', 'cli', 'data', 'main.py')
Expand Down
17 changes: 14 additions & 3 deletions tests/units/cli/parsing_comments/test_get_options_from_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,24 @@ def test_get_normal_options():
assert options['cheburek'] == 'mek'


# TODO: fix it!
@pytest.mark.skip("I'll fix it later.")
def test_real_options():
options = get_options_from_comments_by_frame(inspect.currentframe()) # instld: where tests/cli/data/pok, version 1.0.4

assert options == {
'where': 'tests/cli/data/pok',
'version': '1.0.4',
}


def test_get_wrong_options():
with pytest.raises(InstallingPackageError):
options = get_options_from_comments_by_frame(inspect.currentframe()) # instld: lol kek cheburek, cheburek mek
get_options_from_comments_by_frame(inspect.currentframe()) # instld: lol kek cheburek, cheburek mek
with pytest.raises(InstallingPackageError):
options = get_options_from_comments_by_frame(inspect.currentframe()) # instld: lol
get_options_from_comments_by_frame(inspect.currentframe()) # instld: lol
with pytest.raises(InstallingPackageError):
options = get_options_from_comments_by_frame(inspect.currentframe()) # instld:
get_options_from_comments_by_frame(inspect.currentframe()) # instld:


def test_get_empty_options():
Expand Down
Loading