pytest-dev / iniconfig Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I'm not sure if this is the same or related to #17
Trying to install iniconfig via pipenv fails. I have tried with 3.6, 3.7 and 3.8 for python_version. 3.6 is successful, the others aren't.
This is the Pipenv file.
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[packages]
iniconfig = "*"
[requires]
python_version = "3.7"
And the output.
Creating a virtualenv for this project…
Pipfile: /home/some_user/tmp/python/Pipfile
Using /usr/bin/python3.7m (3.7.5) to create virtualenv…
⠸ Creating virtual environment...Already using interpreter /usr/bin/python3.7m
Using base prefix '/usr'
New python executable in /home/some_user/.local/share/virtualenvs/python-sbaFuM9w/bin/python3.7m
Also creating executable in /home/some_user/.local/share/virtualenvs/python-sbaFuM9w/bin/python
Installing setuptools, pip, wheel...
done.
Running virtualenv with interpreter /usr/bin/python3.7m
✔ Successfully created virtual environment!
Virtualenv location: /home/some_user/.local/share/virtualenvs/python-sbaFuM9w
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Building requirements...
Resolving dependencies...
✘ Locking Failed!
ERROR:pip.subprocessor:Command errored out with exit status 1:
command: /home/some_user/.local/share/virtualenvs/python-sbaFuM9w/bin/python /home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/notpip install --ignore-installed --no-user --prefix /tmp/pip-build-env-qhe95u1_/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=41.2.0' wheel 'setuptools_scm>3'
cwd: None
Complete output (20 lines):
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/notpip/__main__.py", line 18, in <module>
from pipenv.patched.notpip._internal.cli.main import main as _main # isort:skip # noqa
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/__init__.py", line 23, in <module>
from pipenv.vendor.vistir.compat import ResourceWarning, fs_str
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/vendor/vistir/__init__.py", line 4, in <module>
from .compat import (
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/vendor/vistir/compat.py", line 202, in <module>
IS_TYPE_CHECKING = os.environ.get("MYPY_RUNNING", is_type_checking())
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/vendor/vistir/compat.py", line 196, in is_type_checking
from typing import TYPE_CHECKING
File "/home/some_user/.local/lib/python3.6/site-packages/typing.py", line 1357, in <module>
class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
File "/home/some_user/.local/lib/python3.6/site-packages/typing.py", line 1005, in __new__
self._abc_registry = extra._abc_registry
AttributeError: type object 'Callable' has no attribute '_abc_registry'
----------------------------------------
Traceback (most recent call last):
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 807, in <module>
main()
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 803, in main
parsed.requirements_dir, parsed.packages, parse_only=parsed.parse_only)
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 785, in _main
resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages)
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 753, in resolve_packages
requirements_dir=requirements_dir,
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 736, in resolve
req_dir=requirements_dir
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/utils.py", line 1386, in resolve_deps
req_dir=req_dir,
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/utils.py", line 1093, in actually_resolve_deps
resolver.resolve()
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/utils.py", line 808, in resolve
results = self.resolver.resolve(max_rounds=environments.PIPENV_MAX_ROUNDS)
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 180, in resolve
has_changed, best_matches = self._resolve_one_round()
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 268, in _resolve_one_round
their_constraints.extend(self._iter_dependencies(best_match))
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 383, in _iter_dependencies
dependencies = self.repository.get_dependencies(ireq)
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 226, in get_dependencies
legacy_results = self.get_legacy_dependencies(ireq)
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 348, in get_legacy_dependencies
download_dir, ireq, wheel_cache
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 303, in resolve_reqs
results = resolver._resolve_one(reqset, ireq)
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/legacy_resolve.py", line 339, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/legacy_resolve.py", line 287, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(req)
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/operations/prepare.py", line 509, in prepare_linked_requirement
req, self.req_tracker, self.finder, self.build_isolation,
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/operations/prepare.py", line 95, in _get_prepared_distribution
abstract_dist.prepare_distribution_metadata(finder, build_isolation)
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/distributions/sdist.py", line 38, in prepare_distribution_metadata
self._setup_isolation(finder)
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/distributions/sdist.py", line 68, in _setup_isolation
"Installing build dependencies"
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/build_env.py", line 202, in install_requirements
call_subprocess(args, spinner=spinner)
File "/home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/utils/subprocess.py", line 242, in call_subprocess
raise InstallationError(exc_msg)
pipenv.patched.notpip._internal.exceptions.InstallationError: Command errored out with exit status 1: /home/some_user/.local/share/virtualenvs/python-sbaFuM9w/bin/python /home/some_user/.local/lib/python3.6/site-packages/pipenv/patched/notpip install --ignore-installed --no-user --prefix /tmp/pip-build-env-qhe95u1_/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=41.2.0' wheel 'setuptools_scm>3' Check the logs for full command output.
Pinning the version to 1.0
is fine.
Hi 👊
This is my first visit to this fine repo, but it seems you have been working hard to keep all dependencies updated so far.
Once you have closed this issue, I'll create seperate pull requests for every update as soon as I find one.
That's it for now!
Happy merging! 🤖
Howdy!
I stumbled upon problem with setup_requires and pip/poetry while using corporate PYPI mirror. As this package is used by pytest 6.0 (released 2 days ago) it can break things for many people.
Current workaround is to install setuptools-scm
manually via pip, before poetry, but it still requires time to debug and fix.
More references for this problem: pytest-dev/pytest-xdist#136 pypa/setuptools#209
based on #16 the build pipeline should also publish the wheels
The readme says it supports comments everywhere. But does that mean it supports recognizing comments but when you save the config those comments disappear? Or does iniconfig retain the location of the comments relative the thing they comments are commenting on?
Hello, I'm using this package in my project and am curious if there is a copyright notice I should reference for it for attribution. The license file does not have a specific copyright notice.
Hi!
Since Python 3.10 there's a new EncodeWarning
that gets flagged when a file is opened without specifying an encoding. PR #10328 in pytest proposes adding this capability. For this to work, a bunch of calls need to be updated to explicitly specify encoding="utf-8"
(or something similar – though UTF-8 seems like a sensible default).
Some of the tests, like test_ini_markers_whitespace
, initialise an IniConfig
object, whose constructor opens a file without specifying an encoding (see here). This leads to the test failing.
Can we modify the constructor to use an explicit encoding when opening the file? If iniconfig
doesn't support UTF-8 we can just use ASCII – so long as something is specified.
Thanks!
I run this package test suite against Pytest 5:
4 failed, 38 passed
There are several identical errors:
=================================== FAILURES ===================================
___________________________ test_iniconfig_from_file ___________________________
tmpdir = local('/usr/src/tmp/pytest-of-builder/pytest-1/test_iniconfig_from_file0')
def test_iniconfig_from_file(tmpdir):
path = tmpdir/'test.txt'
path.write('[metadata]\nname=1')
config = IniConfig(path=path)
assert list(config.sections) == ['metadata']
config = IniConfig(path, "[diff]")
assert list(config.sections) == ['diff']
> py.test.raises(TypeError, "IniConfig(data=path.read())")
E pytest.PytestDeprecationWarning: raises(..., 'code(as_a_string)') is deprecated, use the context manager form or use `exec()` directly
E
E See https://docs.pytest.org/en/latest/deprecations.html#raises-warns-exec
test_iniconfig.py:153: PytestDeprecationWarning
The tests in the current release no longer works with recent versions of pytest
due to py.test
removal. Could you please make a new release with the changes from main?
Hello,
it looks like that there is an issue with the latest version just released, the version in the package is 0.0.0
.
Test:
$ git clone https://github.com/RonnyPfannschmidt/iniconfig.git
$ cd iniconfig
$ pip install .
Processing /path/iniconfig
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: iniconfig
Building wheel for iniconfig (PEP 517) ... done
Created wheel for iniconfig: filename=iniconfig-0.0.0-py2.py3-none-any.whl size=4989 sha256=8465f477143b0ac27c24a47e789989be0759b724d7a2298568686875020185a0
Stored in directory: /private/var/folders/rh/jlkzwq5x70l_b6sjv3y31d9r0000gn/T/pip-ephem-wheel-cache-6cbof_4l/wheels/e9/49/c4/a61f9331f192b395ce56fbff2aa7a0c19a4ab737ec2df5866a
Successfully built iniconfig
Installing collected packages: iniconfig
Successfully installed iniconfig-0.0.0
Are you able to reproduce the same?
Hi,
I was wondering if you would like to integrate continuous fuzzing by way of OSS-Fuzz? Fuzzing is a way to automate test-case generation and has been heavily used for memory unsafe languages. Recently efforts have been put into fuzzing memory safe languages and Python is one of the languages where it would be great to use fuzzing.
In this PR google/oss-fuzz#8130 I did an initial integration into OSS-Fuzz. OSS-Fuzz is a free service run by Google that performs continuous fuzzing of important open source projects. As Iniconfig is a rather small library OSS-Fuzz will dedicate smaller amounts of CPU power to fuzz the project, but still give the benefit of continuous monitoring.
If you would like to integrate, the only thing I need is a list of email(s) that will get access to the data produced by OSS-Fuzz, such as bug reports, coverage reports and more stats. Notice the emails affiliated with the project will be public in the OSS-Fuzz repo, as they will be part of a configuration file.
Reported originally in pytest-dev/pytest#3799 by @edsion1107
@edsion1107 a PR here (with accompanying test) would be welcome!
pytest.ini:
[pytest]
log_file = pytest.log
log_file_level = INFO
log_file_format = %(asctime)s %(module)s.%(funcName)s %(levelname)s %(message)s
log_cli=true
log_cli_level = WARNING
log_cli_format = %(msecs)d %(filename)s(%(lineno)d) %(levelname)s %(message)s
# 中文
;--basetemp=../results
;--tap-files
;--html=report.html --self-contained-html
I have tried to add Chinese comment ,then this error occurs:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.1\helpers\pycharm\_jb_pytest_runner.py", line 31, in <module>
pytest.main(args, plugins_to_load)
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\_pytest\config\__init__.py", line 55, in main
config = _prepareconfig(args, plugins)
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\_pytest\config\__init__.py", line 180, in _prepareconfig
pluginmanager=pluginmanager, args=args
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\pluggy\hooks.py", line 258, in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\pluggy\manager.py", line 67, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\pluggy\manager.py", line 61, in <lambda>
firstresult=hook.spec_opts.get('firstresult'),
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\pluggy\callers.py", line 196, in _multicall
gen.send(outcome)
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\_pytest\helpconfig.py", line 89, in pytest_cmdline_parse
config = outcome.get_result()
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\pluggy\callers.py", line 76, in get_result
raise ex[1].with_traceback(ex[2])
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\pluggy\callers.py", line 180, in _multicall
res = hook_impl.function(*args)
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\_pytest\config\__init__.py", line 612, in pytest_cmdline_parse
self.parse(args)
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\_pytest\config\__init__.py", line 777, in parse
self._preparse(args, addopts=addopts)
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\_pytest\config\__init__.py", line 723, in _preparse
self._initini(args)
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\_pytest\config\__init__.py", line 666, in _initini
rootdir_cmd_arg=ns.rootdir or None,
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\_pytest\config\findpaths.py", line 118, in determine_setup
rootdir, inifile, inicfg = getcfg([ancestor], warnfunc=warnfunc)
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\_pytest\config\findpaths.py", line 35, in getcfg
iniconfig = py.iniconfig.IniConfig(p)
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\py\_vendored_packages\iniconfig.py", line 55, in __init__
tokens = self._parse(iter(f))
File "C:\Users\p_jbzhang\.virtualenvs\wecar-tMZRsXDh\lib\site-packages\py\_vendored_packages\iniconfig.py", line 83, in _parse
for lineno, line in enumerate(line_iter):
UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 259: illegal multibyte sequence
I tried to fix this error:
# filename: iniconfig.py
# line: 49
class IniConfig(object):
def __init__(self, path, data=None):
self.path = str(path) # convenience
if data is None:
# f = open(self.path)
# add encoding params
f = open(self.path, encoding='utf-8')
try:
tokens = self._parse(iter(f))
finally:
f.close()
else:
tokens = self._parse(data.splitlines(True))
I'm looking into updating the OpenWrt package for iniconfig (from 1.1.1 to 2.0.0), and when I try the example from the readme with 2.0.0 (using the example ini file) I get:
Python 3.11.4 (main, Aug 3 2023, 22:34:22) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import iniconfig
>>> ini = iniconfig.IniConfig("example.ini")
>>> ini['section1']['name1']
'value1 # comment'
>>> ini.get('section1', 'name1b', [], lambda x: x.split(","))
['value1', 'value2 # comment']
>>> ini.get('section1', 'notexist', [], lambda x: x.split(","))
[]
>>> [x.name for x in list(ini)]
['section1', 'section2']
>>> list(list(ini)[0].items())
[('name1', 'value1 # comment'), ('name1b', 'value1,value2 # comment')]
>>> 'section1' in ini
True
>>> 'inexistendsection' in ini
False
>>>
Note that # comment
is included with the value of name1
and the second value of name1b
. This appears to differ from the output in the readme - is the above the expected/correct output?
At the moment the parser uses the built-in string strip function (https://github.com/RonnyPfannschmidt/iniconfig/blob/master/iniconfig.py#L134). Nowadays is more and more common that people inadvertently introduce Unicode whitespaces in their configuration. The string strip function does not remove this. When we detect such we should at least warn (especially on the left-hand side), or fail. Failing to strip such characters is never the desired effect, as it effectively generates a new key that visually seems the same leaving the user in confusion of why his config does not work.
Note the py package uses this package vendored, and via that pytest/tox too (https://github.com/pytest-dev/py/blob/master/py/_vendored_packages/iniconfig.py).
Issues generated by this omission:
Detecting unicode spaces https://stackoverflow.com/questions/8921365/in-python-how-to-list-all-characters-matched-by-posix-extended-regex-space/37903375#37903375
I solved that issue #37
f = open(self.path) -> f = open(self.path, encoding='utf-8')
I use tox the testing tool for python in Windows 10 enviroment.
The problem is that class IniConfig tries to read tox.ini with cp932 encoding.
I read the code https://github.com/pytest-dev/iniconfig/blob/master/src/iniconfig/__init__.py#L51 . This not seems to have argument of encoding. Is this possible to set encoding?
tox -c $Env:PROJECT_DIR/tox.ini -e py39
File "c:\work\reni\git\ogs\.venv\lib\site-packages\py\_vendored_packages\iniconfig\__init__.py", line 54, in __init__
tokens = self._parse(iter(f))
File "c:\work\reni\git\ogs\.venv\lib\site-packages\py\_vendored_packages\iniconfig\__init__.py", line 82, in _parse
for lineno, line in enumerate(line_iter):
UnicodeDecodeError: 'cp932' codec can't decode byte 0x81 in position 115: illegal multibyte sequence
The readme talks about old Python versions and platform which are not currently supported.
IMO it is worth still mentioning them, but mentioning that they are no longer supported and update the Changelog to mention when each Python version or platform was de-supported.
The newest iniconfig 1.1.0, and 1.1.1 (with #14), fails on ppc64le / Python 3.7. Other (non-exhaustive) combos pass:
Collecting pytest
Using cached pytest-6.1.1-py3-none-any.whl (272 kB)
Requirement already satisfied, skipping upgrade: attrs>=17.4.0 in /home/travis/virtualenv/python3.7.2/lib/python3.7/site-packages (from pytest) (18.2.0)
Collecting iniconfig
Downloading iniconfig-1.1.1.tar.gz (8.1 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing wheel metadata: started
Preparing wheel metadata: finished with status 'done'
Collecting toml
Using cached toml-0.10.1-py2.py3-none-any.whl (19 kB)
Collecting pluggy<1.0,>=0.12
Using cached pluggy-0.13.1-py2.py3-none-any.whl (18 kB)
Collecting py>=1.8.2
Using cached py-1.9.0-py2.py3-none-any.whl (99 kB)
Collecting packaging
Using cached packaging-20.4-py2.py3-none-any.whl (37 kB)
Collecting importlib-metadata>=0.12; python_version < "3.8"
Using cached importlib_metadata-2.0.0-py2.py3-none-any.whl (31 kB)
Collecting pyparsing>=2.0.2
Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Requirement already satisfied, skipping upgrade: six in /home/travis/virtualenv/python3.7.2/lib/python3.7/site-packages (from packaging->pytest) (1.12.0)
Collecting zipp>=0.5
Using cached zipp-3.3.0-py3-none-any.whl (5.3 kB)
Building wheels for collected packages: iniconfig
WARNING: Building wheel for iniconfig failed: [Errno 13] Permission denied: '/home/travis/.cache/pip/wheels/ca'
Failed to build iniconfig
ERROR: Could not build wheels for iniconfig which use PEP 517 and cannot be installed directly
An earlier build with 1.0.1 passed:
Howdy,
Just noticed that there's no CHANGELOG entry for 1.0.1.
as per pytest-dev/pytest#8923 the following is legal in setup.cfg
[options.extras_require]
tests =
pytest
a mode to handle completely indented sections should be considered
OSS-Fuzz has found a bug in this project. Please see https://oss-fuzz.com/testcase?key=5524954908590080 for details and reproducers.
This issue is mirrored from https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=49798 and will auto-close if the status changes there.
If you have trouble accessing this report, please file an issue at https://github.com/google/oss-fuzz/issues/new.
OSS-Fuzz has found a bug in this project. Please see https://oss-fuzz.com/testcase?key=6211158595469312 for details and reproducers.
This issue is mirrored from https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=49779 and will auto-close if the status changes there.
If you have trouble accessing this report, please file an issue at https://github.com/google/oss-fuzz/issues/new.
When updating from 1.1.1 to 2.0.0 there were no more tests around.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.