Questions tagged [python-packaging]

Packages are namespaces which contain multiple packages and modules themselves.

A package is a directory containing a special file called __init__.py (which indicated that the directory contains a python package) and sub-packages and modules. The package name is determined by the name of the directory.

1369 questions
37
votes
17 answers

Message "note: This error originates from a subprocess, and is likely not a problem with pip"

While downloading pip install allennlp==1.0.0 allennlp-models==1.0.0, I faced this problem: [6 lines of output] running bdist_wheel running build running build_py running build_ext building…
37
votes
2 answers

Is `setup.cfg` deprecated?

It's not completely clear to me, what is the status of setup.cfg. I am looking for solutions for my other question about PEP 508 environment markers, and I became totally confused. To me it seems that setup.cfg is an improvement over setup.py,…
toriningen
  • 7,196
  • 3
  • 46
  • 68
33
votes
3 answers

How to list dependencies for a python library without installing?

Is there a way to get a list of dependencies for a given python package without installing it first? I can currently get a list of requirements, but it requires installing the packages. For example, I can use pip to show basic requirements info,…
Brendan Abel
  • 35,343
  • 14
  • 88
  • 118
32
votes
2 answers

Right way to set python package with sub-packages

I am trying to set a package with sub-packages in python. Here is the tree structure that I have at the moment: myPackage ├── __init__.py ├── mySubPackage1 │   ├── foo2.py │   ├── foo.py │   └── __init__.py ├── mySubPackage2 │   ├── bar2.py │   ├──…
Dror
  • 12,174
  • 21
  • 90
  • 160
31
votes
3 answers

How to build a source distribution without using setup.py file?

With the following package structure . ├── my_package │ └── __init__.py ├── setup.cfg └── setup.py Contents of setup.py from setuptools import setup setup() Contents of setup.cfg [metadata] name = my_package version = 0.1 [options] packages =…
platypus
  • 1,128
  • 8
  • 15
30
votes
1 answer

Relative imports in Python

Hey all -- I am pulling my hair out with relative imports in Python. I've read the documentation 30 times and numerous posts here on SO and other forums -- still doesn't seem to work. My directory structure currently looks like this src/ …
apexdodge
  • 6,657
  • 4
  • 26
  • 33
28
votes
7 answers

How to access python package metadata from within the python console?

If I have built a python package employing distutils.core, e.g. via setup( ext_package="foo", author="me", version="1.0", description="foo package", packages=["foo",], ) where does all the metadata go (what is it intended for?)…
dastrobu
  • 1,600
  • 1
  • 18
  • 32
27
votes
3 answers

Automating Python package release process

I've just started an open source Python project that I hope might be popular one day. At the moment to release a new version I have to do a few things. Test all the things. Edit mypackage.VERSION variable, which setup.py imports from __init__ Build…
Oli
  • 235,628
  • 64
  • 220
  • 299
27
votes
2 answers

Python setuptools/distutils custom build for the `extra` package with Makefile

Preamble: Python setuptools are used for the package distribution. I have a Python package (let us call it my_package), that has several extra_require packages to it. Everything works just find (installation and build of the package, as well as…
26
votes
1 answer

Difference between 'Directory' and 'Python Package' in PyCharm

When to use Directory over Python Package? PS: I understand that I can import from latter but not former. If so, why not create everything as a Python Package? Also, does PyCharm mark a location as one or the other based on its name? What is the…
GuSuku
  • 1,371
  • 1
  • 14
  • 30
24
votes
5 answers

Is requirements.txt still needed when using pyproject.toml?

Since mid 2022 it is now possible to get rid of setup.py, setup.cfg in favor of pyproject.toml. Editable installs work with recent versions of setuptools and pip and even the official packaging tutorial switched away from setup.py to…
Bastian Venthur
  • 12,515
  • 5
  • 44
  • 78
24
votes
2 answers

Is there a simple way to convert setup.py to pyproject.toml

We have multiple python projects, and are considering converting them to use pyproject.toml instead of setup.py. Is there a simple way to automate this?
24
votes
1 answer

single-sourcing package version for setup.cfg Python projects

For traditional Python projects with a setup.py, there are various ways of ensuring that the version string does not have to be repeated throughout the code base. See PyPA's guide on "Single-sourcing the package version" for a list of…
Nico Schlömer
  • 53,797
  • 27
  • 201
  • 249
24
votes
3 answers

How to build and distribute a Python/Cython package that depends on third party libFoo.so

I've written a Python module that depends on some C extensions. Those C extensions depend in turn on several compiled C libraries. I'd like to be able to distribute this module bundled with all the dependencies. I've put together a minimal example…
Sevenless
  • 2,805
  • 4
  • 28
  • 47
24
votes
5 answers

How to accomplish relative import in python

stuff/ __init__.py mylib.py Foo/ __init__.py main.py foo/ __init__.py script.py script.py wants to import mylib.py This is just an example, but really I just want to do a relative import…
random
  • 573
  • 1
  • 4
  • 9
1
2
3
91 92