Skip to content

Commit 77982fc

Browse files
authored
Build 2 different packages (#1019)
Working on getting the same contents uploaded to 2 different pypi packages (flask-security and flask-security-too) This means 2 slightly different packages - just with a different 'name' - which means different pyproject.toml which requires a build tool that can handle that (build cant) - so moved to flit like many other pallets-eco. Using flit enabled moving the manifest into pyproject.toml and eliminating the MANIFEST file. Finally - different packages mean different provenance etc - so separated out the publishing action into 2 - one for each pypi. This means we will create 2 draft releases in github - but that should be ok. Note that the changing from MANIFEST could introduce slightly different contents...
1 parent 726327c commit 77982fc

File tree

8 files changed

+239
-51
lines changed

8 files changed

+239
-51
lines changed

.github/workflows/publish-too.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Publish-Too
2+
on:
3+
push:
4+
tags:
5+
- '*'
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
hash: ${{ steps.hash.outputs.hash }}
11+
steps:
12+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
13+
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
14+
with:
15+
python-version: '3.x'
16+
cache: pip
17+
cache-dependency-path: requirements*/*.txt
18+
# Use the commit date instead of the current date during the build.
19+
- run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
20+
- name: Create dist
21+
run: |
22+
python -m pip install -U pip
23+
pip install tox
24+
tox -e makedist-too
25+
# Generate hashes used for provenance.
26+
- name: generate hash
27+
id: hash
28+
run: cd dist && echo "hash=$(sha256sum * | base64 -w0)" >> $GITHUB_OUTPUT
29+
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
30+
with:
31+
path: ./dist
32+
provenance:
33+
needs: [build]
34+
permissions:
35+
actions: read
36+
id-token: write
37+
contents: write
38+
# Can't pin with hash due to how this workflow works.
39+
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
40+
with:
41+
base64-subjects: ${{ needs.build.outputs.hash }}
42+
create-release:
43+
# Upload the sdist, wheels, and provenance to a GitHub release. They remain
44+
# available as build artifacts for a while as well.
45+
needs: [provenance]
46+
runs-on: ubuntu-latest
47+
permissions:
48+
contents: write
49+
steps:
50+
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
51+
- name: create release
52+
run: >
53+
gh release create --draft --repo ${{ github.repository }}
54+
${{ github.ref_name }}-Too
55+
*.intoto.jsonl/* artifact/*
56+
env:
57+
GH_TOKEN: ${{ github.token }}
58+
59+
publish-pypi-too:
60+
needs: [ provenance ]
61+
# Wait for approval before attempting to upload to PyPI. This allows reviewing the
62+
# files in the draft release.
63+
environment:
64+
name: publish
65+
url: https://pypi.org/project/Flask-Security-Too/${{ github.ref_name }}
66+
runs-on: ubuntu-latest
67+
permissions:
68+
id-token: write
69+
steps:
70+
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
71+
- uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14
72+
with:
73+
packages-dir: artifact/

.github/workflows/publish.yaml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,3 @@ jobs:
7070
- uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14
7171
with:
7272
packages-dir: artifact/
73-
74-
publish-pypi-too:
75-
needs: [ provenance ]
76-
# Wait for approval before attempting to upload to PyPI. This allows reviewing the
77-
# files in the draft release.
78-
environment:
79-
name: publish
80-
url: https://pypi.org/project/Flask-Security-Too/${{ github.ref_name }}
81-
runs-on: ubuntu-latest
82-
permissions:
83-
id-token: write
84-
steps:
85-
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
86-
- uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14
87-
with:
88-
packages-dir: artifact/
File renamed without changes.

MANIFEST.in

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

pyproject-too.toml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
[project]
2+
name = "Flask-Security-Too"
3+
description = "Quickly add security features to your Flask application."
4+
readme.content-type = "text/x-rst"
5+
readme.file = "README.rst"
6+
keywords = ["flask security"]
7+
license = { file = "LICENSE.txt" }
8+
maintainers = [{ name = "Chris Wagner", email = "jwag.wagner+github@gmail.com"}]
9+
authors = [{ name = "Matt Wright"}, { name = "Chris Wagner", email = "jwag.wagner+github@gmail.com"}]
10+
requires-python = ">=3.9"
11+
urls.Documentation = "https://flask-security.readthedocs.io"
12+
urls.Homepage = "https://github.com/pallets-eco/flask-security"
13+
urls.Source = "https://github.com/pallets-eco/flask-security"
14+
urls.Tracker = "https://github.com/pallets-eco/flask-security/issues"
15+
urls.Releases = "https://pypi.org/project/Flask-Security/"
16+
classifiers=[
17+
"Environment :: Web Environment",
18+
"Framework :: Flask",
19+
"Intended Audience :: Developers",
20+
"License :: OSI Approved :: MIT License",
21+
"Operating System :: OS Independent",
22+
"Programming Language :: Python",
23+
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
24+
"Topic :: Software Development :: Libraries :: Python Modules",
25+
"Programming Language :: Python :: 3",
26+
"Programming Language :: Python :: 3.9",
27+
"Programming Language :: Python :: 3.10",
28+
"Programming Language :: Python :: 3.11",
29+
"Programming Language :: Python :: 3.12",
30+
"Programming Language :: Python :: Implementation :: CPython",
31+
"Programming Language :: Python :: Implementation :: PyPy",
32+
"Development Status :: 5 - Production/Stable",
33+
]
34+
dynamic = [
35+
"version",
36+
]
37+
dependencies = [
38+
# flask dependencies include werkzeug, jinja2, itsdangerous, click, blinker
39+
"Flask>=3.0.0",
40+
"Flask-Login>=0.6.3",
41+
"Flask-Principal>=0.4.0",
42+
"Flask-WTF>=1.1.2",
43+
"email-validator>=2.0.0",
44+
"markupsafe>=2.1.0",
45+
"passlib>=1.7.4",
46+
"wtforms>=3.0.0", # for form-level errors
47+
"importlib_resources>=5.10.0",
48+
]
49+
50+
[project.optional-dependencies]
51+
babel = ["babel>=2.12.1", "flask_babel>=3.1.0"]
52+
fsqla = ["flask_sqlalchemy>=3.1.0", "sqlalchemy>=2.0.18", "sqlalchemy-utils>=0.41.1"]
53+
common = ["argon2_cffi>=21.3.0", "bcrypt>=4.0.1", "flask_mailman>=0.3.0", "bleach>=6.0.0"]
54+
mfa = ["cryptography>=40.0.2", "qrcode>=7.4.2", "phonenumberslite>=8.13.11", "webauthn>=2.0.0"]
55+
low = [
56+
# Lowest supported versions
57+
"Flask==3.0.0",
58+
"Flask-SQLAlchemy==3.1.0",
59+
"Flask-SQLAlchemy-Lite==0.1.0;python_version>='3.10'",
60+
"Flask-Babel==3.1.0",
61+
"Flask-Mailman==0.3.0",
62+
"Flask-Login==0.6.3",
63+
"Flask-WTF==1.1.2",
64+
"peewee==3.16.2",
65+
"argon2_cffi==21.3.0",
66+
"authlib==1.2.0",
67+
"babel==2.12.1",
68+
"bcrypt==4.0.1",
69+
"bleach==6.0.0",
70+
"freezegun",
71+
"jinja2==3.1.2",
72+
"itsdangerous==2.1.2",
73+
"markupsafe==2.1.2",
74+
"mongoengine==0.27.0",
75+
"mongomock==4.1.2",
76+
"pony==0.7.16;python_version<'3.11'",
77+
"phonenumberslite==8.13.11",
78+
"qrcode==7.4.2",
79+
# authlib requires requests
80+
"requests",
81+
# passlib required setuptools
82+
"setuptools",
83+
"sqlalchemy==2.0.18",
84+
"sqlalchemy-utils==0.41.1",
85+
"webauthn==2.0.0",
86+
"werkzeug==3.0.1",
87+
"zxcvbn==4.4.28"
88+
]
89+
[build-system]
90+
requires = ["flit_core >=3.8,<4"]
91+
build-backend = "flit_core.buildapi"
92+
93+
[tool.flit.module]
94+
name = "flask_security"
95+
96+
[tool.flit.sdist]
97+
include = [
98+
"AUTHORS",
99+
"CHANGES.rst",
100+
"CONTRIBUTING.rst",
101+
"LICENSE.txt",
102+
".djlintrc",
103+
".git-blame-ignore-revs",
104+
".gitignore",
105+
".pre-commit-config.yaml",
106+
"babel.ini",
107+
"codecov.yml",
108+
"mypy.ini",
109+
"pytest.ini",
110+
"tox.ini",
111+
"docs/",
112+
"examples/",
113+
"requirements",
114+
"tests/",
115+
]
116+
exclude = ["docs/_build/"]
117+
118+
[tool.djlint]
119+
ignore="H005,H006" # lang, img height/width
120+
121+
[tool.pyright]
122+
include=["flask_security", "tests/view_scaffold.py"]
123+
analyzeUnannotatedFunctions = "none"
124+
reportMissingImports = false

pyproject.toml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
[build-system]
2-
requires = ["setuptools"]
3-
build-backend = "setuptools.build_meta"
4-
51
[project]
62
name = "Flask-Security"
73
description = "Quickly add security features to your Flask application."
84
readme.content-type = "text/x-rst"
95
readme.file = "README.rst"
106
keywords = ["flask security"]
11-
# license = "MIT"
7+
license = { file = "LICENSE.txt" }
128
maintainers = [{ name = "Chris Wagner", email = "jwag.wagner+github@gmail.com"}]
139
authors = [{ name = "Matt Wright"}, { name = "Chris Wagner", email = "jwag.wagner+github@gmail.com"}]
1410
requires-python = ">=3.9"
@@ -90,9 +86,34 @@ low = [
9086
"werkzeug==3.0.1",
9187
"zxcvbn==4.4.28"
9288
]
89+
[build-system]
90+
requires = ["flit_core >=3.8,<4"]
91+
build-backend = "flit_core.buildapi"
9392

94-
[tool.setuptools.dynamic]
95-
version = {attr = "flask_security.__version__"}
93+
[tool.flit.module]
94+
name = "flask_security"
95+
96+
[tool.flit.sdist]
97+
include = [
98+
"AUTHORS",
99+
"CHANGES.rst",
100+
"CONTRIBUTING.rst",
101+
"LICENSE.txt",
102+
".djlintrc",
103+
".git-blame-ignore-revs",
104+
".gitignore",
105+
".pre-commit-config.yaml",
106+
"babel.ini",
107+
"codecov.yml",
108+
"mypy.ini",
109+
"pytest.ini",
110+
"tox.ini",
111+
"docs/",
112+
"examples/",
113+
"requirements",
114+
"tests/",
115+
]
116+
exclude = ["docs/_build/"]
96117

97118
[tool.djlint]
98119
ignore="H005,H006" # lang, img height/width

requirements/dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-r docs.txt
22
-r tests.txt
33
mypy
4-
build
4+
flit
55
check-wheel-contents
66
psycopg2-binary
77
pymysql

tox.ini

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,23 @@ commands =
124124
[testenv:makedist]
125125
deps =
126126
-r requirements/tests.txt
127-
build
128-
setuptools
127+
flit
129128
twine
130129
check-wheel-contents
131130
commands =
132131
tox -e compile_catalog
133-
python -m build
132+
flit build --no-use-vcs
133+
check-wheel-contents dist
134+
135+
[testenv:makedist-too]
136+
deps =
137+
-r requirements/tests.txt
138+
flit
139+
twine
140+
check-wheel-contents
141+
commands =
142+
tox -e compile_catalog
143+
flit -f pyproject-too.toml build --no-use-vcs
134144
check-wheel-contents dist
135145

136146
[testenv:mypy]

0 commit comments

Comments
 (0)