Skip to content

Commit 00c9eed

Browse files
committed
Switch from flit to poetry
1 parent 784e02b commit 00c9eed

File tree

7 files changed

+1122
-77
lines changed

7 files changed

+1122
-77
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ jobs:
1919
with:
2020
python-version: '3.11'
2121
architecture: 'x64'
22+
- name: Setup poetry
23+
run: python3 -m pip install poetry
24+
- name: Install dependencies
25+
run: python3 -m poetry install
2226
- name: Run tests
2327
run: make test
24-
env:
25-
FLIT_ROOT_INSTALL: "1"
2628
- name: Build package
2729
id: build_package
2830
run: make package

.github/workflows/test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ jobs:
2222
with:
2323
python-version: ${{ matrix.python-version }}
2424
architecture: 'x64'
25+
- name: Setup poetry
26+
run: python3 -m pip install poetry
27+
- name: Install dependencies
28+
run: python3 -m poetry install
2529
- name: Run tests
2630
run: make test
27-
env:
28-
FLIT_ROOT_INSTALL: "1"
2931
- name: Build package
3032
id: build_package
3133
run: make package

HACKING.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,34 +95,37 @@ Helper functions to help the Parser in navigating through the reStructuredText.
9595

9696
## Developing Snooty
9797

98-
1. Run the following to install the necessary tools:
98+
1. Install [Poetry](https://python-poetry.org/docs/)
99+
100+
2. Set up the project's dependencies.
99101

100102
```shell
101-
python3 -m pip install flit virtualenv
103+
poetry install
102104
```
103105

104-
2. Make your changes to the source code.
106+
3. Make your changes to the source code.
105107

106-
3. Run `make test` and `make format ` to check that the tests pass and fix your formatting. This will also install the prerequirements defined in pyproject.toml.
108+
4. Run `make test` and `make format ` to check that the tests pass and fix your formatting. This will also install the prerequirements defined in pyproject.toml.
107109

108-
4. Use [Flit](https://flit.readthedocs.io/en/latest/) to install Snooty. The module will be symlinked (via `-s`) to allow for testing changes without reinstalling the module.
110+
5. You can activate a shell where the `snooty` command is available by running:
109111

110112
```shell
111-
flit install -s
113+
poetry shell
114+
115+
snooty build <docs_property_path>
112116
```
113117

114118
### Running tests
115119

116120
To run tests for a specific file:
117121

118122
```shell
119-
. .venv/bin/activate
120-
pytest snooty/test_<file>.py
123+
poetry run pytest snooty/test_<file>.py
121124
```
122125

123126
### Code Coverage
124127

125-
Install [Coverage](https://coverage.readthedocs.io/en/v4.5.x/). After running tests via `make format test`, run:
128+
Install [Coverage](https://coverage.readthedocs.io/). After running tests via `make format test`, run:
126129

127130
```shell
128131
coverage html

Makefile

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,31 @@
1-
.PHONY: help lint format test clean flit-publish package cut-release performance-report
1+
.PHONY: help lint format test clean package cut-release performance-report
22

3-
SYSTEM_PYTHON=$(shell which python3)
43
PLATFORM=$(shell printf '%s_%s' "$$(uname -s | tr '[:upper:]' '[:lower:]')" "$$(uname -m)")
54
VERSION=$(shell git describe --tags)
65
PUSH_TO=$(shell git remote -v | grep -m1 -E 'github.com(:|/)mongodb/snooty-parser.git' | cut -f 1)
76
PACKAGE_NAME=snooty-${VERSION}-${PLATFORM}.zip
8-
export SOURCE_DATE_EPOCH = $(shell date +%s)
97

108
help: ## Show this help message
119
@grep -E '^[a-zA-Z_.0-9-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
1210

13-
.venv/.EXISTS: pyproject.toml
14-
-rm -r .venv snootycli.py
15-
"$(SYSTEM_PYTHON)" -m venv .venv
16-
. .venv/bin/activate && \
17-
python3 -m pip install --upgrade pip && \
18-
python3 -m pip install flit && \
19-
flit install -s --deps=develop
20-
touch $@
21-
22-
lint: .venv/.EXISTS ## Run all linting
23-
. .venv/bin/activate && python3 -m mypy --strict snooty tools
24-
. .venv/bin/activate && python3 -m pyflakes snooty tools
25-
. .venv/bin/activate && python3 -m black snooty tools --check
11+
lint: ## Run all linting
12+
poetry run mypy --strict snooty tools
13+
poetry run pyflakes snooty tools
14+
poetry run black snooty tools --check
2615
tools/lint_changelog.py CHANGELOG.md
2716

28-
format: .venv/.EXISTS ## Format source code with black
29-
. .venv/bin/activate && python3 -m isort snooty tools
30-
. .venv/bin/activate && python3 -m black snooty tools
17+
format: ## Format source code with black
18+
poetry run isort snooty tools
19+
poetry run black snooty tools
3120

3221
test: lint ## Run unit tests
33-
. .venv/bin/activate && python3 -X dev -m pytest --cov=snooty
22+
poetry run python3 -X dev -m pytest --cov=snooty
3423

35-
dist/snooty/.EXISTS: .venv/.EXISTS pyproject.toml snooty/*.py snooty/gizaparser/*.py
24+
dist/snooty/.EXISTS: pyproject.toml snooty/*.py snooty/gizaparser/*.py
3625
-rm -rf snooty.dist dist
3726
mkdir dist
3827
echo 'from snooty import main; main.main()' > snootycli.py
39-
. .venv/bin/activate && python3 -m PyInstaller -n snooty snootycli.py
28+
poetry run python3 -m PyInstaller -n snooty snootycli.py
4029
rm snootycli.py
4130
install -m644 snooty/config.toml snooty/rstspec.toml LICENSE* dist/snooty/
4231
touch $@
@@ -52,13 +41,10 @@ dist/${PACKAGE_NAME}.asc: dist/snooty-${VERSION}-${PLATFORM}.zip ## Build and si
5241
gpg --armor --detach-sig $^
5342

5443
clean: ## Remove all build artifacts
55-
-rm -r snooty.tar.zip* snootycli.py .venv
44+
-rm -r snooty.tar.zip* snootycli.py
5645
-rm -rf dist
5746
-rm -rf .docs
5847

59-
flit-publish: test ## Deploy the package to pypi
60-
SOURCE_DATE_EPOCH="$$SOURCE_DATE_EPOCH" flit publish
61-
6248
package: dist/${PACKAGE_NAME}
6349

6450
cut-release: ## Release a new version of snooty. Must provide BUMP_TO_VERSION
@@ -86,7 +72,7 @@ cut-release: ## Release a new version of snooty. Must provide BUMP_TO_VERSION
8672
@echo "Release will be created at: https://github.com/mongodb/snooty-parser/releases/tag/v${BUMP_TO_VERSION}"
8773

8874
DOCS_COMMIT=1c6dfe71fd45fbdcdf5c7b73f050f615f4279064
89-
performance-report: .venv/.EXISTS ## Fetch a sample corpus, and generate a timing report for each part of the parse
75+
performance-report: ## Fetch a sample corpus, and generate a timing report for each part of the parse
9076
if [ ! -d .docs ]; then git clone https://github.com/mongodb/docs.git .docs; fi
9177
cd .docs; if [ `git rev-parse HEAD` != "${DOCS_COMMIT}" ]; then git fetch && git reset --hard "${DOCS_COMMIT}"; fi
92-
. .venv/bin/activate && python3 -m snooty.performance_report .docs
78+
poetry run python3 -m snooty.performance_report .docs

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The Snooty Parser
2+
=================

0 commit comments

Comments
 (0)