Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle PEP-496 Environment Markers #246

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion pip/flatpak-pip-generator
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import subprocess
import sys
import tempfile
import urllib.request
import platform

from collections import OrderedDict

Expand Down Expand Up @@ -44,6 +45,21 @@ parser.add_argument('--runtime',
opts = parser.parse_args()


def format_full_version(info):
version = '{0.major}.{0.minor}.{0.micro}'.format(info)
kind = info.releaselevel
if kind != 'final':
version += kind[0] + str(info.serial)
return version

ENV = {
"sys_platform": sys.platform,
"python_version": platform.python_version()[:3],
"python_full_version": format_full_version(sys.version_info),
"implementation_version": format_full_version(sys.implementation.version)
}


def get_pypi_url(name: str, filename: str) -> str:
url = 'https://pypi.org/pypi/{}/json'.format(name)
print('Extracting download url for', name)
Expand Down Expand Up @@ -298,7 +314,9 @@ system_packages = ['cython', 'easy_install', 'mako', 'markdown', 'meson', 'pip',

fprint('Generating dependencies')
for package in packages:

parts = package.line.split(";")
if len(parts) == 2 and not eval(parts[1].strip(), ENV, ENV):
continue
if package.name is None:
print('Warning: skipping invalid requirement specification {} because it is missing a name'.format(package.line), file=sys.stderr)
print('Append #egg=<pkgname> to the end of the requirement line to fix', file=sys.stderr)
Expand Down