Skip to content

Commit 74627e7

Browse files
authored
IP-5090: [python-dependency-injector] 프로젝트 관리 도구를 poetry로 변경 (#2)
1 parent 50c9258 commit 74627e7

22 files changed

+9698
-9897
lines changed

.deepsource.toml

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish package
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: 3.11
16+
- name: Run image
17+
uses: abatilo/actions-poetry@v2
18+
with:
19+
poetry-version: 1.8
20+
- name: Publish package
21+
env:
22+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
23+
run: |
24+
poetry config pypi-token.pypi $PYPI_TOKEN
25+
poetry publish --build

.github/workflows/publishing.yml

Lines changed: 0 additions & 125 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,39 @@ jobs:
1616
- 3.12
1717
steps:
1818
- uses: actions/checkout@v4
19-
- uses: actions/cache@v4
20-
with:
21-
path: ~/eggs
22-
key: ${{ runner.os }}-eggs-${{ matrix.python-version }}-${{ hashFiles('*cfg') }}
23-
restore-keys: |
24-
${{ runner.os }}-eggs-${{ matrix.python-version }}-
25-
- uses: actions/setup-python@v5
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
id: setup-python
2623
with:
2724
python-version: ${{ matrix.python-version }}
28-
- run: pip install tox
29-
- run: tox
30-
env:
31-
TOXENV: ${{ matrix.python-version }}
25+
cache: pip
26+
27+
- name: Load cached poetry installation
28+
uses: actions/cache@v4
29+
with:
30+
path: ~/.local
31+
key: poetry-${{ steps.setup-python.outputs.python-version }}
32+
33+
- name: Install Poetry
34+
uses: snok/install-poetry@v1
35+
with:
36+
virtualenvs-create: true
37+
virtualenvs-in-project: true
38+
installer-parallel: true
39+
40+
- name: Load cached venv
41+
id: cached-poetry-dependencies
42+
uses: actions/cache@v4
43+
with:
44+
path: .venv
45+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
46+
47+
- name: Install dependencies
48+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
49+
shell: bash
50+
run: poetry install
51+
52+
- name: Run tests
53+
run: |
54+
poetry run pytest -vv -s tests

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,4 @@ src/dependency_injector/providers/*.so
7575
.workspace/
7676
.venv
7777
.DS_Store
78+
tmp*

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
default_language_version:
2+
python: python3.11
3+
repos:
4+
- repo: https://github.com/astral-sh/ruff-pre-commit
5+
rev: v0.4.10
6+
hooks:
7+
- id: ruff
8+
args: [--fix]
9+
- id: ruff-format
10+
- repo: https://github.com/python-poetry/poetry
11+
rev: 1.8.3
12+
hooks:
13+
- id: poetry-check
14+
- id: poetry-lock
15+
args: [--no-update]

.pylintrc

Lines changed: 0 additions & 49 deletions
This file was deleted.

Makefile

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ VERSION := $(shell python setup.py --version)
22

33
CYTHON_SRC := $(shell find src/dependency_injector -name '*.pyx')
44

5-
CYTHON_DIRECTIVES = -Xlanguage_level=2
5+
CYTHON_DIRECTIVES = -Xlanguage_level=3
66

77
ifdef DEPENDENCY_INJECTOR_DEBUG_MODE
88
CYTHON_DIRECTIVES += -Xprofile=True
@@ -26,15 +26,10 @@ clean:
2626
find examples -name '__pycache__' -delete
2727

2828
cythonize:
29-
# Compile Cython to C
30-
cython -a $(CYTHON_DIRECTIVES) $(CYTHON_SRC)
31-
# Move all Cython html reports
32-
mkdir -p reports/cython/
33-
find src -name '*.html' -exec mv {} reports/cython/ \;
29+
cython $(CYTHON_DIRECTIVES) $(CYTHON_SRC)
3430

3531
build: clean cythonize
36-
# Compile C extensions
37-
python setup.py build_ext --inplace
32+
poetry build
3833

3934
docs-live:
4035
sphinx-autobuild docs docs/_build/html
@@ -51,27 +46,3 @@ test:
5146
coverage run --rcfile=./.coveragerc -m pytest -c tests/.configs/pytest.ini
5247
coverage report --rcfile=./.coveragerc
5348
coverage html --rcfile=./.coveragerc
54-
55-
check:
56-
flake8 src/dependency_injector/
57-
flake8 examples/
58-
59-
pydocstyle src/dependency_injector/
60-
pydocstyle examples/
61-
62-
mypy tests/typing
63-
64-
test-publish: cythonize
65-
# Create distributions
66-
python setup.py sdist
67-
# Upload distributions to PyPI
68-
twine upload --repository testpypi dist/dependency-injector-$(VERSION)*
69-
70-
publish:
71-
# Merge release to master branch
72-
git checkout master
73-
git merge --no-ff release/$(VERSION) -m "Merge branch 'release/$(VERSION)' into master"
74-
git push origin master
75-
# Create and upload tag
76-
git tag -a $(VERSION) -m 'version $(VERSION)'
77-
git push --tags

build.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import shutil
2+
from pathlib import Path
3+
from typing import Any
4+
5+
from setuptools import Distribution, Extension
6+
from setuptools.command.build_ext import build_ext
7+
8+
SOURCE_DIR = Path("src", "dependency_injector")
9+
10+
11+
EXTENSIONS = [
12+
Extension(
13+
"dependency_injector.containers",
14+
[str(SOURCE_DIR.joinpath("containers.c"))],
15+
extra_compile_args=["-O3"],
16+
),
17+
Extension(
18+
"dependency_injector.providers",
19+
[str(SOURCE_DIR.joinpath("providers.c"))],
20+
extra_compile_args=["-O3"],
21+
),
22+
Extension(
23+
"dependency_injector._cwiring",
24+
[str(SOURCE_DIR.joinpath("_cwiring.c"))],
25+
extra_compile_args=["-O3"],
26+
),
27+
]
28+
29+
30+
def build(setup_kwargs: dict[str, Any]):
31+
distribution = Distribution(
32+
{"ext_modules": EXTENSIONS},
33+
)
34+
cmd = build_ext(distribution)
35+
cmd.finalize_options()
36+
cmd.run()
37+
38+
for output in cmd.get_outputs():
39+
relative_extension = Path("src", Path(output).relative_to(cmd.build_lib))
40+
shutil.copyfile(output, relative_extension)

0 commit comments

Comments
 (0)