Why ist setuptools not installing install_requires - python

My Python package is installed using setuptools configured with a setup.cfg file. In it requirements are specified:
[options]
packages = find:
zip_safe = True
include_package_data = True
install_requires =
gmsh >= 4.10.5
matplotlib >= 3.6.1
numpy >= 1.23.3
When installing the package via pip the package to a fresh venv non of the requirements are installed. The output of pip show no errors or related information. However, once manually installing them everything works fine. How can I get pip to actually install the requirements?

It is mentioned in the comments that you have a pyproject.toml file. If you use the toml configuration then you do not need the setup.cfg at all. Delete the setup.cfg and add in pyproject.toml:
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = ...
version = ...
dependencies = [
"gmsh >= 4.10.5",
"matplotlib >= 3.6.1",
"numpy >= 1.23.3",
]

Related

PIP: Cant install dependencies from builded poetry wheel if pyproject.toml contains deps from file

Im using poetry in my project for dependencies, so my pyproject.toml contains all my dependencies. My goal is is to build a wheel from the current project and install them in another virtualenv using pip. But im facing an error:
pip._vendor.pkg_resources.RequirementParseError: Invalid URL: artifacts/pp-0.358.0.tar.gz
I guess that the problem may be in the relative path, but I don't know how to fix it, because when installing dependencies, this package is taken from the tar.gz file located in this path.
Мой pyproject.toml:
[tool.poetry]
name = "package_name"
version = "0.0.0"
description = ""
readme = "README.md"
packages = [
{include = "package1"},
{include = "package2"},
{include = "package3"},
]
[tool.poetry.dependencies]
python = "~3.8"
pp = {file = "artifacts/pp-0.358.0.tar.gz"}
...some other deps
To build a wheel im using following command:
poetry build --format wheel
Installing to another virtualenv with following command:
pip3 install /Users/av/Projects/package_name/dist/package_name-0.0.0-py3-none-any.whl
Is it any ways to fix it somehow? If I comment pp line in dependencies installation works well.

How to configure setuptools with setup.cfg to include platform name, python tag and ABI tag?

Due to the console message of setup.py install is deprecated, I am in the middle of upgrading my existing setup.py install to the recommended setup.cfg with build
My existing setup.py looks something like
from setuptools import setup
setup(
name='pybindsample',
version='0.1.0',
packages=[''],
package_data={'': ['pybindsample.so']},
has_ext_modules=lambda: True,
)
My current translation looks like:
setup.cfg
[metadata]
name = pybindsample
version = 0.1.0
[options]
packages = .
[options.package_data]
. = pybindsample.so
pyproject.toml
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
My question is how can I translate has_ext_modules=lambda: True? has_ext_modules=lambda: True is from the solution here. Without this, after executing python3 -m build --wheel the file name of the generated wheel will become pybindsample-0.1.0-py3-none-any.whl, whereas my old python3 setup.py bdist_wheel will generate wheel with file name pybindsample-0.1.0-cp39-cp39-macosx_11_0_x86_64.whl. I have attempted
setup.cfg
[metadata]
name = pybindsample
version = 0.1.0
[options]
packages = .
has_ext_modules=lambda: True,
[options.package_data]
. = pybindsample.so
but it still generates pybindsample-0.1.0-py3-none-any.whl, I also attempted
setup.cfg
[metadata]
name = pybindsample
version = 0.1.0
[options]
packages = .
[options.package_data]
. = pybindsample.so
[bdist_wheel]
python-tag = c39
plat-name = macosx_11_0_x86_64
py-limited-api = c39
this generates pybindsample-0.1.0-cp39-none-macosx_11_0_x86_64.whl, and I couldn't figure out why the abi tag is still none.
What is the right way to configure setuptools with setup.cfg to include platform name, python tag, and ABI tag?

"requires" (pyproject.toml) with a local package in editable mode

I am using a pyproject.toml file to allow me to use third party packages during my build. (For example, I'd like to use the toml package in setup.up.) When I add a local package to "requires" (installed in editable mode), the build doesn't see the package. Is there a way to include local packages in my pyproject.toml other than explicitly deploying them to pypi?
Here's what my pyproject.toml file looks like currently:
[build-system]
requires = ["setuptools", "wheel", "toml", "my_local_package"]
You can do something like:
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools >= 61.2",
"versioningit # file:///Users/basnijholt/Downloads/versioningit",
"wheel",
]

Download dependencies declared in pyproject.toml using Pip

I have a Python project that doesn't contain requirements.txt.
But it has a pyproject.toml file.
How can I download packages (dependencies) required by this Python project and declared in pyproject.toml using the Pip package manager (instead of the build tool Poetry).
So instead of pip download -r requirements.txt, something like pip download -r pyproject.toml.
Here is an example of .toml file:
[build-system]
requires = [
"flit_core >=3.2,<4",
]
build-backend = "flit_core.buildapi"
[project]
name = "aedttest"
authors = [
{name = "Maksim Beliaev", email = "beliaev.m.s#gmail.com"},
{name = "Bo Yang", email = "boy#kth.se"},
]
readme = "README.md"
requires-python = ">=3.7"
classifiers = ["License :: OSI Approved :: MIT License"]
dynamic = ["version", "description"]
dependencies = [
"pyaedt==0.4.7",
"Django==3.2.8",
]
[project.optional-dependencies]
test = [
"black==21.9b0",
"pre-commit==2.15.0",
"mypy==0.910",
"pytest==6.2.5",
"pytest-cov==3.0.0",
]
deploy = [
"flit==3.4.0",
]
to install core dependencies you run:
pip install .
if you need test(develop) environment (we use test because it is a name defined in .toml file, you can use any):
pip install .[test]
To install from Wheel:
pip install C:\git\aedt-testing\dist\aedttest-0.0.1-py3-none-any.whl[test]
pip supports installing pyproject.toml dependencies natively.
As of version 10.0, pip supports projects declaring dependencies that are required at install time using a pyproject.toml file, in the form described in PEP 518. When building a project, pip will install the required dependencies locally, and make them available to the build process. Furthermore, from version 19.0 onwards, pip supports projects specifying the build backend they use in pyproject.toml, in the form described in PEP 517.
From the project's root, use pip's local project install:
python -m pip install .
You can export the dependencies to a requirements.txt and use pip download afterwards:
poetry export -f requirements.txt > requirements.txt
pip download -r requirements.txt

Install python package from svn using dependency_links in setup.py

I am trying to install hw3 package which has a dependency package hw2. My setup.py looks as follows -
setup(
name='hw3',
version='0.1',
packages = find_packages(),
install_requires = 'hw2',
dependency_links = [
r'svn+https://server.local/svn/Libraries/testPkg2/trunk#egg=hw2'
]
)
I get the following error when I run python setup.py install in windows cmd
svn: E170013: Unable to connect to a repository at URL 'svn+https://server.local/svn/Libraries/testPkg2/trunk'
svn: E125002: Undefined tunnel scheme 'https'
Alternatively, I have requirements.txt which is as follows
svn+https://server.local/svn/Libraries/testPkg2/trunk#egg=hw2
If I run pip install -r requirements.txt, it installs hw2 package successfully.
My svn version is
svn, version 1.9.7 (r1800392) compiled Aug 8 2017, 22:14:48 on
x86-microsoft-windows
how to resolve this error? Thanks
I am getting the same error for 'http' and 'svn'.
For 'ssh' it is
svn: E170012: Can't create tunnel
svn: E720002: Can't create tunnel: The system cannot find the file specified.
Maybe try it directly with the install_requires option (requires pip>=18.1):
setup(
name='hw3',
version='0.1',
packages = find_packages(),
install_requires = ['hw2#svn+https://server.local/svn/Libraries/testPkg2/trunk#egg=hw2'],
)
See also this answer to a related question https://stackoverflow.com/a/54216163/13835019.

Categories