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.25 #19

Merged
merged 9 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ tests/cli/data/chpok
tests/cli/data/pok
.idea
.ruff_cache
.mutmut-cache
html
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![Downloads](https://static.pepy.tech/badge/instld/month)](https://pepy.tech/project/instld)
[![Downloads](https://static.pepy.tech/badge/instld)](https://pepy.tech/project/instld)
[![codecov](https://codecov.io/gh/pomponchik/instld/graph/badge.svg?token=XuhCNeksjG)](https://codecov.io/gh/pomponchik/instld)
[![Lines of code](https://sloc.xyz/github/pomponchik/instld/?category=code)](https://github.com/boyter/scc/)
[![Hits-of-Code](https://hitsofcode.com/github/pomponchik/instld?branch=main)](https://hitsofcode.com/github/pomponchik/instld/view?branch=main)
[![Tests](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)
Expand Down
Binary file added docs/assets/console_record.mov
Binary file not shown.
Binary file added docs/assets/console_record_2.mov
Binary file not shown.
Binary file added docs/assets/presentation_2.pptx
Binary file not shown.
Binary file added docs/assets/terminal_2.gif
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/terminal_3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 2 additions & 40 deletions docs/texts/habr/first_article.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,3 @@
# Вы все еще ставите пакеты? Тогда мы идем к вам
# INSTLD и будущее пакетных менеджеров


Пакетный менеджер и связанный с ним тулинг - это очень часто штука, стоящая в основе инфраструктуры вокруг популярного современного языка. Требования к нему обычно довольно понятны: он должен давать возможность быстро собрать большой проект из кучи готовых компонентов. В Python с этим все немного неоднозначно. У нас есть стандартный pip, которого хватает для большинства ситуаций. Есть всякие замудренные решения вроде poetry для умных дядек, которые любят выступать на конференциях. Но увы, пока в Python не завезли чего-то настолько простого, чтобы вот прямо написал import в своем коде - и готово. Я решил это исправить.

Расписать: я решил принести в Python немного магии.

Данная статья посвящена библиотеке [instld](https://github.com/pomponchik/instld), которая позволяет вам:

1. В принципе отказаться от такого шага, как установка библиотек.
2. Использовать в одной программе более одного виртуального окружения.
3. Использовать в одной программе несколько версий одной и той же библиотеки.
4. Затащить в свою программу несколько библиотек с конфликтующими зависимостями, которые обычно не получается даже установить одновременно.
5. Определять, какие библиотеки реально используются в проекте, а какие нет.

Установить ее можно командой:

```bash
pip install instld
```

Я предполагаю, что основная ЦА библиотеки - это люди, которые часто пишут скрипты одноразового запуска, например админы. Однако про ее возможности полезно знать всем питонистам, поскольку ситуации, когда нам может понадобиться что-то из перечисленного выше, случаются практически у каждого. Короче, поехали.


## Автоматическая установка пакетов















![Когда выбрал instld](https://disabilitylawfirms.org/files/2019/09/AdobeStock_279551710.jpg)
Год от года программы продолжают раздуваться. На хабре уже есть тысячи обличительных статей на эту тему, но что, если мы перестанем с этим бороться, примем неизбежное и начнем получать удовольствие?
2 changes: 1 addition & 1 deletion instld/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def push(self, line):

else:
builtins.__import__ = import_wrapper
spec = importlib.util.spec_from_file_location('kek', os.path.abspath(python_file))
spec = importlib.util.spec_from_file_location('__main__', os.path.abspath(python_file))
module = importlib.util.module_from_spec(spec)
sys.modules['__main__'] = module
if sys.platform.lower() in ('win32',):
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = 'setuptools.build_meta'

[project]
name = 'instld'
version = '0.0.24'
version = '0.0.25'
authors = [
{ name='Evgeniy Blinov', email='zheni-b@yandex.ru' },
]
Expand Down Expand Up @@ -33,6 +33,10 @@ classifiers = [
[project.scripts]
instld = 'instld.cli.main:main'

[tool.mutmut]
paths_to_mutate="instld"
runner="pytest"

[project.urls]
'Source' = 'https://github.com/pomponchik/instld'
'Tracker' = 'https://github.com/pomponchik/instld/issues'
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ pytest-timeout==2.1.0
contextif==0.0.3
ruff==0.0.290
pre-commit
mutmut==2.4.4
19 changes: 19 additions & 0 deletions tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,22 @@ def test_install_package_from_another_repository_only_command():


os.remove(script)


def test_run_script_and_check_the___name__():
strings = [
'print(__name__)',
]

script = os.path.join('tests', 'cli', 'data', 'main.py')
with open(script, 'w') as file:
file.write('\n'.join(strings))

for runner in (subprocess.run,):
result = runner(['instld', script], stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=100, universal_newlines=True)

result.check_returncode()

assert result.stdout == '__main__\n'

os.remove(script)
Loading