Skip to content

Commit de379bc

Browse files
authored
Merge pull request #3148 from regro/pypi-url
feat: pypi lowercase transforms
2 parents 7a6bcd9 + 50dcadb commit de379bc

File tree

7 files changed

+514
-11
lines changed

7 files changed

+514
-11
lines changed

conda_forge_tick/url_transforms.py

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,22 @@ def _pypi_name_munger(url):
8989

9090
def _pypi_munger(url):
9191
names = [
92+
[
93+
"{{ name }}",
94+
("{{ name|lower }}",),
95+
],
9296
[
9397
"{{ name }}",
9498
(
99+
"{{ name.replace('_', '-').lower() }}",
95100
"{{ name.replace('_', '-') }}",
101+
'{{ name.replace("_", "-").lower() }}',
102+
"{{ name.replace('_','-').lower() }}",
103+
'{{ name.replace("_","-").lower() }}',
104+
"{{ name|replace('_', '-')|lower }}",
105+
'{{ name|replace("_", "-")|lower }}',
106+
"{{ name|replace('_','-')|lower }}",
107+
'{{ name|replace("_","-")|lower }}',
96108
'{{ name.replace("_", "-") }}',
97109
"{{ name.replace('_','-') }}",
98110
'{{ name.replace("_","-") }}',
@@ -105,7 +117,15 @@ def _pypi_munger(url):
105117
[
106118
"{{ name }}",
107119
(
120+
"{{ name.replace('-', '_').lower() }}",
108121
"{{ name.replace('-', '_') }}",
122+
'{{ name.replace("-", "_").lower() }}',
123+
"{{ name.replace('-','_').lower() }}",
124+
'{{ name.replace("-","_").lower() }}',
125+
"{{ name|replace('-', '_')|lower }}",
126+
'{{ name|replace("-", "_")|lower }}',
127+
"{{ name|replace('-','_')|lower }}",
128+
'{{ name|replace("-","_")|lower }}',
109129
'{{ name.replace("-", "_") }}',
110130
"{{ name.replace('-','_') }}",
111131
'{{ name.replace("-","_") }}',
@@ -117,16 +137,36 @@ def _pypi_munger(url):
117137
],
118138
]
119139
if "/pypi." in url or "/files.pythonhosted.org" in url:
120-
burl, eurl = url.rsplit("/", 1)
140+
burl, murl, eurl = url.rsplit("/", 2)
121141
for _names in names:
122142
for vhave, vrep in permutations(_names, 2):
123143
if isinstance(vhave, tuple):
124144
for _v in vhave:
125-
if _v in eurl:
126-
yield burl + "/" + eurl.replace(_v, vrep)
127-
elif vhave in eurl:
145+
if _v in eurl or _v in murl:
146+
yield (
147+
burl
148+
+ "/"
149+
+ murl.replace(_v, vrep)
150+
+ "/"
151+
+ eurl.replace(_v, vrep)
152+
)
153+
elif vhave in eurl or vhave in murl:
128154
assert isinstance(vrep, tuple)
129-
yield burl + "/" + eurl.replace(vhave, vrep[0])
155+
yield (
156+
burl
157+
+ "/"
158+
+ murl.replace(vhave, vrep[0])
159+
+ "/"
160+
+ eurl.replace(vhave, vrep[0])
161+
)
162+
if len(vrep) > 1:
163+
yield (
164+
burl
165+
+ "/"
166+
+ murl.replace(vhave, vrep[1])
167+
+ "/"
168+
+ eurl.replace(vhave, vrep[1])
169+
)
130170

131171

132172
def _github_munger(url):

tests/test_url_transforms.py

Lines changed: 314 additions & 4 deletions
Large diffs are not rendered by default.

tests/test_version_migrator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
("boost", "1.74.0"),
5757
("boostcpp", "1.74.0"),
5858
("event_stream", "1.6.3"),
59+
("21cmfast", "3.4.0"),
5960
# these contain sources that depend on conda build config variants
6061
pytest.param(
6162
"polars_mixed_selectors",
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{% set name = "21cmFAST" %}
2+
{% set version = "3.3.1" %}
3+
4+
package:
5+
name: {{ name|lower }}
6+
version: {{ version }}
7+
8+
source:
9+
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz
10+
sha256: 96f5809d111a8a137c25758fa3f41586ea44cecba7ae191518767895afc7b3c6
11+
12+
13+
build:
14+
number: 1
15+
script:
16+
- export SETUPTOOLS_SCM_PRETEND_VERSION={{ version }}
17+
- INC=${PREFIX}/include LIB=${PREFIX}/lib {{ PYTHON }} -m pip install . -vv
18+
skip: true # [win]
19+
20+
requirements:
21+
build:
22+
- {{ compiler('c') }}
23+
- llvm-openmp # [osx]
24+
- libgomp # [linux]
25+
- python # [build_platform != target_platform]
26+
- cross-python_{{ target_platform }} # [build_platform != target_platform]
27+
host:
28+
- python
29+
- pip
30+
- cffi
31+
- fftw
32+
- gsl
33+
- llvm-openmp # [osx]
34+
- libgomp # [linux]
35+
- libblas
36+
- nomkl
37+
run:
38+
- python
39+
- scipy
40+
- numpy
41+
- click
42+
- pyyaml
43+
- cffi >=1.0
44+
- scipy
45+
- astropy >=2.0
46+
- h5py >=2.8.0
47+
- cached-property
48+
- matplotlib-base
49+
- fftw
50+
- gsl
51+
- nomkl
52+
- bidict
53+
- psutil
54+
- setuptools_scm
55+
56+
test:
57+
imports:
58+
- py21cmfast
59+
commands:
60+
- 21cmfast --help
61+
62+
about:
63+
home: https://github.com/21cmFAST/21cmFAST
64+
license: MIT
65+
license_family: MIT
66+
license_file: LICENSE
67+
summary: A semi-numerical cosmological simulation code for the 21cm signal
68+
description: |
69+
21cmFAST provides a simple and fast simulation package for the cosmological
70+
21cm signal as either coeval cubes or full lightcones.
71+
doc_url: https://21cmFAST.readthedocs.io/
72+
dev_url: https://github.com/21cmFAST/21cmFAST
73+
74+
extra:
75+
recipe-maintainers:
76+
- steven-murray
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{% set name = "21cmFAST" %}
2+
{% set version = "3.4.0" %}
3+
4+
package:
5+
name: {{ name|lower }}
6+
version: {{ version }}
7+
8+
source:
9+
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name|lower }}/{{ name|lower }}-{{ version }}.tar.gz
10+
sha256: aff3b5a2adb30ad9a6c2274461901686606e9fdb5e3ff7040cbdf22755d7469f
11+
12+
13+
build:
14+
number: 0
15+
script:
16+
- export SETUPTOOLS_SCM_PRETEND_VERSION={{ version }}
17+
- INC=${PREFIX}/include LIB=${PREFIX}/lib {{ PYTHON }} -m pip install . -vv
18+
skip: true # [win]
19+
20+
requirements:
21+
build:
22+
- {{ compiler('c') }}
23+
- llvm-openmp # [osx]
24+
- libgomp # [linux]
25+
- python # [build_platform != target_platform]
26+
- cross-python_{{ target_platform }} # [build_platform != target_platform]
27+
host:
28+
- python
29+
- pip
30+
- cffi
31+
- fftw
32+
- gsl
33+
- llvm-openmp # [osx]
34+
- libgomp # [linux]
35+
- libblas
36+
- nomkl
37+
run:
38+
- python
39+
- scipy
40+
- numpy
41+
- click
42+
- pyyaml
43+
- cffi >=1.0
44+
- scipy
45+
- astropy >=2.0
46+
- h5py >=2.8.0
47+
- cached-property
48+
- matplotlib-base
49+
- fftw
50+
- gsl
51+
- nomkl
52+
- bidict
53+
- psutil
54+
- setuptools_scm
55+
56+
test:
57+
imports:
58+
- py21cmfast
59+
commands:
60+
- 21cmfast --help
61+
62+
about:
63+
home: https://github.com/21cmFAST/21cmFAST
64+
license: MIT
65+
license_family: MIT
66+
license_file: LICENSE
67+
summary: A semi-numerical cosmological simulation code for the 21cm signal
68+
description: |
69+
21cmFAST provides a simple and fast simulation package for the cosmological
70+
21cm signal as either coeval cubes or full lightcones.
71+
doc_url: https://21cmFAST.readthedocs.io/
72+
dev_url: https://github.com/21cmFAST/21cmFAST
73+
74+
extra:
75+
recipe-maintainers:
76+
- steven-murray

tests/test_yaml/version_dash_extensions_correct.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package:
77
version: {{ version }}
88

99
source:
10-
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name.replace('-', '_') }}-{{ version }}.tar.gz
10+
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name.replace('-', '_').lower() }}/{{ name.replace('-', '_').lower() }}-{{ version }}.tar.gz
1111
sha256: b36fcf6fd74d87cafdbabc9568c3ae0097712ccee8f7d59be8e916b51d40b106
1212

1313
build:

tests/test_yaml/version_pypiurl_correct.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package:
66
version: "{{ version }}"
77

88
source:
9-
url: "https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name.replace('_', '-') }}-{{ version }}.tar.gz"
9+
url: "https://pypi.io/packages/source/{{ name[0] }}/{{ name.replace('_', '-').lower() }}/{{ name.replace('_', '-').lower() }}-{{ version }}.tar.gz"
1010
sha256: f3fe3f89011899b82451669cf1dbe4978523b8ac0f62c9c116429876fe8b6be8
1111

1212
build:

0 commit comments

Comments
 (0)