I am using pyenv to select python 3.10.9:
pyenv global 3.10.9
python --version
Python 3.10.9
Poetry configuration file shows that Poetry should use the current python version:
(base) bob#Roberts-Mac-mini shims % poetry config --list (amended)
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.prefer-active-python = true
but when I create a new poetry project:
poetry new --src newproject
in the generated pyproject.toml the python version is 3.11, which is the version that was active when I installed poetry itself (file amended):
(base) bob#Roberts-Mac-mini newproject % cat pyproject.toml
[tool.poetry]
name = "newproject"
version = "0.1.0"
description = ""
authors = ["XXXX YYYYYY <ZZZZZZZZZZ#gmail.com>"]
readme = "README.md"
packages = [{include = "newproject", from = "src"}]
[tool.poetry.dependencies]
python = "^3.11"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
I see there's an experimental poetry setting: https://python-poetry.org/docs/configuration/#virtualenvsprefer-active-python-experimental
Are there hidden problems using it?
The other solution I can think of is editing the pyproject.toml file, change python to 3.10 and then use "poetry env use 3.10" to create the venv with 3.10. Is this ok?
Are there other solutions to force the new environment to 3.10.9?
Related
my first problem, did not install pyqt-tools, because current version pyqt-tools dependents pyqt5 version 5.15.4. Ok. I install this version and retray install pyqt-tools, but now, poetry print thise error:
Unable to find installation candidates for pyqt5-plugins (5.15.4.2.2)
my pyproject.toml
[tool.poetry]
name = "imageengine"
version = "0.1.0"
description = "Simple image engine application for linux"
authors = ["Code Man"]
license = "GPLv3"
readme = "README.md"
[tool.poetry.dependencies]
python = "3.11"
pyqt5 = "5.15.4"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
my poetry info
Version: 1.2.2
Poetry-Core Version: 1.4.0
i tried found about this problem, but not founded...
Using version ^5.15.4.3.2 for pyqt5-tools
Updating dependencies
Resolving dependencies... (0.1s)
Package operations: 2 installs, 0 updates, 0 removals
• Installing pyqt5-plugins (5.15.4.2.2): Failed
RuntimeError
Unable to find installation candidates for pyqt5-plugins (5.15.4.2.2)
at /usr/lib/python3.10/site-packages/poetry/installation/chooser.py:103 in choose_for
99│
100│ links.append(link)
101│
102│ if not links:
→ 103│ raise RuntimeError(f"Unable to find installation candidates for {package}")
104│
105│ # Get the best link
106│ chosen = max(links, key=lambda link: self._sort_key(package, link))
107│
I run Poetry in combination together with tox for my unittests.
[tox]
skipsdist = True
envlist = autofix,linters,unittests
isolated_build = True
[testenv:unittests]
commands =
poetry run pytest {posargs: {[pytest-config]posargs}}
I run the tests on my Jenkins Agent, which uses Python 3.9, but I also want to run my tests for Python 3.7 and 3.8.
Does anyone know how to do with Tox and Poetry?
I tried this:
envlist = autofix,linters,{py37,py38,py39}-unittests,pre-commit
but this results in:
C:\Users\xcg5847\Miniconda3\envs\testme\lib\site-packages\tox\config\__init__.py:670: UserWarning: conflicting basepython version (set 3.9, should be 3.7) for env 'py37-unittests';resolve conflict or set ignore_basepython
_conflict
There's a default section in tox, the [testenv] section. Note especially that this does not declare a name. This is the section that is run using the first available, or specifically selected, python executable.
Using the default section with envlist entry below should do the trick:
[tox]
skipsdist = True
envlist = py37,py38,autofix,linters
isolated_build = True
[testenv]
commands =
poetry run pytest {posargs: {[pytest-config]posargs}}
And then tox will use py37 and py38 to run the [testenv] section. Assuming you have autofix,linters defined somewhere below.
Bonus:
Use a envlist = py,autofix,linters configuration. The py will select the first python executable on your PATH. Handy for working with coworkers. And then, in your CI, you can run a dedicated python executable with tox -e py38. Food for thought.
Source
I recently added the package typepigeon to conda-forge. On conda-forge it is currently at version 1.0.9; however, when installing typepigeon via conda install, the output of pip list shows its version to be 0.0.0.post2.dev0+a27ab2a instead of 1.0.9.
conda list:
typepigeon 1.0.9 pyhd8ed1ab_0 conda-forge
pip list:
typepigeon 0.0.0.post2.dev0+a27ab2a
I think the issue arises from the way I am assigning the version (I am using dunamai to extract the Git tag as the version number). This version extraction is done within setup.py of typepigeon.
try:
__version__ = Version.from_any_vcs().serialize()
except RuntimeError as error:
warnings.warn(f'{error.__class__.__name__} - {error}')
__version__ = '0.0.0'
When conda-forge builds the feedstock, I think it might be looking at the Git tag of the feedstock repository instead of the version from PyPI (as it is locally executing setup.py).
How can I modify the Conda Forge recipe to force the PyPI version?
I've figured out a solution; it might not be the best possible way to do this, but it works for my workflow.
I injected the version into the setup.py by looking for an environment variable (that I called __version__):
if '__version__' in os.environ:
__version__ = os.environ['__version__']
else:
from dunamai import Version
try:
__version__ = Version.from_any_vcs().serialize()
except RuntimeError as error:
warnings.warn(f'{error.__class__.__name__} - {error}')
__version__ = '0.0.0'
Then, in the conda-forge recipe, I added an environment variable (__version__) to the build step:
build:
noarch: python
script: export __version__={{ version }} && {{ PYTHON }} -m pip install . -vv
I would like to install a package from a git repository specifying a commit id using pipenv (I belive it should be very similar If I would use pip)
so far I tried:
pipenv install "git+ssh://git#bitbucket.org/<username>/<repository>.git/<commit_id>#egg=mypackage"
which is apending the following line to the Pipfile & provides no errors
<package-name> = {git = "ssh://git#bitbucket.org/<username>/<repository>.git/<commit_id>"}
If I import the package import mypackage it detects it but its dependencies are missing.
The setup.py of mypackage looks like;
import setuptools
with open("README.md", "r") as readme:
long_description = readme.read()
with open("./requirements.txt", "r") as fh:
requirements = fh.readlines()
setuptools.setup(
name='mypackage',
url='https://bitbucket.org/<username>/<repositroy>',
packages=setuptools.find_packages(),
install_requires=[req for req in requirements if req[0] not in ["#", "-"]],
)
Just figured it out by reading this that the revision id should be specified after a #
pipenv install "git+ssh://git#bitbucket.org/<username>/<repository>.git#<commit_id>#egg=<package_name>"
I installed ansible using pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python get-pip.py
sudo pip install ansible
But I cannot find either ~/.ansible.cfg or etc/ansible in macOS.
$ansible --version
WARNING: Executing a script that is loading libcrypto in an unsafe way. This will fail in a future version of macOS. Set the LIBRESSL_REDIRECT_STUB_ABORT=1 in the environment to force this into an error.
ansible 2.10.0.dev0
config file = None
configured module search path = [u'/Users/nethminiromina/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /Users/nethminiromina/Library/Python/2.7/lib/python/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.16 (default, Oct 17 2019, 17:14:30) [GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.32.4) (-macos10.15-objc-s
How can I find or setup inventory file?
Q: "Cannot find etc/ansible"
A: pip show -f ansible should show the installed files. If the configuration file is missing create one. See Configuring Ansible.
Q: "How can I find or setup inventory file?"
A: See Where to store Ansible host file on Mac OS X.
You can use ansible-config to show the config file location
% ansible-config --version
ansible-config [core 2.13.1]
config file = None
configured module search path = ['/Users/myusername/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ansible
ansible collection location = /Users/myusername/.ansible/collections:/usr/share/ansible/collections
executable location = /Library/Frameworks/Python.framework/Versions/3.9/bin/ansible-config
python version = 3.9.7 (v3.9.7:1016ef3790, Aug 30 2021, 16:39:15) [Clang 6.0 (clang-600.0.57)]
jinja version = 3.1.2
libyaml = True
In this case I had no configuration file (config file = None) so I generated an empty one (option --disabled means all entries are commented out) in the current directory with
% ansible-config init --disabled > ansible.cfg
Now ansible-config can find a configuration file in the current directory /localDir
% ansible-config --version
ansible-config [core 2.13.1]
config file = /localDir/ansible.cfg
[ . . . ]
Note: consider security issues Avoiding security risks with ansible.cfg in the current directory.
Here's the priority list of places where Ansible will search for a config file (see configuration file):
ANSIBLE_CONFIG (environment variable if set)
ansible.cfg (in the current directory)
~/.ansible.cfg (in the home directory)
/etc/ansible/ansible.cfg