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
23
votes
2 answers

python pip priority order with index-url and extra-index-url

I searched a bit but could not find a clear answer. The goal is, to have two pip indexes, one is a private index, that will be a first priority. And one is the standard PyPI. The priority is there to prevent the security risk of code injection. Say…
user3599803
  • 6,435
  • 17
  • 69
  • 130
22
votes
2 answers

Trying to read JSON file within a Python package

I am in the process of packaging up a python package that I'll refer to as MyPackage. The package structure is: MyPackage/ script.py data.json The data.json file comprises cached data that is read in script.py. I have figured out how to…
Mason Edmison
  • 594
  • 3
  • 16
21
votes
10 answers

module 'pip' has no attribute 'pep425tags'

When I am trying to install .whl with pip it said: ... is not a supported wheel on this platform to solve this problem, I searched the Internet and it said I can input this into repl import pip; print(pip.pep425tags.get_supported()) with this I…
Alina
  • 311
  • 1
  • 2
  • 5
20
votes
1 answer

Python commands to build distribution setup.py build vs python -m build

I'm learning about Python packaging, and according to this guide, the command to build a python distribution package seems to be python3 -m build. But I aslo found that there is a command line interface for setup.py file from setuptools: $ python…
oeter
  • 627
  • 2
  • 8
  • 23
20
votes
2 answers

How to build a C extension in keeping with PEP 517, i.e. with pyproject.toml instead of setup.py?

I want to build a C extension for CPython. I could do it traditionally with a setup.py file. However, for the reasons mentioned in PEP 517, I would prefer a declarative approach using a pyproject.toml. I understand that setuptools is the only build…
19
votes
1 answer

What is 'extra' in pypi dependency?

In requires_dist section of a package's json response from pypi, it is given: requires_dist : [ "bcrypt; extra == 'bcrypt'", "argon2-cffi (>=16.1.0); extra == 'argon2'" ] can anyone make it clear the second statement of each dependency,…
All Іѕ Vаиітy
  • 24,861
  • 16
  • 87
  • 111
19
votes
2 answers

Prevent package from being installed on old Python versions

What can we put in a setup.py file to prevent pip from collecting and attempting to install a package when using an unsupported Python version? For example magicstack is a project listed with the trove classifier: Programming Language :: Python :: 3…
wim
  • 338,267
  • 99
  • 616
  • 750
19
votes
1 answer

Pip install error missing 'libxml/xmlversion.h'

I need to install the python package xmlsec(https://pypi.python.org/pypi/xmlsec) and when I try running pip install xmlsec It gives me this error: src\xmlsec\constants.c(266) : fatal error C1083: Cannot open include file: 'libxml/xmlversion.h': No…
clue3434
  • 215
  • 1
  • 2
  • 8
18
votes
2 answers

Multilevel relative import

Multilevel relative import I have following folder structure top\ __init__.py util\ __init__.py utiltest.py foo\ __init__.py foo.py bar\ __init__.py foobar.py I want to access from foobar.py…
Razer
  • 7,843
  • 16
  • 55
  • 103
18
votes
2 answers

Python: How do I find which pip package a library belongs to?

I got a script transferred from someone else. And there is a module imported into the script. I'm wondering what is the best way to find out which pip package installed this library (other than search online). I tried to import the package and then…
Suanmeiguo
  • 1,365
  • 3
  • 17
  • 28
17
votes
2 answers

setup.py -- configuration for private / commercial projects

What can I put on our setup.py project configuration file to tell the developers that the project is a private/commercial application/library. Currently I set: setup( name='MyProject', version='0.1.0', license='(c) My Company', …
Laurent LAPORTE
  • 21,958
  • 6
  • 58
  • 103
16
votes
1 answer

How to build python project based on pyproject.toml

I would like to understand current state of Python build systems and requirements management. Imagine, that I checked out sources of some project that is using poetry (or pipenv). And this project has pyproject.toml file with build system specified.…
Andrey Tatarinov
  • 530
  • 1
  • 3
  • 11
16
votes
3 answers

Installing nltk data dependencies in setup.py script

I use NLTK with wordnet in my project. I did the installation manually on my PC, with pip: pip3 install nltk --user in a terminal, then nltk.download() in a python shell to download wordnet. I want to automatize these with a setup.py file, but I…
Tom Cornebize
  • 1,362
  • 15
  • 33
16
votes
5 answers

Import modules from subfolders

I have following arrangement of files: python |---- main.py |---- files |---- folder1 |---- a.py, a1.py, ... |---- folder2 |---- b.py, b1.py, ... I wanted to import my modules a.py and b.py to main.py. For this I…
user741592
  • 875
  • 3
  • 10
  • 25
15
votes
1 answer

python installing package with submodules

I have a custom project package with structure like: package-dir/ mypackage/ __init__.py submodule1/ __init__.py testmodule.py main.py requirements.txt setup.py using cd…
muon
  • 12,821
  • 11
  • 69
  • 88
1 2
3
91 92