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
10
votes
0 answers

Should I be using only pyproject.toml?

Should I be using only pyproject.toml or use it with setup.py and setup.cfg? Or perhaps some other combination of them. I can't find any definitive answer to this question so I'd be pleased if someone could enlighten the matter.
paavoto
  • 127
  • 4
10
votes
3 answers

how to prevent Poetry to consider .gitignore

I am working on a python project which uses pythonnet with several C# dll's as dependencies. As I do not want to push the dll's to the git repository I adapted the .gitignore file. However, now Poetry does not include the dll's into the python…
jodá
  • 342
  • 7
  • 25
10
votes
1 answer

How to build an sdist with pip?

I'm in the process of converting my projects to use flit as their build backend using pyroject.toml as defined in PEP517. I still have some projects that will continue to use setuptools as their build backend. Some projects may not be PEP 517…
Brendan Abel
  • 35,343
  • 14
  • 88
  • 118
10
votes
4 answers

How can I use relative importing in Python3 with an if __name__='__main__' block?

I am making a package, and the modules within this package have code inside if __name__=='__main__': blocks for testing purposes. But my attempts to use relative imports in these modules causes errors. I have read this thread and the billion…
pyjamas
  • 4,608
  • 5
  • 38
  • 70
10
votes
1 answer

Packaging Python dependencies in subdirectory for AWS Lambda

I came across an article on serverlesscode.com about building Python 3 apps for AWS Lambda that recommends using pip (or pip3) to install dependencies in a /vendored subdirectory. I like this idea as it keeps the file structure clean, but I'm having…
Harry
  • 4,660
  • 7
  • 37
  • 65
10
votes
4 answers

How do you recursively get all submodules in a python package?

Problem I have a folder structure like this: - modules - root - abc hello.py __init__.py - xyz hi.py __init__.py blah.py __init__.py foo.py bar.py …
Vivek Joshy
  • 974
  • 14
  • 37
10
votes
1 answer

Correct use of PEP 508 environment markers in setup.cfg

I am trying to make use of PEP 496 -- Environment Markers and PEP 508 -- Dependency specification for Python Software Packages by specifying dependencies that only make sense on specific OS. My setup.py looks like this: import setuptools assert…
toriningen
  • 7,196
  • 3
  • 46
  • 68
10
votes
3 answers

How should I handle importing third-party libraries within my setup.py script?

I'm developing a Python application and in the process of branching off a release. I've got a PyPI server set up on a company server and I've copied a source distribution of my package onto it. I checked that the package was being hosted on the…
Tagc
  • 8,736
  • 7
  • 61
  • 114
10
votes
2 answers

How do I add cv2 as a requirement in a python package?

I'm trying to make my own package which uses OpenCV Python module cv2. However when using PyCharm, it warns that the Package requirement is not satisfied. I suspect this is because I used the recommended method of copy/pasting cv2.pyd into my…
Bill
  • 698
  • 1
  • 5
  • 22
10
votes
1 answer

Difference between devpi and pypi server

Had a quick question here, I am used to devpi and was wondering what is the difference between devpi and pypi server? Is one better than another? Which of this one scale better?
wodash
  • 103
  • 1
  • 5
10
votes
1 answer

How to import a module but ignoring the package's __init__.py?

I'm trying to import a function which is in a module inside a package in Python, but when I try: from package.module import some_function Python executes the package's __init__.py but it can't happen. Is there a way to import the function telling…
9
votes
1 answer

Specifying test dependencies in pyproject.toml and getting them installed with pip install -e

I have a Python project with a pyproject.toml similar to the one below. I use python build to generate an package I use to install in production environments. For development environments, I use pip install -e . I'm trying to figure out how to make…
devnectar
  • 99
  • 1
  • 3
9
votes
4 answers

pip installing environment.yml as if it's a requirements.txt

I have an environment.yml file, but don't want to use Conda: name: foo channels: - defaults dependencies: - matplotlib=2.2.2 Is it possible to have pip install the dependencies inside an environment.yml file as if it's a requirements.txt…
Intrastellar Explorer
  • 3,005
  • 9
  • 52
  • 119
9
votes
2 answers

Twine is defaulting "long_description_content_type" to text/x-rst

Heres is my setup setup( name="`...", version="...", description=..., long_description_content_type="text/markdown", long_description=README, author="...", classifiers=[...], packages=["..."], …
ElLoko 233
  • 473
  • 1
  • 5
  • 11
9
votes
3 answers

Getting Python package distribution version from within a package

You can get the version of a python distribution using import pkg_resources pkg_resources.get_distribution("distro").version This is great if you know the distribution name, however I need to dynamically figure out my distribution name at…
Gricey
  • 1,321
  • 1
  • 18
  • 38