-
Notifications
You must be signed in to change notification settings - Fork 3
pep518 support #14
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
pep518 support #14
Conversation
- refactor: pep518 support - ci(tests): kwargs before positional args - fix(MANIFEST.in): ensure all support files in tarball - tests: pytest requires tests folder to have an empty __init__.py - tests(conftest.py): pytest plugin name not logassert.pytest_plugin - tests: when called by unittest unittest modules require process shield
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello! Thanks for these changes! Please check some details and questions.
Regarding flake8, it was working before so we don't really need to ignore anything.
Thanks again!
requirements-dev.in
Outdated
@@ -1,3 +1,4 @@ | |||
flake8 | |||
flake8-pyproject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put the development dependencies in pyproject.toml
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two routes lets discuss both and their real ramifications:
Dynamic optional-dependencies
[project]
dynamic = ["optional-dependencies"]
[tool.setuptools.dynamic]
optional-dependencies.dev = { file = ['requirements-dev.in'] }
Static optional-dependencies
[project.optional-dependencies]
dev = [
"flake8",
"flake8-pyproject",
"pytest",
"structlog",
]
The disadvantages of static dependencies:
- managing requirements
Packages intended for managing requirements files are no longer an option.
Coerced towards a preference to eventually accept either poetry or uv.
There are packages specifically for managing requirements files rather than
venvs.
- target venv?
No mention of target virtual environment. Naively assumes there will ever
only be one.
- lock files
Hardening security aside, more important to be able to reproduce dev env, by specifying all dependencies' version.
Would take minimal effort to lock down the dev environment and periodically update it
Ur informed choice
-
Which shall it be: dynamic or static?
-
If dynamic, lock dev env or keep it unlocked?
-
If dynamic, create a
requirements/
folder, move requirements files over , remove prependedrequirements-
from file names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some ideas, with simplicity in mind:
- I will not switch to using uv or poetry; let's keep using pip (and will not use a lock file)
project.optional-dependencies
is not a real choice, those are "if they are only needed for a specific feature of your package"; this is not about optional features, but development dependencies- I will not add a
requirements
directory
With that in mind, is there a way to put the development dependencies in pyproject.toml
and make pip
install them from there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two types of extras (for maintainers and for end users), but no way to distinguish the two. Both fall under optional dependencies.
pip will work just fine with unlocked static optional dependencies.
pyproject.toml
Outdated
"Source code" = 'https://github.com/facundobatista/logassert' | ||
|
||
[tool.setuptools.packages.find] | ||
# where = ["src"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this commented line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Locally, flake8
is having a hard time with the flat package
layout. Would be resolved by moving to a src package
layout.
logassert -> src/logassert
The current situation, flat package
layout, locally, flake8 looks thru virtualenv env/
at every single package. Many vendored packages are using six
for py27 compatibility. flake8
generates lots of F821 undefined name messages.
Since this action might be surprising, wanted to discuss it and form consensus on the move over to the normal src package
layout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line is to make the transition from flat package to src package layout smooth.
The transition process
Rename/move logassert/
folder as src/logassert
then uncomment the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will not move from logassert
to src
; please focus the PR in using pyproject.toml
which is what I agreed and not changing the project's structure.
Regarding flake8, it is currently working ok in master. So if after your changes it's not working anymore, it may be one of your changes that need to be revisited...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In master (within gh workflow) works fine; there is no virtual environment folder.
Removed the comment line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifying the folders ensures flake8 does not go thru the venv folder.
Executes exponentially quicker.
Was hitting the CPU hard and taking a long time to complete.
flake8 --count --select=E9,F63,F7,F82 --show-source --statistics logassert/ tests/
flake8 --count --exit-zero --max-complexity=10 --max-line-length=99 --statistics logassert/ tests/
Tests are failing cuz the logs plugin is not being discovered. The plugin (logassert) and plugin dotted path (only one plugin allowed) is specified in Will add this step:
The local path hack has already been removed: tests/conftest.py
What it looks like now
|
- ci: install project before running pytest - tests(test_classic): remove process shield
- ci: install package and dependencies before flake8
- ci: remove --no-deps flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! This is much better shaped!! Cool.
Please check a comment regarding content in MANIFEST.in... btw, when is this file used?
Thanks!!
MANIFEST.in
Outdated
include test | ||
|
||
# docs (build converts symlink to copy of README.md) | ||
graft docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why all this new stuff?
- .github, .mkdocs, .readthedocs.yml are very project specific
- developmnet requirements and tests should not be distributed
- docs is just a link to the README...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From distribution will remove all project, development, and tests
Also will remove unnecessary explicit includes (README.md and LICENSE are automagically included)
Do not understand why docs/
even exists. Placeholder? Removed that as well. Normally docs is where mkdocs or Sphinx files/folders would go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MANIFEST.in
... btw, when is this file used?
Running python -m build
will create dist/
and places tarball and whl in there.
Been opening the tarball in xarchiver (a GUI that opens compressed files) to see what source files are being distributed and then adjusting MANIFEST.in
If setuptools-scm
were used, would automatically include package files. MANIFEST.in
would only be needed to exclude files and folders.
- chore: from distribution exclude project, development, and tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks for all this work. I'll merge and adjust any further detail if needed. Thanks again!
closes #12
Adds dependency
flake8-pyproject
torequirements-dev.in
The intent is minimal changes, but some fixes were necessary
__init__.py
logassert.pytest_plugin
These fixes are nitpicky
Recommendations not in the commit
flat layout should be src layout. The flat layout is confusing flake8 causing it to inspect all packages in venv not just logassert. F821 is ignored until this issue is resolved.
To convert to a src-layout:
In
pyproject.toml
, uncommenttool.setuptools.packages.find.where
Requests
apply patches in chronological order to avoid existing PRs needing to be rebased
any changes, just ask. Will make them