Skip to content

Commit

Permalink
Merge pull request #240 from facelessuser/chore/hatch-backend
Browse files Browse the repository at this point in the history
Use hatch as the build backend
  • Loading branch information
facelessuser authored Apr 6, 2022
2 parents 094d265 + 741e0c6 commit e79f532
Show file tree
Hide file tree
Showing 28 changed files with 148 additions and 160 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ jobs:
max-parallel: 4
matrix:
platform: [ubuntu-latest, windows-latest]
tox-env: [py36, py37, py38, py39, py310, nolxml, nohtml5lib]
tox-env: [py37, py38, py39, py310, nolxml, nohtml5lib]
include:
- tox-env: py36
python-version: 3.6
continue-on-error: false
- tox-env: py37
python-version: 3.7
continue-on-error: false
Expand Down Expand Up @@ -60,7 +57,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools tox coverage codecov
python -m pip install --upgrade pip setuptools build tox coverage codecov
- name: Test
run: |
python -m tox
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ jobs:
git push gh-token gh-pages
pypi:
strategy:
matrix:
distribution: [bdist_wheel, sdist]

runs-on: ubuntu-latest

steps:
Expand All @@ -50,10 +46,10 @@ jobs:
python-version: 3.9
- name: Package
run: |
pip install --upgrade setuptools wheel
python setup.py ${{ matrix.distribution }}
pip install --upgrade build
python -m build -s -w
- name: Publish
uses: pypa/gh-action-pypi-publish@v1.4.1
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 - 2021 Isaac Muse <isaacmuse@gmail.com>
Copyright (c) 2018 - 2022 Isaac Muse <isaacmuse@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
16 changes: 0 additions & 16 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Documentation is found here: https://facelessuser.github.io/soupsieve/.

MIT License

Copyright (c) 2018 - 2021 Isaac Muse <isaacmuse@gmail.com>
Copyright (c) 2018 - 2022 Isaac Muse <isaacmuse@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions docs/src/markdown/.snippets/refs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--8<--
links.md
abbr.md
--8<--
4 changes: 0 additions & 4 deletions docs/src/markdown/_snippets/refs.txt

This file was deleted.

6 changes: 5 additions & 1 deletion docs/src/markdown/about/changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## 2.3.2

- **FIX**: Fix some typos in error messages.

## 2.3.1

- **FIX**: Ensure attribute selectors match tags that have new lines characters in attributes. (#233)
- **FIX**: Ensure attribute selectors match tags that have new line characters in attributes. (#233)

## 2.3

Expand Down
2 changes: 0 additions & 2 deletions docs/src/markdown/about/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,5 +391,3 @@ class SelectorLang:
Attribute | Description
------------- | -----------
`languages` | A list of regular expression objects that match a language pattern.

--8<-- "links.txt"
22 changes: 1 addition & 21 deletions docs/src/markdown/about/license.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
# License

MIT License

Copyright (c) 2018 - 2021 Isaac Muse <isaacmuse@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--8<-- "LICENSE.md"
4 changes: 0 additions & 4 deletions docs/src/markdown/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,3 @@ Tags do not necessarily have to have a prefix for Soup Sieve to recognize them e
*should* automatically get the SVG namespace. Depending how namespaces were defined in the document, tags may inherit
namespaces in some conditions. Namespace assignment is mainly handled by the parser and exposed through the Beautiful
Soup API. Soup Sieve uses the Beautiful Soup API to then compare namespaces for supported documents.

--8<--
refs.txt
--8<--
4 changes: 0 additions & 4 deletions docs/src/markdown/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,3 @@ Compiled patterns are cached, so if for any reason you need to clear the cache,
```pycon3
>>> sv.purge()
```

--8<--
refs.txt
--8<--
3 changes: 1 addition & 2 deletions docs/src/markdown/selectors/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,5 @@ Namespaces can be used with attribute selectors as well except that when `[|attr
```

--8<--
selector_styles.txt
refs.txt
selector_styles.md
--8<--
3 changes: 1 addition & 2 deletions docs/src/markdown/selectors/combinators.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,5 @@ has an adjacent sibling that precedes it that matches the first element.
https://developer.mozilla.org/en-US/docs/Web/CSS/Adjacent_sibling_combinator

--8<--
selector_styles.txt
refs.txt
selector_styles.md
--8<--
3 changes: 1 addition & 2 deletions docs/src/markdown/selectors/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,5 @@ A selector list is a list of selectors joined with a comma (`,`). A selector lis
valid if any of the selectors in a list matches.

--8<--
selector_styles.txt
refs.txt
selector_styles.md
--8<--
9 changes: 7 additions & 2 deletions docs/src/markdown/selectors/pseudo-classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,12 @@ given element), match at least one element.
While the level 4 specifications state that [compound](#compound-selector) selectors are supported, complex selectors
are planned for level 5 CSS selectors. Soup Sieve supports [complex](#complex-selector) selectors.

In addition to supporting complex selectors, Soup Sieve also supports nested `:has()` which has been excluded from the
level 4 specifications to help encourage browsers to implement `:has()`. This exclusion helps to reduces complexity and
improves performance in a live environment. As these performance concerns are not an issue in a scraping environment
compared to a web browser, Soup Sieve has no intentions on restricting the nesting of `:has()`. Users can always choose
not to nest `:has()` if there are concerns.

=== "Syntax"
```css
:has(selector)
Expand Down Expand Up @@ -1590,6 +1596,5 @@ Syntax is the same as [`:-soup-contains()`](#:-soup-contains).
`:-soup-contains-own()` was added in 2.1.

--8<--
selector_styles.txt
refs.txt
selector_styles.md
--8<--
3 changes: 1 addition & 2 deletions docs/src/markdown/selectors/unsupported.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,5 @@ Selects links that have already been visited.
```

--8<--
selector_styles.txt
refs.txt
selector_styles.md
--8<--
51 changes: 51 additions & 0 deletions hatch_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""Dynamically define some metadata."""
import os

from hatchling.metadata.plugin.interface import MetadataHookInterface


def get_version_dev_status(root):
"""Get version_info without importing the entire module."""

import importlib.util

path = os.path.join(root, "soupsieve", "__meta__.py")
spec = importlib.util.spec_from_file_location("__meta__", path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module.__version_info__._get_dev_status()


def get_requirements(root):
"""Load list of dependencies."""

install_requires = []
with open(os.path.join(root, "requirements", "project.txt")) as f:
for line in f:
if not line.startswith("#"):
install_requires.append(line.strip())
return install_requires


class CustomMetadataHook(MetadataHookInterface):
"""Our metadata hook."""

def update(self, metadata):
"""See https://ofek.dev/hatch/latest/plugins/metadata-hook/ for more information."""

metadata["dependencies"] = get_requirements(self.root)
metadata["classifiers"] = [
f"Development Status :: {get_version_dev_status(self.root)}",
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Python Modules',
'Typing :: Typed'
]
8 changes: 6 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repo_url: https://github.com/facelessuser/soupsieve
edit_uri: tree/main/docs/src/markdown
site_description: A modern CSS selector library for Beautiful Soup.
copyright: |
Copyright &copy; 2018 - 2021 <a href="https://github.com/facelessuser" target="_blank" rel="noopener">Isaac Muse</a>
Copyright &copy; 2018 - 2022 <a href="https://github.com/facelessuser" target="_blank" rel="noopener">Isaac Muse</a>
docs_dir: docs/src/markdown
theme:
Expand Down Expand Up @@ -86,7 +86,11 @@ markdown_extensions:
- pymdownx.mark:
- pymdownx.striphtml:
- pymdownx.snippets:
base_path: docs/src/markdown/_snippets
base_path:
- docs/src/markdown/.snippets
- LICENSE.md
auto_append:
- refs.md
- pymdownx.keys:
separator: "\uff0b"
- pymdownx.details:
Expand Down
63 changes: 59 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,69 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
"hatchling>=0.21.1",
]
build-backend = "hatchling.build"

build-backend = "setuptools.build_meta"
[project]
name = "soupsieve"
description = "A modern CSS selector implementation for Beautiful Soup."
readme = "README.md"
license = "MIT"
requires-python = ">=3.6"
authors = [
{ name = "Isaac Muse", email = "Isaac.Muse@gmail.com" },
]
keywords = [
"CSS",
"HTML",
"XML",
"selector",
"filter",
"query",
"soup"
]
dynamic = [
"classifiers",
"dependencies",
"version",
]

[project.urls]
Homepage = "https://github.com/facelessuser/soupsieve"

[tool.hatch.version]
source = "code"
path = "soupsieve/__meta__.py"

[tool.hatch.build.targets.wheel]
include = [
"/soupsieve",
]

[tool.hatch.build.targets.sdist]
include = [
"/docs/src/markdown/**/*.md",
"/docs/src/markdown/**/*.gif",
"/docs/src/markdown/**/*.png",
"/docs/src/markdown/dictionary/*.txt",
"/docs/theme/**/*.css",
"/docs/theme/**/*.js",
"/docs/theme/**/*.html",
"/requirements/*.txt",
"/soupsieve/**/*.py",
"/soupsieve/py.typed",
"/tests/**/*.py",
"/.pyspelling.yml",
"/.coveragerc",
"/mkdocs.yml",
"/tox.ini",
]

[tool.mypy]
files = [
"soupsieve/*.py"
"soupsieve"
]
strict = true
show_error_codes = true

[tool.hatch.metadata.hooks.custom]
2 changes: 1 addition & 1 deletion requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mkdocs_pymdownx_material_extras==1.5.5
mkdocs_pymdownx_material_extras>=2.0
mkdocs-git-revision-date-localized-plugin
mkdocs-minify-plugin
pyspelling
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit e79f532

Please sign in to comment.